Error in crossGEEKron function of crossCarry package in R

46 views Asked by At

I am trying to do analysis for repeated measure crossover study with 2 periods, 2 treatment at 3 time. However, on running crossCarryKron function, I am getting this error: ****Error in r_media[ii, ] <- media_temp/(n_suj) : replacement has length zero** **

My data is in same format as in demo data- Arterial. I am not able to understand why i am getting this error. Can anyone help?

Code: carrydata<- createCarry(data=rop, treatment= "treatment", period= "period", id="sno") data<- carrydata$data carry<- carrydata$carryover

model<- CrossGEEKron(response= "syst", treatment = "treatment", 
         period = "period", id= "sno", time = "time",
         carry= "Carry_2", data=data, correlation="ar1")

Result:

Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
running glm to get initial regression estimate
(Intercept)     period2  treatment2     Carry_2        time 
   78.71847    -2.05556    -6.94444     1.88889     0.06081 
Error in r_media[ii, ] <- media_temp/(n_suj) : 
  replacement has length zero

My dataset is:

 time   babysuhidno        sno         syst diast    hr   period    treatment
                                
1   0   104944203   104944203   82  36  172 1   2
2   0   104944203   104944203   76  41  171 2   1
3   0   10583361    10583361    84  47  170 1   2
4   0   10583361    10583361    87  42  156 2   1
5   0   105855122   105855122   83  44  153 1   1
6   0   105855122   105855122   65  33  167 2   2
7   0   105855143   105855143   71  32  168 1   1
8   0   105855143   105855143   76  43  165 2   2
9   0   105904967   105904967   53  26  177 1   2
10  0   105904967   105904967   73  52  163 2   1
11  20  104944203   104944203   81  40  174 1   2
12  20  104944203   104944203   81  51  170 2   1
13  20  10583361    10583361    85  39  181 1   2
14  20  10583361    10583361    83  57  157 2   1
15  20  105855122   105855122   80  36  165 1   1
16  20  105855122   105855122   61  31  171 2   2
17  20  105855143   105855143   72  33  165 1   1
18  20  105855143   105855143   76  41  162 2   2
19  20  105904967   105904967   54  27  172 1   2
20  20  105904967   105904967   82  42  152 2   1
21  35  104944203   104944203   75  33  177 1   2
22  35  104944203   104944203   81  42  159 2   1
23  35  10583361    10583361    80  37  173 1   2
24  35  10583361    10583361    83  48  153 2   1
25  35  105855122   105855122   88  45  156 1   1
26  35  105855122   105855122   72  43  174 2   2
27  35  105855143   105855143   85  66  154 1   1
28  35  105855143   105855143   75  42  133 2   2
29  35  105904967   105904967   62  32  177 1   2
30  35  105904967   105904967   71  41  141 2   1

Anyone know how to circumvent this error?

1

There are 1 answers

0
AlirioCruz On

The problem occurs because the package only works with id=1,2,3,... that is, when they are a sequence of numbers. It is a package error that I am already resolving, I apologize, for the moment it should be done as follows:

rop$sno = as.numeric(factor(rop$sno))

carrydata<- createCarry(data=rop, treatment= "treatment", period= "period", id="sno") 
data<- carrydata$data 
carry<- carrydata$carryover


model<- CrossGEEKron(response= "syst", treatment = "treatment", 
                     period = "period", id= "sno", time = "time",
                     carry= "Carry_2", data=data, correlation="ar1")

model$QIC
model$Within
model$Between
summary(model$model)

And the Output will be:

> model$QIC
          geepack..QIC.model1.
QIC                       2462
QICu                      2048
Quasi Lik                -1019
CIC                        212
params                       5
QICC                      2420
> model$Within
      [,1]  [,2]  [,3]
[1,] 1.000 0.874 0.764
[2,] 0.874 1.000 0.874
[3,] 0.764 0.874 1.000
> model$Between
       [,1]   [,2]
[1,] 1.0000 0.0918
[2,] 0.0918 1.0000
> summary(model$model)

Call:
geepack::geeglm(formula = form1, family = gaussian, data = data, 
    id = id, zcor = rep(RR[upper.tri(RR)], n_suj), corstr = "userdefined")

 Coefficients:
            Estimate Std.err   Wald Pr(>|W|)    
(Intercept)  80.3777  6.5683 149.75   <2e-16 ***
period2      -2.6601 34.8293   0.01     0.94    
treatment2   -9.5611  8.5820   1.24     0.27    
Carry_2       2.0144 36.3217   0.00     0.96    
time          0.0548  0.0713   0.59     0.44    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation structure = userdefined 
Estimated Scale Parameters:

            Estimate Std.err
(Intercept)     67.9    35.7
  Link = identity 

Estimated Correlation Parameters:
        Estimate Std.err
alpha:1      0.8   0.362
Number of clusters:   5  Maximum cluster size: 6