extend: Extend a longitudinal model.

Description Usage Arguments Details Value Examples

View source: R/extend.R

Description

This method increases the sample size for a model.

Usage

1
extend(object, along, within, n, values)

Arguments

object

a fitted model object to extend.

along

the name of an explanatory variable. This variable will have its number of levels extended.

within

names of grouping variables, separated by "+" or ",". Each combination of groups will be extended to n rows.

n

number of levels: the levels of the explanatory variable will be replaced by 1,2,3,..,n for a continuous variable or a,b,c,...,n for a factor.

values

alternatively, you can specify a new set of levels for the explanatory variable.

Details

extend takes "slices" through the data for each unique value of the extended variable. An extended dataset is built from n slices, with slices duplicated if necessary.

Value

A copy of object suitable for doSim with an extended dataset attached as an attribute named newData.

Examples

1
2
3
4
5
6
fm <- lmer(y ~ x + (1|g), data=simdata)
nrow(example)
fmx1 <- extend(fm, along="x", n=20)
nrow(getData(fmx1))
fmx2 <- extend(fm, along="x", values=c(1,2,4,8,16))
nrow(getData(fmx2))

simr documentation built on Jan. 29, 2019, 9:04 a.m.