Closed sebastianmarinc closed 3 years ago
Damn, another reason to completely gut this function and redesign it to use lavaanList()
.
The problem is that it expects the model=
argument to be the name of an object (in your example, mod
). But when you submit it to measurementInvariance()
, the models are defined for you as parameter tables that are passed to cfa()
. Thus, when permuteMeasEq()
looks for the object in fit_config@call
, it does not find the name mod
, but rather a data.frame
resembling what is returned by parTable(fit_config)
. That is why the help-page example did not work (I just updated it to not use the deprecated measurementInvariance()
function). 8ffbf69
For it to work, you just have to fit each of your models by calling cfa()
with the first argument as a named object.
Thanks for this! That makes sense. Also, whenever I try to parallelize (with snow), I get the following error message
Error in get(name, envir = envir) : object 'permuteOnce.mgcfa' not found
yup, that's the other reason (#95) I need to scrap this and start it from the ground up. I just need to find the time... But the idea is to simply generate all the permuted data sets first (rather than generate and analyze at each step). Then I can pass the list of data sets to lavaanList()
, which has the whole parallel situation worked out much better than I could in 2016. This approach has worked out quite well for my revamping of the runMI()
functionality.
But if you are using a unix-like OS (Mac or Linux), then the multicore options work just fine because they are capable of forking, which means each node can share a common workspace.
Just to confirm, this essentially means to randomly order the grouping variable in the data set. Each time I randomly order the grouping variable, that would be the same number of times I'd "permutate" the data?
Yes, the grouping variable is what is permuted. The remainder of the data set remains intact each time a random permutation of the grouping variable is drawn via sample()
.
Awesome! And after I fit the models, how do I extract the fit measures to compare to the original data (i.e., "Make an inference about the observed fit measure by comparing it with the vector of permuted fit measures")?
As a follow up, I'm not sure how to compare the original fit statistics to all of the permuted ones.
The steps of the procedure are described on p. 712 of the source article: https://pure.uva.nl/ws/files/32815315/00060744_201812000_00008.pdf
I'm trying to run the following code:
However, I get the following error in the console: ...
If you have any insight on the problem, please lmk when you can. Thanks!!