Learn R Programming

predictmeans (version 0.97)

covariatemeans: Predicted Means of a Linear Model with Covariate Variable(s)

Description

This function obtains predicted means with graph for a new set of covariate values.

Usage

covariatemeans(model, modelterm, covariate, level=0.05, Df, trans, responsen, 
    plot=TRUE, plotord, mtitle, jitterv=0, newwd=TRUE)

Arguments

model
Model object returned by aov, lm, glm, gls, lme, and lmer.
modelterm
Name (in "quotes") for indicating which factor term's predicted mean to be calculated. The modelterm must be given exactly as it appears in the printed model, e.g. "A" or "A:B".
covariate
Name(s) (in "quotes") of the covariate variable(s) in the model.
level
A significant level for calculating confident interval. The default value is 0.05.
Df
A degree of freedom for calculating CI of predicted means (you can manually specified Df here). For the above models, Df is obtained from the function automatically.
trans
A function object for calculating the back transformed means, e.g. trans=exp.
responsen
Name (in "quotes") of the back transformed response variable in the model.
plot
A logical variable. If set to TRUE (default), plots of predicted means with CI will be drawn.
plotord
A numeric vector specifying the order of plotting for two or three way interaction (e.g. plotord = c(2, 1, 3) will put the second variable in modelterm on the X axis, the first variable as the grouping variab
mtitle
The main title in the graph.
jitterv
A degree of jitter in x and y direction in the graph. The default is zero.
newwd
A logical variable to indicate whether to print graph in a new window. The default value is TRUE.

Value

  • Predicted MeansA table of predicted means.

Examples

Run this code
library(predictmeans)
  data(Oats, package="nlme")
  fm <- lme(yield ~ nitro*Variety, random=~1|Block/Variety, data=Oats)
# library(lme4)
# fm <- lmer(yield ~ nitro*Variety+(1|Block/Variety), data=Oats)
  covariatemeans(fm, "Variety", covariate="nitro")

Run the code above in your browser using DataLab