MICE Error in parse(text = x, keep.source = FALSE) : <text>:1:141: unexpected ')'

Viewed 36

I am trying to conduct a multiple imputation using a 2-level zero-inflated negative binomial model using MICE. This is my code:

    ini<-mice(mydata2, m = 10, maxit=0)
    meth<-ini$method
    pred<-ini$predictorMatrix
    meth[3]<-"2l.zinb"
    pred[1,]<-c(-2,0,3,3,3)
    set.seed(123456)
    ##impute missing data
    imp2l<-mice(mydata2, maxit=10, method=meth, predictorMatrix=pred, m=10, print = FALSE)

When I run the imputation line of code I get the following error:

Error in parse(text = x, keep.source = FALSE) : :1:141: unexpected ')' 1:nz~DistrictCode+AY2012to2013+AY2013to2014+AY2014to2015+AY2015to2016+AY2016to2017+AY2017to2018+AY2018to2019+treatTx55to80+treatTx80ormore+(1|)

I have followed other threads that have a similar error and have made sure that my variables don't have any illegal characters or spaces in the variable name or even the label names. My data structure looks like this:

'data.frame':   7461 obs. of  5 variables:
 $ DistrictCode   : num  61176 61176 61176 61176 61176 ...
 $ AY             : Factor w/ 8 levels "2011to2012","2012to2013",..: 1 2 3 4 5 6 7 8 1 2 ...
 $ TotalExpulsions: num  23 24 15 10 17 13 16 13 14 4 ...
 $ prepost        : Factor w/ 2 levels "Preinterventionperiod",..: 1 1 2 2 2 2 2 2 1 1 ...
 $ treat          : Factor w/ 3 levels "Control0to55",..: 1 1 1 1 1 1 1 1 2 2 ...

Is there something that I'm missing? Thank you in advance.

0 Answers
Related