This function computes one or more contrasts of the estimated regression coefficients in a fit from one of the functions in Design, along with standard errors, confidence limits, t or Z statistics, P-values.
1 2 3 4 5 6 7 8 9 10 11 12
a fit of class
arguments to pass to the computational code. The arguments are listed in the Details section below.
a function to transform the contrast, SE, and lower and upper
confidence limits before printing. For example, specify
These functions mirror
There are some between-package inconsistencies regarding degrees of freedom in some models. See the package vignette for more details.
Fold changes are calculated for each hypothesis. When
"simple", the ratio of the
a group predictions over the
b group predictions are used. When
fcType = "signed", the
ratio is used if it is greater than 1; otherwise the negative inverse
-1/ratio) is returned.
Arguments to the contast functions are:
a: a list containing settings for all predictors that you do not wish to
set to default (adjust-to) values. Usually you will specify two
variables in this list, one set to a constant and one to a sequence of
values, to obtain contrasts for the sequence of values of an
interacting factor. The
gendata function will generate the
necessary combinations and default values for unspecified predictors.
a: another list that generates the same number of observations as
unless one of the two lists generates only one observation. In that
case, the design matrix generated from the shorter list will have its
rows replicated so that the contrasts assess several differences
against the one set of predictor values. This is useful for comparing
multiple treatments with control, for example. If
b is missing, the
design matrix generated from
a is analyzed alone.
covType: a string matching the method for estimating the covariance matrix. The default value produces the typical estimate. See
vcovHC for options.
cnames: vector of character strings naming the contrasts when
cnames is not necessary as
contrast.rms tries to name the contrasts by examining which
predictors are varying consistently in the two lists.
be needed when you contrast "non-comparable" settings, e.g., you
list(treat="drug", age=c(20,30)) with
type="average" to average the individual contrasts (e.g., to
obtain a Type II or III contrast)
weights: a numeric vector, used when
type="average", to obtain weighted contrasts
conf.int: confidence level for confidence intervals for the contrasts
env: environment in which evaluate fit
fcFun: a function to transform the numerator and denominator of fold changes
fcType: a character string: "simple", "log" or "signed"
a list of class
"contrast.Design" containing the elements
cnames, which denote the contrast
estimates, standard errors, Z or t-statistics, variance matrix,
residual degrees of freedom (this is
NULL if the model was not
ols), lower and upper confidence limits, 2-sided P-value, design
matrix, and contrast names (or
Also, an element called
1 2 3 4 5 6 7 8 9
library(nlme) Orthodont2 <- Orthodont Orthodont2$newAge <- Orthodont$age - 11 fm1Orth.lme2 <- lme(distance ~ Sex*newAge, data = Orthodont2, random = ~ newAge | Subject) summary(fm1Orth.lme2) contrast(fm1Orth.lme2, a = list(Sex = levels(Orthodont2$Sex), newAge = 8 - 11), b = list(Sex = levels(Orthodont2$Sex), newAge = 10 - 11))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.