runehaubo / lmerTestR

Repository for the R-package lmerTest
48 stars 9 forks source link

Can the lmertest package run in Julia? #48

Open liamblything1 opened 2 years ago

liamblything1 commented 2 years ago

Hello, Question 1: Can lmer test provide an automation of the required syntax commands for ALL possible combinations of random effect structures?

I'm running the step function of lmerTest, which feeds out the backward elimination of non-significant effects. The command syntax looks like this: step_elimination_object <- step(model_name) step_elimination_object # Display elimination results

As you will know, the step function* displays elimination information. For example, if my initial model is this...

      model_name = lmer(Response ~ IV1 * IV2 * IV3  +
      ( IV1 * IV2 *IV3 + 1 | RandomFactor1) + 
      ( IV1 * IV2   + 1 | RandomFactor2), data= Simdata , REML= FALSE, lmerControl(optimizer ="bobyqa"))

...then in my case, lmertest appears to tell me that it considered eliminating (i) the most complex slope term on RandomFactor1: IV1 : IV2 : IV3 in ( IV1 IV2 IV3 + 1 | RandomFactor1) +

      (ii) the most complex slope term on RandomFactor2:
      IV1 : IV2  in ( IV1 * IV2   + 1 | RandomFactor2)

..and it finally tells me the syntax of the 'model found' (in my case, no terms were eliminated)

My question is whether I would be able to retrieve the syntax formula from when ALL terms and DIFFERENT COMBINATIONS of terms were considered for elimination. For example, if lmertest considers elimination of IV1 as a slope to RandomFactor1, there must be some stored syntax for that model tested for elimination. This could either be in the form of what the model looks like without IV1 as a slope to Random Factor 1:

    Response ~ IV1 * IV2 * IV3  +
    (IV2 *IV3 + 1 | RandomFactor1) + 
        ( IV1 * IV2   + 1 | RandomFactor2), data= Simdata , REML= FALSE,
    lmerControl(optimizer ="bobyqa"))

OR it could be in the form of how the general output was written for the most complex terms: IV1 in ( IV1 IV2 IV3 + 1 | RandomFactor1)

I also wondered whether the get_model fucntion would return the syntax for all the possible models that could have been eliminated:

  get_step_elimination_object  <- get_model(step_elimination_object )

However, this just returned the output of the final model. i had a look into this object's global environment hoping it might have what I'm looking for, but could not find anything.

Any advice would be hugely appreciated as I am planning a complex study that will require hundreds of possible random effect combinations to be tested, and do not want to be prone to manual error for it!

Question 2:

I've recently started running lmer via Julia because it affords more complex models to converge more easily than R.

Note that this is still on the R interface but I call Julia and then use the Julia package #j$library("MixedModels")

My Question is, is it possible to use lmerTest for Julia-run mixed effect models? If so, how would I go about it?

Thank you very much

Liam

*alternative step commands used: step_elimination_object2 <- step(model_name,reduce.fixed = FALSE, reduce.random = FALSE)

and

step_elimination_object3 =step(model_name, ddf="Satterthwaite", type=3, alpha.random = 0.1, alpha.fixed = 0.05, reduce.fixed = TRUE, reduce.random = TRUE, lsmeans.calc=TRUE, difflsmeans.calc=TRUE, test.effs=NULL, keep.effs = NULL, method.grad="simple")