Kamster
Kamster

Reputation: 127

Testing Various Hypothesis Test for Coefficients in R

I know in R it returns for a Multiple Regression it returns hypothesis test for βi=0 but what if you want to test such tests like βi=1. Is there any easy command for this or if not how do you call the coefficents standard error, value of coefficent, degree of freedom of regression so i can use t distribution cdf to calculate p value. I want to do this for a general program to run through multiple data

Upvotes: 1

Views: 2385

Answers (2)

Glen_b
Glen_b

Reputation: 8302

While there's packages that do this, it's so simple to do you could write a little function.

This returns p-values for a regression summary in sl for a two tailed test against equality to the values in b0:

testb0=function(sl,b0) {
  slm=sl$coefficients                               #$
  t0=(slm[,1]-b0)/slm[,2]
  pt(abs(t0),sl$df[2],lower.tail=FALSE)
}

a test of that function:

testb0( summary(lm(dist~speed+I(speed^2),cars)), b0=c(0,1,0) )

which returns the three p-values

(Intercept)       speed  I(speed^2) 
 0.43415754  0.48308979  0.06820122 

Upvotes: 3

StatsStudent
StatsStudent

Reputation: 1604

There are several packages in R that will allow you to test whether coefficients are different from values other than 0. For example, https://www.rforge.net/doc/packages/FSA/hoCoef.html. In this case, you'd use: specify, bo = 1 in the hoCoef function.

Upvotes: 3

Related Questions