beta_test: Hypothesis testing for coefficients in lm objects.

beta_testR Documentation

Hypothesis testing for coefficients in lm objects.

Description

The beta_test function performs a hypothesis test for each coefficient when the reference value is different to zero.

Usage

beta_test(
  object,
  alternative = c("two.sided", "less", "greater"),
  parm,
  ref.value
)

Arguments

object

A lm object.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

parm

is a vector with the coefficient names.

ref.value

is a numeric vector with the reference values to perform the test Ho: \beta_j = \beta_{j0}.

Value

The beta_test function returns a matrix with the estimated coefficient, standard error, t value and p-value.

Examples

# In simple linear regression
mod1 <- lm(dist ~ speed, data=cars)
coef(mod1)

# to test beta_speed = 3 vs beta_speed < 3
beta_test(object=mod1, parm='speed', ref.value=3, alternative='less')

# In multiple linear regression
mod2 <- lm(mpg ~ hp + wt, data=mtcars)

# to test separately
# beta_hp = -0.05 vs beta_hp < -0.05 and
# beta_wt = -3 vs beta_wt != -3
alternative <- c("less", "two.sided")
ref.value <- c(-0.05, -3)
parm <- c("hp", "wt")
beta_test(mod2, alternative, parm, ref.value)

fhernanb/model documentation built on March 3, 2024, 12:15 p.m.