Learn R Programming

vows (version 0.4)

semipar.mix.mp: Massively parallel semiparametric mixed models

Description

Fits a set of semiparametric mixed models, with a common design matrix, by repeated calls to gamm4. Only a single smooth term is permitted.

Usage

semipar.mix.mp(Y, x, param = NULL, random, data.ran, k = 10, norder = 4, pen.order = 2, knots = "quantile", store.gamm4 = FALSE)

Arguments

Y
$n \times V$ response matrix.
x
a vector giving the predictor upon which each column of Y is regressed.
param
a matrix or vector for the parametric terms in the model.
random
a formula, passed to gamm4, specifying the random effects structure in lmer style. See the example.
data.ran
a required data frame containing the factors used for random effects.
k
number of knots.
norder
order of B-splines: the default, 4, gives cubic B-splines.
pen.order
order of the derivative penalty.
knots
knot placement for the B-spline bases. The default, "quantile", gives knots at equally spaced quantiles of the data. The alternative, "equispaced", gives equally spaced knots.
store.gamm4
logical: should the gamm4 objects to be stored in the output? FALSE by default.

Value

coef
matrix of the coefficients obtained from gamm4 looping (including both parametric and nonparametric parts).
bsplinecoef
matrix of B-spline coefficients.
pwdf
vector of pointwise effective degrees of freedom.
pwlsp
vector of pointwise log smoothing parameters: grid values maximizing the restricted likelihood at each point.
B
matrix of basis function values.
C
the constraint matrix.
Z
transformation matrix to impose constraints.
basis
B-spline basis object, of the type created by the fda package; the coefficient estimates are with respect to this basis.

Details

Unlike semipar.mp, this function does not use large matrix multiplications to avoid looping through model fits. Instead it performs a separate call to gamm4 to fit a semiparametric mixed model for each column of Y.

Examples

Run this code
Y = matrix(rnorm(3000),,3)
x1 = rnorm(1000)
x2 = matrix(rnorm(2000),,2)
family.fac <- factor(rep(1:20,rep(50,20)))
person.fac <- factor(rep(rep(1:25,rep(2,25)),rep(20,50)))
semimix = semipar.mix.mp(Y = Y, x = x1, param = x2, random = ~ (1|a/b),
          data.ran = data.frame(a = family.fac, b = person.fac))

Run the code above in your browser using DataLab