16
$\begingroup$

Sorry if this is a newb question; I'm trying to teach myself statistics for the first time. I think I have the basic procedure down, but I'm struggling to execute it with R.

So, I'm trying to evaluate the significance of regression coefficients in a multiple linear regression of form

$$ \hat y = X \hat \beta$$

I think the t-statistic for testing $H_0: \hat \beta_j = 0, H_a: \hat \beta_j \neq 0$ is given by

$$t_0 = \frac{\hat \beta_j - 0}{\text{se}(\hat \beta_j)} = \frac{\hat \beta_j}{\sqrt{\hat \sigma^2 C_{jj}}} = \frac{\hat \beta_j}{\sqrt{C_{jj} SS_{Res}/(n-p)}}$$ where $C_{jj}$ is the $j^{th}$ diagonal entry in $(X'X)^{-1}$.

So far, so good. I know how to calculate all of these values using matrix operations in R. But in order to reject the null, the book says I need $$|t_0| > t_{\alpha/2,n-p}$$

How can I compute this critical value $t_{\alpha/2,n-p}$ using R? Right now the only way I know how to find these values is by looking in the table in the back of the book. There must be a better way.

$\endgroup$
1
  • $\begingroup$ The qt() function does this. $\endgroup$
    – guest
    Commented Jan 24, 2012 at 6:52

1 Answer 1

30
$\begingroup$

Welcome to the Stats Stackexchange. You can compute the $t_{\alpha/2, n-p}$ critical value in R by doing qt(1-alpha/2, n-p).

In the following example, I ask R to give me the $95\%$ critical value for $df=1, 2, \dots, 10$. The result is a list of the first ten critical values for the t-distribution at the given confidence level:
> qt(.975, 1:10)
[1] 12.706205 4.302653 3.182446 2.776445 2.570582 2.446912 2.364624 2.306004 2.262157 2.228139

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.