# Loading required libraries
library(sandwich)
# Reading in a dataset
data(mri)
# Linear regression of LDL on age (with robust SE by default)
testReg <- regress ("mean", ldl~age+stroke, data = mri)
# Testing coefficient created by .5*age - stroke (the first 0 comes from excluding the intercept)
testC <- c(0, 0.5, -1)
lincom(testReg, testC)
# Test multiple combinations:
# whether separately whether .5*age - stroke = 0 or Intercept + 60*age = 125
testC <- matrix(c(0, 0.5, -1, 1, 60, 0), byrow = TRUE, nrow = 2)
lincom(testReg, testC, null.hypoth = c(0, 125))
# Test joint null hypothesis:
# H0: .5*age - stroke = 0 AND Intercept + 60*age = 125
lincom(testReg, testC, null.hypoth = c(0, 125), joint.test = TRUE)
Run the code above in your browser using DataLab