Dear list, I am trying to impute the two level data, I have a question about a warning. Could you give me some suggestions please? Thank you very much. Here is my code and output of mice package:> ini <- mice(try, maxit=0) > pred=ini$pred > predFAC1_1 FAC2_1 FAC3_1 FAC4_1 FAC5_1 FAC6_1 FAC7_1 FAC8_1 FAC9_1 FAC10_1 ClassSize_1 ClassSize_2 ClassSize_3 intercept TeacherID_1 bulg_1 bulg_2 FAC1_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC2_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC3_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC4_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC5_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC6_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC7_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC8_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC9_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC10_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 intercept 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 TeacherID_1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 bulg_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bulg_2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bulg_3 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 bulg_3 FAC1_1 0 FAC2_1 0 FAC3_1 0 FAC4_1 0 FAC5_1 0 FAC6_1 0 FAC7_1 0 FAC8_1 0 FAC9_1 0 FAC10_1 0 ClassSize_1 0 ClassSize_2 0 ClassSize_3 0 intercept 0 TeacherID_1 1 bulg_1 0 bulg_2 0 bulg_3 0> pred["bulg_1",]=c(2,2,2,2,2,2,2,2,2,2,1,0,0,2,-2,0,0,0) > imp=mice(try,meth=c("","","","","","","","","","","","","","","","2l.norm","2l.norm","2l.norm"),pred=pred,maxit=3)iter imp variable 1 1 bulg_3Error in factor(x[, type == (-2)], labels = 1:n.class) : invalid labels; length 2 should be 1 or 0> class(formi$bulg_1)[1] "numeric"> class(formi$bulg_2)[1] "numeric"> class(formi$bulg_3)[1] "numeric" The TeacherID_1 is the second level ID. bulg_1, bulg_2, and bulg_3 are continuous variables that need to be imputed. Why the factor() was used for continuous variables? Thank you very much. Best regards, ya [[alternative HTML version deleted]]
hi list, I googled this invalid lables issue. It seems different people doing different analysis encountered this problem. So I guess this is not about the MICE package. However, in general, they have categorical variables, in my case, I double checked, the bulg_1, bulg_2, and bulg_3 are continuous variables that need to be imputed. Why the factor() function was used here: Error in factor(x[, type == (-2)], labels = 1:n.class) Thank you very much. Best regards, ya ·¢¼þÈË£º ya ·¢ËÍʱ¼ä£º 2012-09-19 11:30 ÊÕ¼þÈË£º 32680822 Ö÷Ì⣺ Fw: invalid labels; length 2 should be 1 or 0 Dear list, I am trying to impute the two level data, I have a question about a warning. Could you give me some suggestions please? Thank you very much. Here is my code and output of mice package:> ini <- mice(try, maxit=0) > pred=ini$pred > predFAC1_1 FAC2_1 FAC3_1 FAC4_1 FAC5_1 FAC6_1 FAC7_1 FAC8_1 FAC9_1 FAC10_1 ClassSize_1 ClassSize_2 ClassSize_3 intercept TeacherID_1 bulg_1 bulg_2 FAC1_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC2_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC3_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC4_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC5_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC6_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC7_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC8_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC9_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FAC10_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ClassSize_3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 intercept 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 TeacherID_1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 bulg_1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bulg_2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bulg_3 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 bulg_3 FAC1_1 0 FAC2_1 0 FAC3_1 0 FAC4_1 0 FAC5_1 0 FAC6_1 0 FAC7_1 0 FAC8_1 0 FAC9_1 0 FAC10_1 0 ClassSize_1 0 ClassSize_2 0 ClassSize_3 0 intercept 0 TeacherID_1 1 bulg_1 0 bulg_2 0 bulg_3 0> pred["bulg_1",]=c(2,2,2,2,2,2,2,2,2,2,1,0,0,2,-2,0,0,0) > imp=mice(try,meth=c("","","","","","","","","","","","","","","","2l.norm","2l.norm","2l.norm"),pred=pred,maxit=3)iter imp variable 1 1 bulg_3Error in factor(x[, type == (-2)], labels = 1:n.class) : invalid labels; length 2 should be 1 or 0> class(formi$bulg_1)[1] "numeric"> class(formi$bulg_2)[1] "numeric"> class(formi$bulg_3)[1] "numeric" The TeacherID_1 is the second level ID. bulg_1, bulg_2, and bulg_3 are continuous variables that need to be imputed. Why the factor() was used for continuous variables? Thank you very much. Best regards, ya [[alternative HTML version deleted]]
I had the same problem, but found this note in the MICE package documentation (at http://cran.r-project.org/web/packages/mice/mice.pdf): Added June 25, 2012: The currently implemented algorithm does not handle predictors that are speci?ed as ?xed effects (type=1). When using mice.impute.2l.norm(), the current advice is to specify all predictors as random effects (type=2). Warning: The assumption of heterogeneous variances requires that in every class at least one observation has a response in y. -- View this message in context: http://r.789695.n4.nabble.com/invalid-labels-length-2-should-be-1-or-0-tp4643712p4647974.html Sent from the R help mailing list archive at Nabble.com.