[R-sig-ME] Function to create candidate model list

Andy Fugard andyfugard at gmail.com
Wed Jul 14 18:00:44 CEST 2010


There's one here:

    http://www.andyfugard.info/TypeII_Lmer.R

which might give you some clues for how to write what you really want.
 (See examples at end.)  It does a sort of iterated "drop1" - only on
the fixed effects.  It doesn't touch the random effects at all, which
means you'll end up with nonsense if you have a random slope, e.g.,
models of these forms will be compared.

    y ~ 1 + x + (x|id)
    y ~ 1     + (x|id)

Here's example output:

lmer.typeII(r2 ~ (Anger * Gender * btype * situ) + (1|id) + (1|item),
 family = binomial, data = VerbAgg)

                            AIC    BIC Chisq Chi Df Pr(>Chisq)
 Anger                    -9.52  -2.58 11.52      1       0.00
 Gender                   -0.78   6.15  2.78      1       0.10
 btype                   -27.88 -14.01 31.88      2       0.00
 situ                    -15.20  -8.27 17.20      1       0.00
 Anger:Gender              2.00   8.93  0.00      1       0.98
 Anger:btype               2.03  15.90  1.97      2       0.37
 Anger:situ               -0.63   6.30  2.63      1       0.10
 Gender:btype            -14.83  -0.96 18.83      2       0.00
 Gender:situ               1.48   8.42  0.52      1       0.47
 btype:situ                2.75  16.61  1.25      2       0.53
 Anger:Gender:btype        0.87  14.74  3.13      2       0.21
 Anger:Gender:situ        -0.09   6.85  2.09      1       0.15
 Anger:btype:situ          3.32  17.19  0.68      2       0.71
 Gender:btype:situ         3.33  17.20  0.67      2       0.71
 Anger:Gender:btype:situ   3.57  17.44  0.43      2       0.81

For instance the row for Anger is the result of comparing these two models:

 r2 ~ Anger + Gender + btype + situ + (1 | id) + (1 | item)
 r2 ~         Gender + btype + situ + (1 | id) + (1 | item)

(the AIC and BIC columns are differences; Chisq is the log-likelihood
ratio.)

The row for Anger:Gender is the result of comparing:

 r2 ~ Anger + Gender + btype + situ + (1 | id) + (1 | item) +
     Anger:Gender + Anger:btype + Anger:situ + Gender:btype +
     Gender:situ + btype:situ
 r2 ~ Anger + Gender + btype + situ + (1 | id) + (1 | item) +
                  + Anger:btype + Anger:situ + Gender:btype +
     Gender:situ + btype:situ

Cheers,

Andy


On Wed, Jul 14, 2010 at 17:10, Raymond Danner <rdanner at vt.edu> wrote:
>
> Dear R users,
>
> Could anyone recommend a function that creates a list of all possible
> candidate mixed models (type lmer) from specified fixed and random
> variables?  So that you know where I雋 going--I would then like to rank
> these models with AIC and calculate model averages with the AICcmodavg
> package.
>
> Thanks in advance,
> Ray
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




More information about the R-sig-mixed-models mailing list