numObs in Multiple Group Models
Posted on
rlucas
Joined: 11/17/2009
Forums
I'm running a multiple-group model with 17 groups (using raw data). However, the number of observations that is reported is wrong. Instead of reporting the total N across all groups, it reports N X the number of groups. In other words, the full sample size across all groups is 20814, but summary reports numObs as 353838 (which is 20814*17). When I ignore the groups and run the model on the full sample, I get the correct number of observations (20814), but if I run it as 17 groups (with each group being a subset of the 20814), I get 353838 observations.
I am pretty sure that I am not specifying the model incorrectly and inadvertently using the full sample for all groups. The results match my mPlus output, and the descriptive statistics and estimates do vary across groups. Is this a bug or am I missing something about why this should be reported this way (or could I be doing something wrong to cause it to report it this way)?
Here are a couple of
(1) If you have several submodels in your script, and each submodel contains an identical copy of the data set, then consider placing the data set in the parent model. In other words, if you script looks like this:
Replace it with:
(2) You can use the "numObs=" argument to the summary() function to explicitly specify the number of observations. See ?summary. Although we would like more information to determine why there is a mismatch in the computed number of observations.
Log in or register to post comments
In reply to Here are a couple of by mspiegel
Ah, I figured it out. I had
model@data@observed <- data[which(data$agecat==index),]
wouldn't just take care of everything. So the original number of observations was kept for each of the subgroups, even though the data were replaced. So now when I go back and examine the data for each submodel, the correct data are there, but the number of observations is still listed as the same as it was for the template.
So I've figured out how to fix this, but it does lead to one question: If I leave out the mxData statement from my template model, will everything just work using the above statement in the function to add the data, or do I need to explicitly add the number of observations and the type with statements like:
model@data@numObs <- 1345
model@data@type <- "raw"
Thanks for your help!
Log in or register to post comments
In reply to Ah, I figured it out. I had by rlucas
Ah, yes I see what is
numObs
is set in the call to the function mxData. I would recommend replacing:with:
Log in or register to post comments