lincon: Linear combinations of regression model parameters.

View source: R/lincon.R

linconR Documentation

Linear combinations of regression model parameters.

Description

This is a function allows one to obtain standard inferences (i.e., point estimates, standard errors, confidence intervals, etc.) concerning any linear combination of regression model parameters.

Usage

## S3 method for class 'lm'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## S3 method for class 'nls'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## S3 method for class 'glm'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## S3 method for class 'lmerMod'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## S3 method for class 'glmerMod'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## S3 method for class 'gls'
lincon(model, a, b, df, tf, cnames, level = 0.95, fcov = vcov, ...)
## Default S3 method:
lincon(model, a, b, df = Inf, tf, cnames, level = 0.95, fcov = vcov, fest = coef, ...)

Arguments

model

Model object.

...

Not used.

a

Vector or matrix defining the a_j coefficients of the linear combination(s). If omitted then this defaults to the identity matrix to provide inferences for each parameter similar to the summary function.

b

A scalar or vector defining the b coefficient(s) of the linear combination. Assumed to be zero if missing.

df

Optional degrees of freedom. If left missing the residual degrees of freedom will be used except for GLMs with family = poisson or family = binomial in which case an infinite degrees of freedom is used. Defaults to infinity for Wald tests/intervals when using the default method.

tf

Optional transformation function to apply to the point estimate(s) and confidence interval limits (e.g., tf = exp for a logistic model to estimate odds or odds ratios).

cnames

Optional vector of contrast names. If left missing the contrast coefficients are shown. If FALSE then no names are shown.

level

Confidence level in (0,1). Default is 0.95.

fcov

Function for estimating the covariance matrix of the model parameters.

fest

Function for extracting the model parameter estimates (must be same as order of the covariance matrix).

Details

For a regression model with a linear component (e.g., linear and generalized linear models) with parameters \beta_0, \beta_1, \dots, \beta_p a linear combination is defined as

a_0\beta_0 + a_1\beta_1 + \cdots + a_p\beta_p + b.

For a nonlinear regression model with parameters \theta_1, \theta_2, \dots, \theta_q a linear combination is defined as

a_1\theta_1 + a_2\theta_2 + \cdots + a_q\theta_q + b.

Inferences for the linear combination are based on either exact (normal theory) or Wald (asymptotic) test statistics and confidence intervals. The estimated standard error(s) of the linear combinations are computed using any specified function for estimating the variance-covariance matrix of the model parameters.

Examples

myreg <- lm(Gas ~ Insul + Temp + Insul:Temp, data = MASS::whiteside)
# same as summary(myreg)
lincon(myreg)
# slope with respect to temperature after insulation
lincon(myreg, a = c(0,0,1,1))
# expected gas consumption before and after insulation at 5 degrees celsius
lincon(myreg, a = matrix(c(1,0,5,0,1,1,5,5), 2, 4, byrow = TRUE), cnames = c("Before","After"))
# change in expected gas consumption at five degrees celsius from adding insulation
lincon(myreg, a = c(0,1,0,5))


trobinj/trtools documentation built on Jan. 3, 2025, 4:14 a.m.