Obtaining factor scores from CFA using ordinal data and DWLS estimator

492 views
Skip to first unread message

bega...@yahoo.com

unread,
May 1, 2014, 9:32:41 PM5/1/14
to lav...@googlegroups.com
I have fit a CFA model that uses ordinal predictors and the DWLS estimator. I want to use the parameter estimates from this model to generate factor scores for other data. When I use the predict() function and the newdata argument within that function, the data I am using for "newdata" is one case (i.e., a data frame with one row and the requisite number of columns). However, when I attempt to generate a factor score for this one case, I get the following error:

Error in lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan ERROR: ordered variable(s) has/have only 1 level

Of course there is only going to be 1 level to an ordinal variable when there is only 1 case. What am I doing wrong? Is there a solution to this problem?

Thanks,
Brandon

yrosseel

unread,
May 2, 2014, 2:04:24 AM5/2/14
to lav...@googlegroups.com
On 05/02/2014 03:32 AM, begavett via lavaan wrote:
> Error in lav_data_full(data = data, group = group, group.label =
> group.label, :
> lavaan ERROR: ordered variable(s) has/have only 1 level
>
> Of course there is only going to be 1 level to an ordinal variable when
> there is only 1 case. What am I doing wrong? Is there a solution to this
> problem?

Not in this version (0.5-16). You will need to add more (perhaps fake)
data, until the error message goes away. And ignore everything but the
case you need.

The 'newdata' is currently processed (and checked) just as original
data. Hence the error/warning. I will see if we can somehow avoid this
to allow for a single case in predict().

Yves.



bega...@yahoo.com

unread,
May 2, 2014, 10:40:20 AM5/2/14
to lav...@googlegroups.com
Thanks. Will the results differ based on what kind of fake data I enter? If I use just one line of fake data, I appear to be getting different factor scores than if I use multiple lines of fake data.

Brandon

yrosseel

unread,
May 2, 2014, 11:07:58 AM5/2/14
to lav...@googlegroups.com
On 05/02/2014 04:40 PM, begavett via lavaan wrote:
> Thanks. Will the results differ based on what kind of fake data I enter?
> If I use just one line of fake data, I appear to be getting different
> factor scores than if I use multiple lines of fake data.

What I would suggest, is that you make a copy of the original data, and
you add a single line (with the value for which you want to predict the
factor scores). And use this augmented data as the argument of newdata=

Yves.

bega...@yahoo.com

unread,
May 2, 2014, 8:27:52 PM5/2/14
to lav...@googlegroups.com
Thanks. I thought of that, but the original data file is over 4000 lines long. The size of the data file leads to lengthy computation times, which I'd like to avoid.

Brandon

bega...@yahoo.com

unread,
May 3, 2014, 9:38:10 AM5/3/14
to lav...@googlegroups.com
I'm also finding that the factor scores produced by lavaan for this model are quite different than those produced by Mplus.

yrosseel

unread,
May 7, 2014, 11:39:30 AM5/7/14
to lav...@googlegroups.com
On 05/03/2014 03:38 PM, begavett via lavaan wrote:
> I'm also finding that the factor scores produced by lavaan for this
> model are quite different than those produced by Mplus.

What about everything else (chi-square test, degrees of freedom,
parameter estimates)? If that is already different, the factor scores
will differ too.

But if everything else is identical, I would like to investigate this.
Could you send me your Mplus input+output files, and the R script + a
snippet of the data?

Yves.

Reply all
Reply to author
Forward
0 new messages