Description Contrasts Regressions ANOVAs Predicted Marginal Means Datasets and Vignette

It is often the case that a factor only makes sense in a subset of a dataset
(i.e. for some observations a factor may simply not be meaningful), or that
with observational datasets there are no observations in some levels of an
interaction term. There are also cases where a random effects grouping
factor is only applicable in a subset the data, and it is desireable to model
the noise introduced by the repeated measures on the group members within the
subset of the data where the repeated measures exist. The `nauf`

package
allows unordered factors and random effects grouping factors to be coded as
`NA`

in the subsets of the data where they are not applicable or
otherwise not contrastive. It is highly recommended that variables be put on
the same scale with `standardize`

prior to using
`nauf`

functions (though this is not required).

A detailed description of how `NA`

values are treated is given in
`nauf_contrasts`

. These contrasts are implemented automatically
through `nauf_model.frame`

, which stores the information required
to make fixed effects and random effects model matrices with `nauf`

contrasts in its `terms`

attribute. For details on the `terms`

attribute, see `nauf.terms`

. For fixed effects and random
effects model matrices, see `nauf_model.matrix`

and
`nauf_glFormula`

.

`nauf`

contrasts have been implemented for fixed effects regressions
that would normally be fit with `lm`

,
`glm`

, and `glm.nb`

; and for mixed
effects regressions that would normally be fit with `lmer`

,
`glmer`

, and `glmer.nb`

. For fixed
effects `nauf`

regressions, see `nauf_glm`

, and for mixed
effects `nauf`

regressions, see `nauf_glmer`

. There is also
support for Bayesian versions of these models as would normally be fit with
`stan_lm`

, `stan_glm`

,
`stan_glm.nb`

, `stan_lmer`

,
`stan_glmer`

, and `stan_glmer.nb`

(see `nauf_stan_glm`

and `nauf_stan_glmer`

for
details).

The `anova`

function can be used with any frequentist (i.e. not Bayesian)
`nauf`

model.
For fixed effects `nauf`

models, the `anova`

function uses the
methods for corresponding non-`nauf`

models (i.e.
`anova.lm`

, `anova.glm`

, or
`anova.negbin`

depending on the regression family). For
mixed effects `nauf`

models, the `anova`

function uses the
`anova.nauf.merMod`

method, which with default arguments is the
same as `anova.merMod`

. The `anova.nauf.merMod`

method also allows Type III tests to be made via likelihood ratio tests,
parametric bootstrapping, and, for linear models, the Satterthwaite and
Kenward-Roger approximations of denominator degrees of freedom (similar to
the `mixed`

function in the `afex`

package).

The `nauf_ref.grid`

function can be used to construct reference
grids for `nauf`

models (constructing a
`ref.grid-class`

object). Predicted marginal means
(often called least-squares means; but in the case of Bayesian regression they
are posterior marginal means) can be calculated with this reference grid
using the `nauf_pmmeans`

function. The function also allows the
user to flexibly specify a subset of the reference grid to use when
calculating the marginal means, so that the effect of a factor can be tested
with regards to the subset of the data where it is contrastive.

For detailed examples of how to use the `nauf`

package, see the
"Using the nauf package" vignette, which makes use of the
`plosives`

and `fricatives`

datasets included in the
package.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.