Learn R Programming

languageR (version 1.5.0)

make.reg.fnc: Make a simulated data set with regression design

Description

This convenience function creates a regression data set with subjects, items, and three numerical predictors, and optionally an effect of learning or fatigue. This function is called by simulateRegression.fnc, and is not intended for independent use.

Usage

make.reg.fnc(nsubj = 10, nitem = 20, beta = c(400, 2, 6, 4), 
learn = FALSE, learnRate = 10, stdevItem = 40, stdevSubj = 80, 
  stdevError = 50)

Arguments

nsubj

Number of subjects (random effect) required.

nitem

Number of items (random effect) required.

beta

A numeric vector with four beta weights: one for the intercept and one for each of three predictors.

learn

A logical variable, if TRUE, a learning or fatigue effect will be implemented, as specified by learnRate.

learnRate

A number indicating learning (if negative) or fatigue (if positive).

stdevItem

A number specifying the standard deviation of the Item random effect.

stdevSubj

A number specifying the standard deviation of the Subject random effect.

stdevError

A number specifying the standard deviation of the Residual Error.

Value

A data frame with intercept, predictors labelled X, Y and Z, Item, Subject, the simulated random effects for Item and Subject, the residual errors, and the simulated RTs.

See Also

simulateRegression.fnc

Examples

Run this code
# NOT RUN {
  simdat = make.reg.fnc()
  require(lme4)
  require(lmerTest)
  require(optimx)
  simdat.lmer = lmer(RT ~ X + Y + Z + (1|Subject) + (1|Item), 
    control=lmerControl(optimizer="optimx",optCtrl=list(method="nlminb")),
    data = simdat)
  summary(simdat.lmer)

  simdat = make.reg.fnc(learn = TRUE)
  simdat.lmer = lmer(RT ~ X + Y + Z + Trial + (1|Subject) + (1|Item), 
    control=lmerControl(optimizer="optimx",optCtrl=list(method="nlminb")),
    data = simdat)
  summary(simdat.lmer)
# }

Run the code above in your browser using DataLab