Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Covariance Structure in JASP Linear Mixed Model

Hello,

I am trying to set the covariance type or structure for the repeated measures in the Linear Mixed Model analysis, but it appears that JASP does not provide this option. Can anyone tell me how JASP selects the covariance type in the model - is there a default structure/type (e.g., compound symmetry, unstructured, etc.)? I tried reverse engineering by comparing the structures from SPSS output, and it appears that it uses Scaled Identity. However, I am not sure if that's correct. If not, what is it? Also, is there a way to change the covariance type used in the model? Thanks!

Chandramouli Krishnan

Comments

  • The default is identity, and I'm guessing it's difficult to change it, because the R library that JASP uses in the backend (lme4) is quite limited in terms of covariance structures.

    What type of covariance structure were you hoping to use?

  • Thanks for confirming, @patc3! I am looking for Autoregressive (AR1), but at times it is common to use compound symmetry because of its simplicity and correlated error terms. So, I was wondering if there are options to set.

  • Within JASP you have a couple of options, one is simpler the other one is more involved (though neither is simple, unfortunately).

    Taking the example of repeated measures and modeling change over time, the first option is to use the R console module and use the nlme package to estimate the mixed-effects model. For example, here is a growth curve model for outcome "outcome" with random slope for predictor "time" (nested within individual "id") and autoregressive level-1 residual structure:

    Here's the code for this example:

    library(nlme)
    lme(
    fixed=outcome ~ time,
    random=~time|id,
    correlation=corAR1(form=~time),
    data=data
    )
    

    If you want compound symmetry, you can replace corAR1() with corCompSymm() in the correlation argument.

    The second option, which is more involved, is to reshape your data from long to wide (which you have to do outside of JASP), and run a structural equation model using the Structural Equation Modeling analysis from the SEM module. You would have to specify the syntax manually using lavaan syntax. You would have to figure out how to specify AR1 or CS residuals using lavaan syntax.

  • Thank you very much @patc3. I was able to run with the first option by slightly modifying your code. However, not sure how to get all the post-hoc contrasts. Please see below for my code and output. Is there a way to modify the RSyntax that is available in the analysis GUI to adjust the correlation type? I don't see any specification for correlation in the RSyntax within the analysis GUI, so I don't know if it is even possible. Thanks!

    > library(nlme)

    lmm <-

    lme(

    fixed = CROOT ~ Condition * Time,

    random = ~ 1 | Subject,

    correlation = corAR1(form = ~ 1 | Subject),

    data = data,

    method = "REML",

    )

    anova(lmm)


    numDF denDF F-value p-value

    (Intercept) 1 176 166.14310 <.0001

    Condition 2 176 9.33606 0.0001

    Time 3 176 5.15833 0.0019

    Condition:Time 6 176 2.79534 0.0127

  • You can do summary(lmm) to look at the output, and if you want all pairwise comparisons between your conditions, you can do:

    library(emmeans)
    emmeans(lmm, pairwise~Condition, adjust="none")
    

    To be able to use emmeans you will have to use the Mixed Models package in the R console window (default is Descriptives I think):

    By the way I'm not sure what corAR1(form = ~ 1 | Subject) does, but you should double check that it does what you want.

  • @patc3 excellent! Thank you very much!

Sign In or Register to comment.