For a given model object the function computes a linear function of the parameters and the corresponding standard errors, pvalues and confidence intervals.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  ci.lin( obj,
ctr.mat = NULL,
subset = NULL,
subint = NULL,
diffs = FALSE,
fnam = !diffs,
vcov = FALSE,
alpha = 0.05,
df = Inf,
Exp = FALSE,
sample = FALSE )
ci.exp( ..., Exp = TRUE, pval=FALSE )
Wald( obj, H0=0, ... )
ci.mat( alpha = 0.05, df = Inf )
ci.pred( obj, newdata,
Exp = NULL,
alpha = 0.05,
df = Inf )

obj 
A model object (of class

ctr.mat 
Contrast matrix to be multiplied to the parameter vector, i.e. the desired linear function of the parameters. 
subset 
The subset of the parameters to be used. If given as a
character vector, the elements are in turn matched against the
parameter names (using 
subint 

diffs 
If TRUE, all differences between parameters
in the subset are computed. 
fnam 
Should the common part of the parameter names be included
with the annotation of contrasts? Ignored if 
vcov 
Should the covariance matrix of the set of parameters be
returned? If this is set, 
alpha 
Significance level for the confidence intervals. 
df 
Integer. Number of degrees of freedom in the tdistribution used to compute the quantiles used to construct the confidence intervals. 
Exp 
If 
sample 
Logical or numerical. If 
pval 
Logical. Should a column of Pvalues be included with the estimates
and confidence intervals output by 
H0 
Numeric. The null values for the selected/transformed parameters to be tested by a Wald test. Must have the same length as the selected parameter vector. 
... 
Parameters passed on to 
newdata 
Data frame of covariates where prediction is made. 
ci.lin
returns a matrix with number of rows and row names as
ctr.mat
. The columns are Estimate, Std.Err, z, P, 2.5% and
97.5%. If vcov=TRUE
a list with components est
, the
desired functional of the parameters and vcov
, the variance
covariance matrix of this, is returned but not printed. If
Exp==TRUE
the confidence intervals for the parameters are
replaced with three columns: exp(estimate,c.i.).
ci.exp
returns only the exponentiated parameter estimates with
confidence intervals. It is merely a wrapper for ci.lin
,
fishing out the last 3 columns from ci.lin(...,Exp=TRUE)
. If
you just want the estimates and confidence limits, but not
exponentiated, use ci.exp(...,Exp=FALSE)
.
Wald
computes a Wald test for a subset of (possibly linear
combinations of) parameters being equal to the vector of null
values. The selection of the subset of parameters is the same as for
ci.lin
. Using the ctr.mat
argument makes it possible to
do a Wald test for equality of parameters. Wald
returns a named
numerical vector of length 3, with names Chisq
, d.f.
and
P
.
ci.mat
returns a 2 by 3 matrix with rows c(1,0,0)
and
c(0,1,1)*1.96
, devised to postmultiply to a p by 2 matrix with
columns of estimates and standard errors, so as to produce a p by 3 matrix
of estimates and confidence limits. Used internally in ci.lin
and
ci.cum
.
The 1.96 is replaced by the appropriate quantile from the normal or
tdistribution when arguments alpha
and/or df
are given.
ci.pred
returns a 3column matrix with estimates and upper and
lower confidence intervals as columns. This is just a convenience
wrapper for predict.glm(obj,se.fit=TRUE)
which returns a rather
unhandy structure. The prediction with c.i. is made in the link
scale, and by default transformed by the inverse link, since the most
common use for this is for multiplicative Poisson or binomial models
with either log or logit link.
Bendix Carstensen, BendixCarstensen.com & Michael Hills
See also ci.cum
for a function computing
cumulative sums of (functions of) parameter estimates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  # Bogus data:
f < factor( sample( letters[1:5], 200, replace=TRUE ) )
g < factor( sample( letters[1:3], 200, replace=TRUE ) )
x < rnorm( 200 )
y < 7 + as.integer( f ) * 3 + 2 * x + 1.7 * rnorm( 200 )
# Fit a simple model:
mm < lm( y ~ x + f + g )
ci.lin( mm )
ci.lin( mm, subset=3:6, diff=TRUE, fnam=FALSE )
ci.lin( mm, subset=3:6, diff=TRUE, fnam=TRUE )
ci.lin( mm, subset="f", diff=TRUE, fnam="f levels:" )
print( ci.lin( mm, subset="g", diff=TRUE, fnam="gee!:", vcov=TRUE ) )
# Use character defined subset to get ALL contrasts:
ci.lin( mm, subset="f", diff=TRUE )
# A Wald test of whether the gparameters are 0
Wald( mm, subset="g" )
# Wald test of whether the three first fparameters are equal:
( CM < rbind( c(1,1,0,0), c(1,0,1,0)) )
Wald( mm, subset="f", ctr.mat=CM )
# or alternatively
( CM < rbind( c(1,1,0,0), c(0,1,1,0)) )
Wald( mm, subset="f", ctr.mat=CM )

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.