esticon: Contrasts for lm, glm, lme, and geeglm objects

Description Usage Arguments Details Value Author(s) Examples

View source: R/esticon.R

Description

Computes linear functions (i.e. weighted sums) of the estimated regression parameters. Can also test the hypothesis, that such a function is equal to a specific value.

Usage

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'gls'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'geeglm'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'lm'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'glm'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'mer'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'coxph'
esticon(obj, L, beta0, conf.int = TRUE, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'lme'
esticon(obj, L, beta0, conf.int = NULL, level = 0.95,
  joint.test = FALSE, ...)

## S3 method for class 'esticon_class'
coef(object, ...)

## S3 method for class 'esticon_class'
summary(object, ...)

## S3 method for class 'esticon_class'
tidy(x, conf.int = FALSE, conf.level = 0.95,
  ...)

## S3 method for class 'esticon_class'
confint(object, parm, level = 0.95, ...)

Arguments

obj

Regression object (of type lm, glm, lme, geeglm).

L

Matrix (or vector) specifying linear functions of the regresson parameters (one linear function per row). The number of columns must match the number of fitted regression parameters in the model. See 'details' below.

beta0

A vector of numbers

conf.int

TRUE

level

The confidence level

joint.test

Logical value. If TRUE a 'joint' Wald test for the hypothesis L beta = beta0 is made. Default is that the 'row-wise' tests are made, i.e. (L beta)i=beta0i. If joint.test is TRUE, then no confidence inteval etc. is calculated.

...

Additional arguments; currently not used.

object

An esticon_class object.

x

A linear contrast object (as returned by esticon().

conf.level

The desired confidence level.

parm

a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered.

Details

Let the estimated parameters of the model be

β_1, β_2, …, β_p

A linear function of the estimates is of the form

l=λ_1 β_1+λ_2 β_2+ …+λ_p β_p

where λ_1, λ_2, …,λ_p is specified by the user.

The esticon function calculates l, its standard error and by default also a 95 pct confidence interval. It is sometimes of interest to test the hypothesis H_0: l=β_0 for some value β_0 given by the user. A test is provided for the hypothesis H_0: l=0 but other values of β_0 can be specified.

In general, one can specify r such linear functions at one time by speficying L to be an r\times p matrix where each row consists of p numbers λ_1,λ_2,…, λ_p. Default is then that β_0 is a p vector of 0s but other values can be given.

It is possible to test simulatneously that all speficied linear functions are equal to the corresponding values in β_0.

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.

Author(s)

Søren Højsgaard, [email protected]

Examples

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
data(iris)
lm1  <- lm(Sepal.Length ~ Sepal.Width + Species + Sepal.Width : Species, data=iris)
## Note that the setosa parameters are set to zero
coef(lm1)

## Estimate the intercept for versicolor
lambda1 <- c(1, 0, 1, 0, 0, 0)
esticon(lm1, L=lambda1)

## Estimate the difference between versicolor and virgica intercept
## and test if the difference is 1
lambda2 <- c(0, 1, -1, 0, 0, 0)
esticon(lm1, L=lambda2, beta0=1)

## Do both estimates at one time
esticon(lm1, L=rbind(lambda1, lambda2), beta0=c(0, 1))

## Make a combined test for that the difference between versicolor and virgica intercept
## and difference between versicolor and virginica slope is zero:
lambda3 <- c(0, 0, 0, 0, 1, -1)
esticon(lm1, L=rbind(lambda2, lambda3), joint.test=TRUE)

# Example using esticon on coxph objects (thanks to Alessandro A. Leidi).
# Using dataset 'veteran' in the survival package
# from the Veterans' Administration Lung Cancer study

if (require(survival)){
data(veteran)
sapply(veteran, class)
levels(veteran$celltype)
attach(veteran)
veteran.s <- Surv(time, status)
coxmod <- coxph(veteran.s ~ age + celltype + trt, method='breslow')
summary(coxmod)

# compare a subject 50 years old with celltype 1
# to a subject 70 years old with celltype 2
# both subjects on the same treatment
AvB <- c(-20, -1, 0, 0, 0)

# compare a subject 40 years old with celltype 2 on treat=0
# to a subject 35 years old with celltype 3 on treat=1
CvB <- c(5, 1, -1, 0, -1)

est <- esticon(coxmod, L=rbind(AvB, CvB))
est
##exp(est[, c(2, 7, 8)])
}

hojsgaard/doBy documentation built on Oct. 11, 2019, 9:55 a.m.