beta.test: Hypothesis testing for coefficients in lm objects.

Description Usage Arguments Value Examples

View source: R/beta.test.R

Description

beta.test function performs a hypothesis test for coefficients when reference value is different to zero.

Usage

1
2
beta.test(model, alternative = c("two.sided", "less", "greater"), param,
  ref.value)

Arguments

model

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.

param

Is a vector with the coefficient names.

ref.value

Is a numeric vector with the reference values to perform the test Ho: βj = βjo.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Linear regression
mod1 <- lm(dist ~ speed, data=cars)
coef(mod1)
#
# to test beta_speed = 3 vs beta_speed < 3
beta.test(model=mod1, param='speed', ref.value=3, alternative='less')
#-------------
# 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)
param <- c("hp", "wt")
beta.test(mod2, alternative, param, ref.value)

fhernanb/model documentation built on Sept. 16, 2017, 11 a.m.