In pf(D, df, aw) : NaNs produced In pf(D, df, aw) : NaNs produced
I suspect that these warnings have something to do with the fact that I do not get any standard errors and p-values for my coefficient estimates , but I do not really understand what exactly the warning means. Can I change something in order to get the full output of sem (including st. errors and p-values).
Here is the code and some of the output I get.
##running the model
>fitcorrelationsimp<-runMI(correlations, data=mice.imp,fun="sem", estimator="WLSMV", meanstructure=TRUE) Warning messages: 1: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate 2: In muthen1984(Data = X[[g]], ov.names = ov.names[[g]], ov.types = ov.types, : lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix 3: In pf(D, df, aw) : NaNs produced 4: In pf(D, df, aw) : NaNs produced > summary(fitcorrelationsimp, standardized=TRUE) lavaan 0.6-2.1268 did not run (perhaps do.fit = FALSE)?
** WARNING ** Estimates below are simply the starting values Optimization method NLMINB Number of free parameters 0 Number of observations 93 Estimator DWLS Robust Model Fit Test Statistic NaN NaN Degrees of freedom 0 0
...
2) My second question regards a mediation analysis I want to do with the same imputed datasets. Again I specified my model and fit it but I get a warning that the subscript is out of bounds. I know this means that I am asking R to calculate something that isn't there but I do not know where exactly the problem is. Is it something in my coding that is wrong or is it a more serious problem of not being able to carry out mediation analysis with multiple imputed datasets?
Here is my code for this part:
> path.fullmodel<-' normed_Number~a1*normed_CWI3+b1*normed_Ssort+c1*normed_DigitB+normed_CWI1+normed_Digit.F+Condition normed_Matrix~a2*normed_CWI3+b2*normed_Ssort+c2*normed_DigitB+normed_CWI1+normed_Digit.F+Condition Science~a*normed_CWI3+b*normed_Ssort+c*normed_DigitB+d*normed_Number+e*normed_Matrix normed_Number~~normed_Matrix
indirectCWI3 := a1*d+a2*e indirectSsort := b1*d+b2*e indirectDigitB := c1*d+c2*e
totalCWI3:=a+a1*d+a2*e totalSsort:=b+b1*d+b2*e totalDigitB:=c+c1*d+c2*e ' > fit.path.fullmodelimp<-runMI(path.fullmodel, data=mice.imp,fun="sem", estimator="WLSMV", meanstructure=TRUE) Error in `[<-`(`*tmp*`, rhs, lhs, value = coef[i]) : subscript out of bounds
I would really appreciate any help with these two issues.
Many thanks in advance
Thalia
1) I want to look at the correlations between my variables, using the multiple datasets:
2) I get a warning that the subscript is out of bounds.
Error in `[<-`(`*tmp*`, rhs, lhs, value = coef[i]) : subscript out of bounds
Hi Terrence and thanks for all your help. I managed to make things work using the R 3.4.4, semTools 0.5-0 and lavaan 0.6-2 and make my model run . But, today, once again I get a warning:
Error in getMethod("coef", "lavaan.mi") :no method found for function 'coef' and signature lavaan.mi
> impdata$predictorMatrix
English.teacher English Maths Arts Mod.Languages Social.studies Tech
English.teacher 0 1 1 1 1 1 1
English 0 0 1 1 1 1 1
Maths 1 1 0 1 1 1 1
Arts 1 1 1 0 1 1 1
Mod.Languages 1 1 1 1 0 1 1
Social.studies 1 1 1 1 1 0 1
Tech 1 1 1 1 1 1 0
Am I correct to believe that what the output is saying is that
1. English was not used to predict English.teacher (green)
2. English.teacher was used for predicting English (blue)
Also, is there a way to specify that I want the English.teacher variable to be used as a predictor only for missing data on the English variable, but not for missing data on any of the other variables?
Am I correct to believe that what the output is saying is that
1. English was not used to predict English.teacher (green)
2. English.teacher was used for predicting English (blue)No, it is the other way around. The columns represent the predictors, and the rows represent the outcomes. A cell with 0 means that the variable in the column was used to impute the outcome in that row, and a 1 means it was used to impute. So the green 0 means English.teacher was not used to impute English, but the blue 1 means English was used to impute English.teacher.
Could it be due to the fact that English.teacher is a categorical variable? Can you include categorical variables as predictors for variables to be imputed in mice??
Or is it due to the nature of the relationship between the English.teacher and the variable to be imputed? As I said , the missingness pattern in the English variable is directly influenced by the English.teacher variables, since all the cases who had a specific teacher in the subject of English ('English.teacher') are the ones that have with missing data on the outcome ('English'). So is this the reason that R cannot use the 'English.teacher' to impute data on 'English'?