Learn R Programming

Epi (version 1.1.20)

ci.lin: Compute linear functions of parameters with s.e.

Description

For a given model object the function computes a linear function of the parameters and the corresponding standard errors, p-values and confidence intervals.

Usage

ci.lin( obj,
    ctr.mat = NULL,
     subset = NULL,
     subint = NULL,
      diffs = FALSE,
       fnam = !diffs,
       vcov = FALSE,
      alpha = 0.05,
         df = Inf,
        Exp = FALSE )
ci.mat( alpha = 0.05, df=Inf )

Arguments

obj
A model object (of class lm, glm, coxph, survreg, lme,mer,nls,gnlm, MIresult
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 grep) to find the subset. Repeat parameters may result from using a character vector. Thi
subint
Subset selection like for subset, except that elements of a character vector given as argument will be used to select subsets of parameters and only the intersection of these is returned.
diffs
If TRUE, all differences between parameters in the subset are computed. ctr.mat is ignored. If obj inherits from lm, and subset is given as a string subset is used to search amon
fnam
Should the common part of the parameter names be included with the annotation of contrasts? Ignored if diffs==T. If a sting is supplied this will be prefixed to the labels.
vcov
Should the covariance matrix of the set of parameters be returned? If this is set, Exp is ignored.
alpha
Significance level for the confidence intervals.
df
Integer. Number of degrees of freedom in the t-distribution used to compute the quantiles used to construct the confidence intervals.
Exp
If TRUE columns 5:6 are replaced with exp( columns 1,5,6 ).

Value

  • ci.lin returns a matrix with number of rows and rownames 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.mat returns a 2 by 3 matrix with rows c(1,0,0) and c(0,-1,1)*1.96, devised to post-multiply 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 confidnece limits. Used internally in ci.lin and ci.cum. The 1.96 is replaced by the appropriate quantile from the normal or t-distribution when arguments alpha and/or df are given.

See Also

See also ci.cum

Examples

Run this code
# 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 )

Run the code above in your browser using DataLab