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 > pred FAC1_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]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.