fitstepwise: Fit lmer model using model selection

Description Usage Arguments Value See Also Examples

Description

Analyzes data using lmer, using model selection to test significance of random slope terms in the model (likelihood ratio tests). Does forward and backward selection, starting with subject slope or item slope first (one-factor design only)

Usage

1
fitstepwise(mcr.data, wsbi, mf, crit = c(0.01, 0.05, seq(0.1, 0.8, 0.1)))

Arguments

mcr.data

A dataframe formatted as described in mkDf. Named thus to interface with the function mcRun.

wsbi

Whether the design is between-items (TRUE) or within-items (FALSE).

mf

List of the models to be tested, in decreasing order of complexity.

crit

alpha level for each likelihood-ratio test of slope variance.

Value

A single row of a dataframe with number of fields depending on crit. Stepwise lmer models output six values for each alpha level (i.e., level of crit. These values are:

The values are given twice, once from each direction (forward or backward). Thus, if there are two values of crit, there will be 2 (direction) x 6 (value) x 2 (levels of crit) = 24 values in each row of the dataframe. To assemble a dataframe of results from a file into a three-dimensional array, see reassembleStepwiseFile.

fm

the model that was selected. 4 means that no model converged. For forward stepping models, 3 = maximal model was selected; 2 = model includes only first slope; 1 = model is random intercept only. For backward stepping models, 1 = maximal model, 2 = model minus one slope, 3 = random intercept model.

t

t-statistic for the treatment effect

chi

chi-square statistic for the likelihood ratio test (1 df)

pt

p-value for the t-statistic (normal distribution)

pchi

p-value for the chi-square statistic

See Also

fitlmer, fitstepwise.bestpath, reassembleStepwiseFile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
nmc <- 10
pmx <- cbind(randParams(genParamRanges(), nmc, 1001), seed=mkSeeds(nmc, 1001))

x8 <- mkDf(nsubj=24, nitem=24, pmx[8,], wsbi=FALSE)

mf.sfirst <- list(min=Resp ~ Cond + (1 | SubjID) + (1 | ItemID),
                 srs=Resp ~ Cond + (1 + Cond | SubjID) + (1 | ItemID),
                 max=Resp ~ Cond + (1 + Cond | SubjID) + (1 + Cond | ItemID))
mf.ifirst <- list(min=Resp ~ Cond + (1 | SubjID) + (1 | ItemID),
                  irs=Resp ~ Cond + (1 | SubjID) + (1 + Cond | ItemID),
                  max=Resp ~ Cond + (1 + Cond | SubjID) + (1 + Cond | ItemID))

# forward, subj first
fitstepwise(x8, wsbi=FALSE, mf=mf.sfirst, crit=.05)

# forward, item first
fitstepwise(x8, wsbi=FALSE, mf=mf.ifirst, crit=.05)

dalejbarr/simgen documentation built on May 14, 2019, 3:32 p.m.