Replies: 10 comments 7 replies
-
Sorry I can't do magic. Please provide a reproducible example in a really simplified case. |
Beta Was this translation helpful? Give feedback.
-
Appologies for not posting right away with an example - I was hoping this was a known issue or if I broke something obvious. I'm waiting for confirmation from a collaborator that I can share the original data, because I'm having issues reproducing the issue on my own. |
Beta Was this translation helpful? Give feedback.
-
There is a pipe symbol
All the best, Gerko |
Beta Was this translation helpful? Give feedback.
-
I can't even > reprex()
Rendering reprex...
Error: callr subprocess failed: <text>:24:43: unexpected ')'
23: imp <- mice(boys, m = 3, maxit = 2) # proof of concept
24: with(imp, lmer(age ~ hgt + (1 + bmi + tv |)
^
Type .Last.error.trace to see where the error occured But in > imp <- mice(boys, m = 3, maxit = 2) # proof of concept
iter imp variable
1 1 hgt wgt bmi hc gen phb tv reg
1 2 hgt wgt bmi hc gen phb tv reg
1 3 hgt wgt bmi hc gen phb tv reg
2 1 hgt wgt bmi hc gen phb tv reg
2 2 hgt wgt bmi hc gen phb tv reg
2 3 hgt wgt bmi hc gen phb tv reg
> with(imp, lmer(age ~ hgt + (1 + bmi + tv|)))
Error: unexpected ')' in "with(imp, lmer(age ~ hgt + (1 + bmi + tv|)" |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help. The error isn't happening in the analysis step though, it's happening when I call mice() to do the imputation step. I don't explicitly state an lmer formula anywhere. I've been searching around for any resources on multi-level imputation in mice or other packages or functions to use. I see the mice.impute.ml.lmer in miceadds, but I'm having a hell of a time getting that set up. I'd like to stick to an FCS approach because the analyses I want to do eventually involve random slopes, so joint modelling seems less appealing. But finding clear guidance with good documentation hasn't been easy. Any suggestions on good tutorials or resources for multi-level imputation would be helpful. |
Beta Was this translation helpful? Give feedback.
-
@gerkovink Thanks, R expects a variable name after |
Beta Was this translation helpful? Give feedback.
-
Have a look at the Multilevel Imputation Vignette Can't help you any further without a proper All the best, Gerko |
Beta Was this translation helpful? Give feedback.
-
Closing as the issue is not reproducible. |
Beta Was this translation helpful? Give feedback.
-
I am having the same error. I have not included data, however below is the output. NOTE: Data available upon request. >
+ pred_ <-
+ readxl::read_xlsx(
+ here("data/tmp/mi_working.xlsx"),
+ sheet = "pred_matrix",
+ range = "A1:L12"
+ ) %>%
+ .mice_pred_matrix()
+ pred_
+
> clus ID pb ac bhs tb age sex dep anx si
clus 0 0 0 0 0 0 0 0 0 0 0
ID 0 0 0 0 0 0 0 0 0 0 0
pb -2 0 0 0 0 0 0 0 0 0 0
ac -2 0 1 1 1 1 1 1 1 1 1
bhs -2 0 1 1 1 1 1 1 1 1 1
tb -2 0 1 1 1 1 1 1 1 1 1
age 0 0 0 0 0 0 0 0 0 0 0
sex 0 0 1 1 1 1 1 1 1 1 1
dep -2 0 1 1 1 1 1 1 1 1 1
anx -2 0 1 1 1 1 1 1 1 1 1
si -2 0 1 1 1 1 1 1 1 1 1
>
+ imp <-
+ mice(
+ lpa_cov2,
+ pred = pred_,
+ meth = "2l.pmm",
+ maxit = 0,
+ printFlag = FALSE
+ )
+
>
+ imp.5 <-
+ mice.mids(
+ imp,
+ maxit = 5,
+ print = FALSE
+ )
+
+ boundary (singular) fit: see ?isSingular
boundary (singular) fit: see ?isSingular
Error in str2lang(x) : <text>:1:43: unexpected ')'
1: dv._lmer~1+pb+ac+bhs+tb+age+dep+anx+si+(1|)
^
> |
Beta Was this translation helpful? Give feedback.
-
I received this error ( |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I'm trying to set up a multi-level imputation, but am hitting an error that looks like a bug. The model involves imputation of subject and item level variables (i.e. 2 sets of level 2 variables), and therefore two random intercepts - one for the subject factor, and one for the item factor. When I try to set things up with impute.2l.lmer, I get this error:
Error in str2lang(x) : :1:105: unexpected ')'
1: dv._lmer~1+subid+itemid+cwwt+cagtb+hub_connections+tdiff+rdiff+freq.diff+phonsimdiff+rt+(1+subid+itemid|)
Where the formula seems mangled - the subid and itemid should go on the other side of the |. As well, it seems like subid and itemid are also being included as fixed effects, even though they are coded as 2 for the imputed variable in the predictor matrix.
Beta Was this translation helpful? Give feedback.
All reactions