Description Usage Arguments Examples
cvar and dvar are designed to be used in regression formulas to create a contextual mean of a cluster-varying variable and a 'centered-within-groups' version.
1 |
x |
variable to be centered or residualized within groups. If x is a factor, cvar and dvar return matrices whose columns are named consistently with the names of coding variables for factors. |
id |
identifies clusters |
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
dd <- data.frame(x= 1:100, id = rep( LETTERS[1:10], each = 10))
dd$a <- factor(sample( c('a','b','c'), 100, replace = T))
dd$y <- dd$x + rep(rnorm(10), each = 10) + rnorm(100) + as.numeric(dd$a)
library(nlme)
fit <- lme( y ~ x + cvar(x,id), dd, random = ~ 1 + dvar(x,id) | id)
anova( fit , type = 'm')
# The output of 'anova' can be used to test whether a contextual variable
# should be included in the model
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.