sem error

59 views
Skip to first unread message

Vasiliki

unread,
Jun 14, 2019, 10:38:02 AM6/14/19
to lavaan
Hello,

I am new to lavaan and I am having some trouble with my code. I was wondering if I can get some help in this group :)

This is my code:

data1 <- read.csv("data1.csv", header =T)

model1 <- 'cog =~ cog1 + cog2 + cog3; soc =~ soc_1 + soc_2 + soc_3; reg =~ reg1 + reg2 + reg3 + reg4 + reg5 + reg6 + reg7; out =~ out1 + out2 + out3; cog ~ out; soc ~ out; reg ~ out'

SEMmodel <- cfa(model=model1, data=data1,missing = "fiml", estimator = "mlr", se = "robust.huber.white", debug = TRUE)

And this is the error I get:
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 lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: small number of observations (nobs < nvar)
3: 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.
4: In lav_test_yuan_bentler(lavobject = NULL, lavsamplestats = lavsamplestats,  :
  lavaan WARNING: could not invert information matrix
5: In lav_object_post_check(object) :
  lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.
6: In lavaan::lavaan(model = modelideation, data = mrimpact_apq_numeric,  :
  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

thought that if I normalise the data and if I use some dimensionality reduction method it might help with the first two errors, but I am not sure. Also not sure how to address the other 4 warnings.

Any help would be very much appreciated.

With best wishes,
Vasiliki

Jeremy Miles

unread,
Jun 14, 2019, 1:03:19 PM6/14/19
to lav...@googlegroups.com
On Fri, 14 Jun 2019 at 07:38, 'Vasiliki' via lavaan <lav...@googlegroups.com> wrote:
Hello,

I am new to lavaan and I am having some trouble with my code. I was wondering if I can get some help in this group :)

This is my code:

data1 <- read.csv("data1.csv", header =T)

model1 <- 'cog =~ cog1 + cog2 + cog3; soc =~ soc_1 + soc_2 + soc_3; reg =~ reg1 + reg2 + reg3 + reg4 + reg5 + reg6 + reg7; out =~ out1 + out2 + out3; cog ~ out; soc ~ out; reg ~ out'

SEMmodel <- cfa(model=model1, data=data1,missing = "fiml", estimator = "mlr", se = "robust.huber.white", debug = TRUE)

And this is the error I get:
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


Look at your variances (use apply(data1, 2, var) ). Any variables that have really big variances, divide them by a large number to make the variances within about an order of magnitude of each other. 
 
2: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: small number of observations (nobs < nvar)

Your sample is too small. What is your sample size?
 
3: 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.

Probably due to warning 2. 
 
4: In lav_test_yuan_bentler(lavobject = NULL, lavsamplestats = lavsamplestats,  :
  lavaan WARNING: could not invert information matrix

Probably due to warning 2. 
 
5: In lav_object_post_check(object) :
  lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.

Probably due to warning 2, but address the other issues first. 
 
6: In lavaan::lavaan(model = modelideation, data = mrimpact_apq_numeric,  :
  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


May be due to warning 2. 
 
thought that if I normalise the data and if I use some dimensionality reduction method it might help with the first two errors, but I am not sure. Also not sure how to address the other 4 warnings.


Normailizing won't help. Standardizing might. (Depending on exactly what you mean by normalizing). 

Dimensionality reduction might, but that's not something you can just apply without knowing a lot about the data and the theory.
 
Any help would be very much appreciated.


You're welcome,

Jeremy 
Reply all
Reply to author
Forward
0 new messages