Error with a binary response variable

53 views
Skip to first unread message

Magali Frauendorf

unread,
Mar 7, 2018, 3:30:54 AM3/7/18
to lavaan
Hi,

I am trying to run a model in lavaan where I have 3 numerical measured variables (hematocrit, ratio body mass to head length and buffy coat). Those variables are not highly correlated. Thus I want to build the composite (latent) variable "body condition" from those variables that affects the measured variable survival probability (which is a categorical 0/1) variable and nested in location. 

My code looks like this:
M$Surv<-ordered(M$Surv) #ordering the Survival variable
Cmod.1 <- 'Comp <~ 1*Mass_Tohe + avgBC+avgTotCell
Surv ~ Comp' #building composite var and regress the comp to survival, this works

Cmod.1.fit <- sem(Cmod.1, data=M, ordered = "Surv") #using sem function

When using the sem function I get the following error that I don't know how to fix:
Error in start[th.idx] <- th.values[match(th.names.lavpartable, th.names.sample)] : 
  replacement has length zero
In addition: Warning message:
In lav_partable_check(lavpartable, categorical = lavoptions$categorical,  :
  lavaan WARNING: missing intercepts are set to zero: [Comp]

The next step is to use lavaan.survey package in order to use a nested model with the following code:
design<-svydesign(ids=~Loc, nest=T, data=M)
fit.adj<-lavaan.survey(lavaan.fit=fit, survey.design=design)
summary(fit.adj, rsq=T)

I got warning messages. The second one is the same as I already got in the lavaan package. How should I handle those warning messages:
Warning message:
In svydesign.default(ids = ~Loc, nest = T, data = M) :
  No weights or probabilities supplied, assuming equal probability

Warning message:
In lav_partable_check(lavpartable, categorical = lavoptions$categorical,  :
  lavaan WARNING: missing intercepts are set to zero: [Comp]

Thank you!
Best wishes,
Magali

Yves Rosseel

unread,
Mar 12, 2018, 10:05:11 AM3/12/18
to lav...@googlegroups.com, Magali Frauendorf
> Cmod.1.fit <- sem(Cmod.1, data=M, ordered = "Surv") #using sem function
>
> When using the sem function I get the following error that I don't know
> how to fix:
> Error in start[th.idx] <- th.values[match(th.names.lavpartable,
> th.names.sample)] :
>   replacement has length zero

This is due to the conditional.x = TRUE flag, which is the default in
the categorical case. But it does not appear to work in this setting.
The solution is to add the conditional.x = FALSE argument.

> The next step is to use lavaan.survey package

The lavaan.survey package does NOT support categorical outcomes!

Yves.


Reply all
Reply to author
Forward
0 new messages