nauf_glFormula: Create a model frame and fixed and random effects model...

Description Usage Arguments Value See Also Examples

View source: R/nauf_trms_fr_x_z.R

Description

The same as the lme4 modular functions glFormula and lFormula, but implementing nauf_contrasts. nauf_lFormula is used for linear mixed effects regressions (i.e. those that would be fit with nauf_lmer) and nauf_glFormula is used for genarlized linear mixed effects regressions (i.e. those that would be fit with nauf_glmer or nauf_glmer.nb). Both of the functions contain a call to nauf_mkReTrms, which serves the same purpose as the lme4 function mkReTrms, but with nauf_contrasts, and, while mkReTrms is exported by lme4, nauf_mkReTrms is an internal function in the nauf package.

Usage

1
2
3
4
5
6
7
8
9
nauf_glFormula(formula, data = NULL, family = gaussian, subset, weights,
  na.action = na.pass, offset, contrasts = NULL, mustart, etastart,
  control = lme4::glmerControl(), ncs_scale = attr(formula,
  "standardized.scale"), ...)

nauf_lFormula(formula, data = NULL, REML = TRUE, subset, weights,
  na.action = na.pass, offset, contrasts = NULL,
  control = lme4::lmerControl(), ncs_scale = attr(formula,
  "standardized.scale"), ...)

Arguments

formula, data, family, REML, subset, weights, offset, control, mustart, etastart, ...

See glFormula.

na.action, contrasts

Changes from default values are ignored. See nauf_model.frame.

ncs_scale

A positive number to be passed as the scale argument to named_contr_sum for all unordered factors. See nauf_model.frame.

Value

A list with the following elements:

fr

The model frame (with class nauf.frame). See nauf_model.frame.

X

The fixed effects model matrix with nauf_contrasts applied. See nauf_model.matrix.

reTrms

A list containing the random effects model matrix and other information about the random effects structure. The elements of the list have the same structure as that returned by mkReTrms, but incorportating nauf_contrasts.

REML

(nauf_lFormula only): A logical indicating if restricted maximum likelihood was used (copy of argument).

family

(nauf_glFormula only): The regression family (copy of argument).

formula

The formula argument, but with any double vertical bars expanded (e.g. (1 + x || subj) becomes (1 | subj) + (0 + x | subj)).

wmsgs

Warning messages (if any).

See Also

nauf_contrasts for a description of the contrasts applied to unordered factors; nauf_model.frame and nauf_model.matrix for the creation of the fr and X elements of the returned list, respectively; and nauf_lmer, nauf_glmer.nb, and nauf_glmer for fitting mixed effects regressions with gaussian, negative binomial, and all other families, respectively.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
dat <- plosives
dat$spont[dat$dialect == "Valladolid"] <- NA
dat_form <- intdiff ~ voicing * dialect * spont +
  (1 + voicing * spont | speaker) + (1 + dialect | item)
sobj <- standardize(dat_form, dat)
lmod <- nauf_lFormula(sobj$formula, sobj$data)

vless <- droplevels(subset(dat, voicing == "Voiceless"))
vless$fully_voiced <- vless$vdur == 0
vless_form <- fully_voiced ~ dialect * spont +
  (1 + spont | speaker) + (1 + dialect | item)
svless <- standardize(vless_form, vless, family = binomial)
glmod <- nauf_glFormula(svless$formula, svless$data, family = binomial)

CDEager/nauf documentation built on May 6, 2019, 9:24 a.m.