ranblock {statmod}R Documentation

Randomized Block Mixed Linear Model

Description

Fits a mixed linear model by REML. The linear model must contain only one random factor apart from the unit errors.

Usage

randomizedBlock(formula, random, weights=NULL, fixed.estimates=TRUE, data=list(), subset=NULL, contrasts=NULL)
randomizedBlockFit(y,X,Z,w=NULL,fixed.estimates=TRUE)

Arguments

The arguments formula, weights, data, subset and contrasts have the same meaning as in lm. The arguments y, X and w have the same meaning as in lm.wfit.

formula formula specifying the fixed model.
random vector or factor specifying the blocks corresponding to random effects.
weights optional vector of prior weights.
fixed.estimates should the fixed effect coefficients be returned?
data an optional data frame containing the variables in the model.
subset an optional vector specifying a subset of observations to be used in the fitting process.
contrasts an optional list. See the contrasts.arg of model.matrix.default.
y response vector.
X design matrix for fixed model.
Z design matrix for random effects.
w optional vector of prior weights.

Details

This function fits the model y=Xb+Zu+e where b is a vector of fixed coefficients and u is a vector of random effects. Write n for the length of y and q for the length of u. The random effect vector u is assumed to be normal, mean zero, with covariance matrix σ^2_uI_q while e is normal, mean zero, with covariance matrix σ^2I_n. If Z is an indicator matrix, then this model corresponds to a randomized block experiment. The model is fitted using an eigenvalue decomposition which transforms the problem into a Gamma generalized linear model.

This function is essentially equivalent to lme(fixed=formula,random=~1|random) but is more accurate and is much faster for small to moderate size data sets.

Missing values in the data are not allowed.

Value

A list with the components. If fixed.estimates=TRUE then the components from "lm.fit" are also returned.

sigmasquared vector of length two containing the residual and block components of variance.
se.sigmasquared standard errors for the components of variance.

Author(s)

Gordon Smyth

See Also

lme, lm, lm.fit

Examples

#  Compare with first data example from Venable and Ripley (2002), Chapter 10, "Linear Models"
library(MASS)
data(petrol)
out <- randomizedBlock(Y~SG+VP+V10+EP, random=No, data=petrol)
cbind(sigmasquared=out$sigmasquared,se=out$se.sigmasquared)

[Package Contents]