1,291 views

Skip to first unread message

Mar 19, 2019, 11:19:58 AM3/19/19

to lavaan

Hi everyone,

I will be thankful if anyone could diagnose the problem in my code and the reason I'm getting error and how to solve the problem. Many thanks :)

note: many of these variables are highly-correlated (e.g., .8 or above), some variables have outliers and became non-normal; scales of these variables are different, but Rex Kline in his book said not to used z-score standardized data as input to CFA or SEM models, so I just used covariance matrix which is already a form of standardization??

library(lavaan)

data<- read.csv("mydata.csv", header=TRUE) #original data with all 22 variables;

cov.data<- cov(data)

#model with 22 variables, noted as V:

my.model<- 'group2=~ v1 + v2 + v3 +v4 + v5 + v6 + v7

group3=~ v8 + v9 + v10 + v11

group4=~ v12 + v13 + v14 + v15 + v16 + v17 +v18

group5=~ v19 + v20 + v21 + v22'

fit <- sem(my.model,

sample.cov = cov.data,

sample.nobs = 210)

summary(fit, standardized = TRUE)

Results:

Warning messages:

1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :

lavaan WARNING:

Could not compute standard errors! The information matrix could

not be inverted. This may be a symptom that the model is not

identified.

2: In lav_object_post_check(object) :

lavaan WARNING: some estimated ov variances are negative

3: In lavaan::lavaan(model = lex.model, sample.cov = cov.lex, sample.nobs = 210, :

lavaan WARNING: not all elements of the gradient are (near) zero;

the optimizer may not have found a local solution;

use lavInspect(fit, "optim.gradient") to investigate

****************************************************************************************

#change sem() to cfa():

fit1 <- cfa(model= my.model, sample.cov= cov.data, sample.nobs= 210)

results: the exact same warning messages as above

What am I doing wrong??

Mar 21, 2019, 6:56:26 AM3/21/19

to lavaan

some variables have outliers and became non-normal;

Those are 2 separate issues.

scales of these variables are different, but Rex Kline in his book said not to used z-score standardized data as input to CFA or SEM models,

Analyzing z scores without constraining model-implied variances to be 1 will yield biased results.

so I just used covariance matrix which is already a form of standardization??

A covariance matrix is an unstandardized correlation matrix. Use the former.

Warning messages:1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :lavaan WARNING:Could not compute standard errors! The information matrix couldnot be inverted. This may be a symptom that the model is notidentified.2: In lav_object_post_check(object) :lavaan WARNING: some estimated ov variances are negative3: In lavaan::lavaan(model = lex.model, sample.cov = cov.lex, sample.nobs = 210, :lavaan WARNING: not all elements of the gradient are (near) zero;the optimizer may not have found a local solution;use lavInspect(fit, "optim.gradient") to investigate

You have a big model for a smallish sample. Try fitting one factor at a time, to see if the problem occurs for any particular factor. If not, try fitting a 2-factor model, then add another factor until you see the problem occur. Narrow down where the problem is.

#change sem() to cfa():

results: the exact same warning messages as above

sem() and cfa() are the same function, internally, so their results will always be the same.

Terrence D. Jorgensen

Assistant Professor, Methods and Statistics

Research Institute for Child Development and Education, the University of Amsterdam

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu