covariatemeans {predictmeans}R Documentation

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=NULL, covariate, as.is=FALSE, covariateV=NULL, 
  data=NULL, level=0.05, Df=NULL, trans=NULL, transOff=0, responsen=NULL, trellis=TRUE, 
  plotord=NULL, mtitle=NULL, ci=TRUE, point=TRUE, 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 (in "quotes") of one the covariate variables in the model.

as.is

A logic value to specify wheather or not using original covariate values' rage for graph, the default is FALSE.

covariateV

A numeric vector when as.is is FALSE, then covariatemeans will produce the result for covariate at value of covariateV.

data

In some cases, you need to provide the data set used in model fitting, especially when you have applied some variable trnasformation 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 ddf here). For the above models, ddf is obtained from the function automatically.

trans

A function object for calculating the back transformed means, e.g. trans=exp.

transOff

When you use trans=exp(x+1), then transOff=1, the default is 0.

responsen

Name (in "quotes") of the back transformed response variable in the model.

trellis

A logical variable. If set to TRUE (default), a trellis 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 variable, and the third one as the panel variable). The defaults are c(1, 2) and c(1, 2, 3) for two and three way interactions.

mtitle

The main title in the graph.

ci

A logical variable to indicate whether to print confidence interval. The default value is TRUE.

point

A logical variable to indicate whether to print raw data points. The default value is TRUE.

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 Means

A table of predicted means.

Author(s)

Dongwen Luo, Siva Ganesh and John Koolaard

Examples

  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")
  covariatemeans(fm, "Variety", covariate="nitro", covariateV=seq(0, 0.6, 0.1))$data

[Package predictmeans version 1.1.0 Index]