Exogenous variable in sem()

1,205 views
Skip to first unread message

natalia gonz

unread,
Jul 22, 2014, 4:59:08 AM7/22/14
to lav...@googlegroups.com
It`s probably rather obvious but I really don`t get it... I`m having no problems fitting my model with only the continous variables but as soon as I try to include ordinal exogenous variables I`m reaching my limit of understanding. For endogenous variables I could use the ordered argument in sem(), but what to do with exogenous variables?

From the tutorial: 
If you have an exogenous ordinal variable, you can use a coding scheme reflecting the order (say, 1,2,3,...) and treat it as any other (numeric) covariate.

 Minimal example: regression comm ~ ug
> str(d[, c("ug", "comm1", "comm2", "comm3")])
'data.frame': 2063 obs. of  4 variables:
 $ ug   : Ord.factor w/ 4 levels "1"<"2"<"3"<"4": 2 2 4 2 1 3 3 3 4 4 ... # prob. misunderstood "coding scheme reflecting the order" as ""create factor"
 $ comm1: int  5 3 5 3 5 5 3 4 2 3 ...
 $ comm2: int  4 3 5 3 5 4 5 2 4 2 ...
 $ comm3: int  5 3 4 4 5 4 5 4 3 2 ...

> try_ordinal <- ' 
+   comm =~ comm1 + comm2 + comm3
+   comm ~ ug
+ '
> library(lavaan)
> try_ordinal_sem <- sem(
+   model = try_ordinal,
+   data = d,
+   estimator = "WLSMV"
+   #   estimator = "mlr", # not possible anymore 
+   #   missing = "fiml", fixed.x = T
+ )
Error in t(Delta[[g]]) %*% lavsamplestats@WLS.V[[g]] : 
  non-conformable arguments
In addition: Warning messages:
1: In lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan WARNING: exogenous variable(s) declared as ordered in data: ug
2: In WLS.obs - WLS.est :
  longer object length is not a multiple of shorter object length
3: In lavsamp...@WLS.obs[[g]] - WLS.est[[g]] :
  longer object length is not a multiple of shorter object length



When I convert the ug-variable to an integer everything runs smoothly, but I cannot just treat an ordinal as metric? But I guess I`ve totally misunderstood the tutorial and this is exactly what its telling me to do (and I could still use the mlr-estimator)?

Any help would be very much appreciated!

Terrence Jorgensen

unread,
Jul 23, 2014, 3:33:22 PM7/23/14
to lav...@googlegroups.com


From the tutorial: 
If you have an exogenous ordinal variable, you can use a coding scheme reflecting the order (say, 1,2,3,...) and treat it as any other (numeric) covariate.

I think the tutorial is just saying that IF you can make the assumption that the effect of ug is the same between levels 1 and 2 as it is between 2 and 3 or between 3 and 4, then you can treat it as numeric / integer and just estimate a single parameter for the effect of ug.  If you don't want to make that assumption, then you can choose a reference group and create 3 dummy variables for the groups to be compared to the reference group, and regress "comm" on all 3 dummy variables (like you would in regular regression).

Terry

natalia gonz

unread,
Jul 25, 2014, 9:17:45 AM7/25/14
to lav...@googlegroups.com
thank you Terry! 


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

natalia gonz

unread,
Jul 28, 2014, 9:23:01 AM7/28/14
to lav...@googlegroups.com
Terry, I hope you won't mind a (quite unrelated) follow up question.

My question concerns missing variables
  • the variable "comm" (comm1+comm2+comm3) was not measured in group 1 at all
  • for the variable "ji" (ji1+ji2) ji2 is missing for group 2
All the other variables were measured the same way in all of the four groups. Is it possible to still run a multi group analysis for the hole model? Somehow telling lavaan to ignore a specific group for a specific part of the analysis (for example ignore group 1 when comm ~ ug), but include all groups for everything else? 

Alex Schoemann

unread,
Jul 28, 2014, 10:51:01 AM7/28/14
to lav...@googlegroups.com
Hi Natalia,

If you have missing variables in some groups with multiple group analysis you might consider creating "phantom indicators" in the groups with missing indicators. We have a paper describing the technique:

Geldhof, G. J., Pornprasertmanit, S., Schoemann, A. M., & Little, T. D. (2013). Orthogonalizing Through Residual Centering Extended Applications and Caveats. Educational and Psychological Measurement73(1), 27-46.

Alex

natalia gonz

unread,
Aug 5, 2014, 8:22:01 AM8/5/14
to lav...@googlegroups.com
Thank you for the hint, much appreciated!


--
Reply all
Reply to author
Forward
0 new messages