model-coerce: Conversion between a model object and a restriction matrix

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

Testing a small model under a large model corresponds imposing restrictions on the model matrix of the larger model and these restrictions come in the form of a restriction matrix. These functions converts a model to a restriction matrix and vice versa.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
model2restrictionMatrix(largeModel, smallModel)

## S3 method for class 'merMod'
model2restrictionMatrix(largeModel, smallModel)

## S3 method for class 'lm'
model2restrictionMatrix(largeModel, smallModel)

restrictionMatrix2model(largeModel, LL)

## S3 method for class 'merMod'
restrictionMatrix2model(largeModel, LL)

## S3 method for class 'lm'
restrictionMatrix2model(largeModel, LL)

Arguments

largeModel, smallModel

Model objects of the same "type". Possible types are linear mixed effects models and linear models (including generalized linear models)

LL

A restriction matrix.

Value

model2restrictionMatrix: A restriction matrix. restrictionMatrix2model: A model object.

Note

That these functions are visible is a recent addition; minor changes may occur.

Author(s)

Ulrich Halekoh [email protected], Søren Højsgaard [email protected]

References

Ulrich Halekoh, Søren Højsgaard (2014)., A Kenward-Roger Approximation and Parametric Bootstrap Methods for Tests in Linear Mixed Models - The R Package pbkrtest., Journal of Statistical Software, 58(10), 1-30., http://www.jstatsoft.org/v59/i09/

See Also

PBmodcomp, PBrefdist, KRmodcomp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(pbkrtest)
data("beets", package = "pbkrtest")
sug <- lm(sugpct ~ block + sow + harvest, data=beets)
sug.h <- update(sug, .~. - harvest)
sug.s <- update(sug, .~. - sow)

## Construct restriction matrices from models
L.h <- model2restrictionMatrix(sug, sug.h); L.h
L.s <- model2restrictionMatrix(sug, sug.s); L.s

## Construct submodels from restriction matrices
mod.h <- restrictionMatrix2model(sug, L.h); mod.h
mod.s <- restrictionMatrix2model(sug, L.s); mod.s

## The models have the same fitted values
plot(fitted(mod.h), fitted(sug.h))
plot(fitted(mod.s), fitted(sug.s))
## and the same log likelihood
logLik(mod.h)
logLik(sug.h)
logLik(mod.s)
logLik(sug.s)

hojsgaard/pbkrtest documentation built on May 31, 2018, 9:12 a.m.