LeonieHagitte / ShareSEM

0 stars 0 forks source link

Error in line 274 in MNLFA #7

Closed LeonieHagitte closed 9 months ago

LeonieHagitte commented 10 months ago

Fehler: The following error occurred while evaluating the subexpression 'Configural.matL %% Configural.matP %% t(Configural.matL) + Configural.matE' during the evaluation of 'matC' in model 'Configural' : nicht passende Arrays

brandmaier commented 10 months ago

So, we have 12 observed variables in the measurement model, 4 latent variables, and 2 predictors, that is, matE should be 12x12 but it is 13x13. There seems to be an error when computing the number of manifest variables.

In your code,

manVars <- colnames(df4[,-c(2)])
nv <- length(manVars)

this removes only the second column of the dataset instead of removing the last two columns (which is the number of predictors). So this really should be:

manVars <- colnames(df4[,-c(13:14)])
nv <- length(manVars)
brandmaier commented 10 months ago

This is assuming that the predictors are really the last columns. If they are the first, then it should be -c(1:2), of course.

brandmaier commented 10 months ago

I hope this solves the problem :-)

LeonieHagitte commented 10 months ago

Hm this doesnt solve the problem I think - but I will look into this today further.

brandmaier commented 10 months ago

It worked for me with simulated data. Could you please send me the real df4 data via a secure connection?

LeonieHagitte commented 10 months ago

Of course - what would be a good way? Either way it should be the columns 2 and 3 that get excluded - because column 2 is the column for the mergeid and the third is the year of birth, which i already switched into an extra column( the first) displaying the age

brandmaier commented 10 months ago

maybe send via https://mpibox.mpib-berlin.mpg.de/accounts/login/?next=/ ?

brandmaier commented 10 months ago

I think it's best to not assume certain position of columns but really use their names to find them. I modified the code, such that the manifest names are hard-coded: https://github.com/LeonieHagitte/ShareSEM/commit/6079cae82b471e5a2c903aa475df1d8e23903f60