Skip to content

Problems bootstrapping multigroup SEM

3 messages · Chad Danyluck, John Fox

#
Dear John,

Thank you for your insights. I think you do understand what I've been
trying to do. Because I am doing a multigroup comparison ? specifically,
examining the moderating role of test type on outcome ? I needed two
covariance matrices to pass through the model. I wasn't sure how to do this
other than by listing these covariance matrices together. This list was
called to the SEM and worked when the summary stats were called. As you
point out, however, the covariance matrix did not get passed into bootSem()
because, rather than use the cov function, I simply added the list. On
further reflection, the crux of my problem, or confusion, seems to stem
from not understanding how to deal with the need to pass two covariance
matrices into bootSem(). I could pass
"cov(na.omit(stereotype.MAP.data[,-1],
na.omit(evaluative.MAP.data[,-1])))", but I thought that the two matrices
needed to be kept separate because I am comparing the models produced by
each matrix to one another.

Another problem comes to light as I think through the help documentation:

"In the case of an msem (i.e., multi-group) model, *a list of data sets
(again in the appropriate form), one for each group*; in this case,
bootstrapping is done within each group, treating the groups as strata.
Note that the original observations are required, not just the covariance
matrix of the observed variables in the model. *The default is the data set
stored in the sem object*, which will be present only if the model was fit
to a data set rather than to a covariance or moment matrix, and may not be
in a form suitable for Cov."

In my case, the data passed through the sem object was
"c(nrow(stereotype.MAP.data), nrow(evaluative.MAP.data))". Perhaps this is
not suitable for Cov?

At this point I am spinning my wheels. Any further suggestions would be
appreciated.

Kind regards,

Chad
On Wed, Aug 27, 2014 at 6:59 PM, John Fox <jfox at mcmaster.ca> wrote:

            

  
    
#
Dear Chad,
I'm sorry but I don't follow this: c(nrow(stereotype.MAP.data), nrow(evaluative.MAP.data)) are simply the numbers of observations in the data sets, not the data sets themselves. From what you've said, the data sets are stereotype.MAP.data and evaluative.MAP.data. You can use the data and formula arguments to sem(). You need the explicit formula argument because you're apparently omitting one of the variables in each data set; alternatively, you can directly remove the unused variable from each data set, as you've done above. And you need not filter out the missing data (though it doesn't hurt to do so), since the default na.action is na.omit (as is shown in ?sem).
"data: As a generally preferable alternative to specifying S and N, the user may supply a data frame containing the data to which the model is to be fit. In a multigroup model, the data argument may be a list of data frames or a single data frame; in the later event, the factor given as the group argument is used to split the data into groups."

and

"formula: a one-sided formula, to be applied to data to generate the variables for which covariances or raw moments are computed. The default formula is ~., i.e., all of the variables in the data, including an implied intercept; if a covariance matrix is to be computed, the constant is suppressed. In a multigroup model, alternatively a list one one-sided formulas as be given, to be applied individually to the groups."

The multigroup example given in ?sem for the HS.data uses a single data frame, which is then classified by the factor Gender. In your case, you'd specify a list of two data frames; if the same variables are to be used in each, then you need give only one formula rather than a list of two, though the latter would also work.

Best,
 John
2 days later
#
Thanks again John. I think the problem is now resolved.

I changed the information that I passed through the sem() as follows:

MAP.mg.sem <- sem(MAP.mg.mod, data=list(stereotype=stereotype.MAP.data,
evaluative=evaluative.MAP.data), group="IAT.factor")

Then, from ?bootSem

"The default is the data set stored in the sem object, which will be
present only if the model was fit to a data set rather than to a covariance
or moment matrix, and may not be in a form suitable for Cov."
the Cov into bootSem() and so

booted.sem <- bootSem(MAP.mg.sem, R=100)

And I get the anticipated return.

Interestingly, when I tried to pass the Cov and data into the bootSem()
like this:

booted.sem <- bootSem(MAP.mg.sem, R=100, Cov=cov,
data=list(stereotype=stereotype.MAP.data, evaluative=evaluative.MAP.data))

I had a failure to converge.

Kind regards!

Chad
On Tue, Sep 2, 2014 at 4:03 PM, John Fox <jfox at mcmaster.ca> wrote: