[R] problems with pan(): Indizierung ausserhalb der Grenzen = subscript out of bounds

Leo Gürtler leog at anicca-vijja.de
Thu Nov 3 15:13:02 CET 2005


Dear alltogether,

I tried pan() to impute NAs for longitudinal data.
The terminology in the following output follows the pan manpage. No data 
are attached to this script as this may be too huge.


y = 15 responses
pred = at first just intercept was tried (later on covariates should follow)
subj = 168 different subjects with 4 to 6 observations for each subject 
at time points t1, t2, ..., t6

# extract of y
 > y[1:4,]
    anpr impr kepr   lernpr  lstofpr  nachwela   nachfak    nachw     
sbpr widapr zdompr   zerfpr zgleipr  zstimpr  zugrupr
2   3.50 2.75  3.4 2.222222 2.666667  3.333333 15.000000 5.909091 
2.333333      2    1.5 3.666667       4 3.000000 3.555556
202 2.25 2.50  3.6 2.222222 3.666667 12.000000 13.750000 7.777778 
1.666667      2    2.0 3.333333       4 3.333333 3.555556
402   NA   NA   NA       NA       NA        NA        NA       NA       
NA     NA     NA       NA      NA       NA       NA
602 1.75 2.75  3.4 1.555556 3.333333  2.666667  6.666667 5.000000 
2.000000      2    1.0 3.333333       4 2.666667 3.333333
 > dim(y)
[1] 940  15 # matrix y with 15 responses and 940 obs
# y is ordered according to subj
 > length(subj)
[1] 940     #940 obs of 168 different subjects (persons)
# extract of subj
 > subj[1:30]
 [1] 2 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 5 6 6 6 6 6 6 7 7
# how many observations for each subject
 > table(subj)
subj
  2   3   4   5   6   7   8   9  12  13  14  15  16  17  18  19  20  21  
23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  41  
42  43  44  46  47  48  49
  6   5   5   6   6   6   5   6   6   6   6   6   5   6   6   5   6   
6   6   6   5   6   6   5   6   6   4   6   5   5   6   6   6   5   6   
6   4   6   5   6   5   6   6
 50  52  53  55  57  58  59  60  61  62  64  66  67  68  69  70  72  73  
75  76  77  78  79  81  82  83  84  85  86  87  88  89  90  91  92  93  
94  95  97  98  99 100 101
  6   5   5   5   6   6   5   5   6   6   6   6   4   6   6   5   5   
6   6   5   6   4   6   5   5   4   6   5   6   6   4   5   5   6   6   
6   6   6   6   6   6   6   6
103 104 105 106 107 108 109 110 112 113 114 115 116 117 118 121 122 123 
124 125 126 127 128 129 130 131 132 133 134 135 137 138 139 140 141 142 
144 146 147 148 149 150 151
  5   6   5   6   6   6   5   5   5   6   6   5   5   6   5   6   6   
6   6   6   5   4   6   6   6   6   6   4   4   6   5   4   6   5   4   
6   6   6   6   6   6   5   5
152 153 154 155 156 157 158 159 160 162 164 165 166 167 170 171 173 174 
175 176 178 179 181 182 185 186 187 188 189 190 191 192 193 195 196 197 
198 199 200
  5   6   6   6   5   6   6   6   6   6   6   6   6   4   5   6   6   
6   6   5   6   6   6   6   6   6   6   5   6   6   6   5   6   6   6   
6   6   6   6
 > pred <- cbind(interc=rep(1,dim(y)[1]))     # just intercept (at first)
 > dim(pred)
[1] 940  1
xcol <- 1:dim(pred)[2]
 > xcol
[1] 1
#xcol = 1 , using all number of cols of pred[]
 > zcol <- c(1)    # = 1 , number of cols to use
 > y.ncol <- dim(y)[2]
 > n.zcol <- length(zcol)
 > prior <- list(a=y.ncol,
+              Binv=diag(y.ncol),
+              c=n.zcol,
+              Dinv=diag(n.zcol))
 > prior
$a
[1] 15

$Binv
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] 
[,13] [,14] [,15]
 [1,]    1    0    0    0    0    0    0    0    0     0     0     0     
0     0     0
 [2,]    0    1    0    0    0    0    0    0    0     0     0     0     
0     0     0
 [3,]    0    0    1    0    0    0    0    0    0     0     0     0     
0     0     0
 [4,]    0    0    0    1    0    0    0    0    0     0     0     0     
0     0     0
 [5,]    0    0    0    0    1    0    0    0    0     0     0     0     
0     0     0
 [6,]    0    0    0    0    0    1    0    0    0     0     0     0     
0     0     0
 [7,]    0    0    0    0    0    0    1    0    0     0     0     0     
0     0     0
 [8,]    0    0    0    0    0    0    0    1    0     0     0     0     
0     0     0
 [9,]    0    0    0    0    0    0    0    0    1     0     0     0     
0     0     0
[10,]    0    0    0    0    0    0    0    0    0     1     0     0     
0     0     0
[11,]    0    0    0    0    0    0    0    0    0     0     1     0     
0     0     0
[12,]    0    0    0    0    0    0    0    0    0     0     0     1     
0     0     0
[13,]    0    0    0    0    0    0    0    0    0     0     0     0     
1     0     0
[14,]    0    0    0    0    0    0    0    0    0     0     0     0     
0     1     0
[15,]    0    0    0    0    0    0    0    0    0     0     0     0     
0     0     1

$c
[1] 1

$Dinv
     [,1]
[1,]    1

#prior         a = number of cols in y
#              Binv = identity matrix (ncols = nrows = y)
#              c = length of zcol[]
#              Dinv = identity matrix (ncols = length(nzcol))

Now the error message:

 > pan(y, subj, pred, xcol, zcol, prior, seed=1234,iter=1000)
Fehler: Indizierung außerhalb der Grenzen"
# error massage = subscript out of bounds

I do not understand that. Thank you very much for every suggestion.

best,

leo




More information about the R-help mailing list