inst/tests/enhances-nlme.R

library(nlme)
library(lattice)

# Make up some data
n <- 10
j <- 3
alpha <- rnorm(n)
ID <- rep(1:n, j)
x <- runif(n*j)
y <- rnorm(n*j, mean=x + alpha[ID], sd=0.5)
df <- data.frame(y=y, x=x, ID=factor(ID))

# Fit and plot
fit <- lme(y ~ x, random = ~1|ID, data=df)
visreg(fit, "x")
visreg(fit, "x", type="contrast")
visreg(fit, "x", by="ID")
xyplot(y~x|ID, data=df, pch=19) ## Note: Not the same as the above!  Random effects have been eliminated in visreg
visreg(fit, "x", by="ID", level=1) ## Adds the random effects back in

Try the visreg package in your browser

Any scripts or data that you put into this service are public.

visreg documentation built on July 1, 2020, 10:24 p.m.