estimable {gregmisc}R Documentation

Compute and test estimable linear functions of the fitted coefficients (including contrasts) of regression objects

Description

Compute and test estimable linear functions of the fitted coefficients (including contrasts) of regression objects

Usage

estimable(obj, cm, conf.int=NULL)

Arguments

obj Regression (lm,glm,lme) object.
cm matrix specifying estimable linear functions or contrasts (one per row). The number of columns must match the number of fitted coefficients in the model.
conf.int Confidence level. If provided, confidence intervals will be computed.

Details

Computes an estimate, test statitic, significance test, and (optional) confidence interval for each linear functions of the model coefficients specified by the rows of cm. The estimates and their variances are obtained by applying the matrix cm to the model estimates variance-covariance matrix. Degrees of freedom are obtained from the appropriate model terms.

The user is responsible for ensuring that the specified linear functions are meaningful. For computing contrasts among levels of a single factor, contrast.lm may be more convenient.

Value

Returns a matrix with one row per linear function. Columns contain estimated coefficients, standard errors, t values, degrees of freedom, two-sided p-values, and the lower and upper endpoints of the 1-alpha confidence intervals.

Note

The estimated fixed effect parameter of lme objects may have different degrees of freedom. If a specified contrast includes nonzero coefficients for parameters with differing degrees of freedom, the smallest number of degrees of freedom is used and a warning message is issued.

Author(s)

BXC (Bendix Carstensen) bxc@novonordisk.com and Gregory R. Warnes Gregory_R_Warnes@groton.pfizer.com

See Also

contrast.lm, lm, lme, contrasts, contr.treatment, contr.poly

Examples


y <- rnorm(100)
x <-  cut(rnorm(100, mean=y, sd=0.25),c(-4,-1.5,0,1.5,4))
reg <- lm(y ~ x)
summary(reg)

# look at the group means
gm <- sapply(split(y,x),mean)
gm

# contrast mean of 2nd group vs mean of 4th group
estimable(reg, c(    0,   1,    0,   -1) )
# estimate should be equal to:
gm[2] - gm[4]

# confidence intervals etc. for the line for level 4
# for a separate continuous variable modelled as spline
# with a single knot at 0.5:
x2 <- rnorm(100,mean=y,sd=0.5)
reg2 <- lm(y ~ x + x2 + pmax(x2-0.5,0) )

xx2<-seq(-2,2,,50)
tmp <- estimable(reg2,cbind(1,0,0,1,xx2,pmax(xx2-0.5,0)), conf.int=0.95)
plotCI(x=xx2,y=tmp[,1],li=tmp[,6],ui=tmp[,7])

[Package Contents]