mixed: Obtain p-values for a mixed-model from lmer().

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Fits and calculates p-values for all effects in a mixed model fitted with lmer. The default behavior (currently the only behavior implemented) calculates type 3 like p-values using the Kenward-Rogers approximation for degrees-of-freedom implemented in KRmodcomp. print, summary, and anova methods for the returned object of class "mixed" are available (all return the same data.frame).

Usage

1
2
  mixed(fixed, random, dv, data, type = 3, method = c("KR",
    "PB"), ...)

Arguments

fixed

character vector specifying the fixed part of the model.

random

character vector specifying the random part of the model (in the current implementation this random part is fit with all models).

dv

character vector specifying the dependent variable

data

data.frame containing the data. Should have all the variables present in fixed, random, and dv as columns.

type

type of sums of squares on which effects are based. Currently only type 3 (3 or "III") is implemented.

method

character vector indicating which methods for obtaining p-values should be used. Currently only "KR" is implemented corresponding to the Kenward-Rogers approximation for degrees-of-freedom.

...

further arguments passed to lmer.

Details

Type 3 sums of squares are obtained by fitting a model in which only the corresponding effect is missing.

See Judd, Westfall, and Kenny (2012) for examples of how to specify the random effects structure for factorial experiments.

Value

An object of class "mixed" (i.e., a list) with the following elements:

  1. anova.table a data.frame containing the statistics returned from KRmodcomp.

  2. full.model the "mer" object returned from fitting the full mixed model.

  3. restricted.models a list of "mer" objects from fitting the restricted models (i.e., each model lacks the corresponding effect)

  4. tests a list of objects returned by the function for obtaining the p-values (objects are of class "KRmodcomp" when method = "KR").

  5. type The type argument used when calling this function.

  6. method The method argument used when calling this function.

The following methods exist for objects of class "mixed": print, summary, and anova (all return the same data.frame).

Note

This functions may take some time especially with complex random structures.

Author(s)

Henrik Singmann with contributions from Ben Bolker and Joshua Wiley.

References

Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: A new and comprehensive solution to a pervasive but largely ignored problem. Journal of Personality and Social Psychology, 103(1), 54–69. doi:10.1037/a0028347

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# example data from package languageR:
# Lexical decision latencies elicited from 21 subjects for 79 English concrete nouns, with variables linked to subject or word.
data(lexdec, package = "languageR")

# using the simplest model
m1 <- mixed("Correct + Trial + PrevType * meanWeight + Frequency + NativeLanguage * Length",  "(1|Subject) + (1|Word)", "RT", data = lexdec)

anova(m1)
# gives:
##                   Effect df1     df2      Fstat p.value
## 1            (Intercept)   1   96.64 13573.0985   0.000
## 2                Correct   1 1627.73     8.1452   0.004
## 3                  Trial   1 1592.43     7.5738   0.006
## 4               PrevType   1 1605.39     0.1700   0.680
## 5             meanWeight   1   75.39    14.8545   0.000
## 6              Frequency   1   76.08    56.5348   0.000
## 7         NativeLanguage   1   27.12     0.6953   0.412
## 8                 Length   1   75.83     8.6959   0.004
## 9    PrevType:meanWeight   1 1601.18     6.1823   0.013
## 10 NativeLanguage:Length   1 1555.49    14.2445   0.000

## End(Not run)

afe documentation built on May 2, 2019, 4:48 p.m.