clm: Fitting linear model with equality constraints

View source: R/clm.R

clmR Documentation

Fitting linear model with equality constraints

Description

clm can either be used for estimating the linear model with equality constraints C * beta = d, or for general hypothesis testing in multiple linear regression, where H0: C * beta = d and H1: otherwise

Usage

clm(formula, coef_mat, d, data = NULL, t_test = FALSE, ...)

Arguments

formula

formula passed to lm

coef_mat

the coefficient matrix C as in C * beta = d

d

the constant vector on the right hand side

data

data frame containing variables in the model

t_test

whether use the t test for hypothesis testing, only applicable when the coefficient matrix only has one row

...

additional arguments passed to lm

Value

clm returns a list containing the following components

  • coefficients: estimate of beta under constraints

  • residuals: the residuals

  • fitted_values: the fitted values

  • df_residual: the residual degree of freedom

  • sigma2: estimate of sigma^2, i.e. the variance of residuals

  • F_stat when t_test = FALSE, F-statistic testing H0: C * beta = d

  • t_stat: when t_test = TRUE, t-statistic testing: C * beta = d

  • p_value: p value of the test

  • y: the response

  • x: the model matrix

  • model: the model frame

Examples

df <- read.table("http://www.stat.ucla.edu/~nchristo/statistics_c173_c273/jura.txt", header = TRUE)
df <- df[, c(-1, -2, -3, -4)]
C <- matrix(
  c(
    0, 1, 1, 0, 0, -3, 0,
    0, 0, 0, 1, 0, 1, 1
  ),
  nrow = 2, byrow = TRUE
)
d <- c(2, 3)
clm(Pb ~ ., data = df, coef_mat = C, d = d)

enixam/ymisc documentation built on Nov. 22, 2022, 1:31 a.m.