beta_test | R Documentation |
The beta_test
function performs a hypothesis test for each coefficient when
the reference value is different to zero.
beta_test(
object,
alternative = c("two.sided", "less", "greater"),
parm,
ref.value
)
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 |
The beta_test
function returns a matrix with the estimated coefficient,
standard error, t value and p-value.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.