MATH 376 -- Probability and Statistics 2 

 

A hypothesis test on a regression coefficient  

 

April 15, 2010 

 

> with(Statistics): with(plots):
 

 

Using the median housing price data from class a few days ago.  

We enter the lists of x  and  y  coordinates of the data points separately. 

 

> XList:=[0.,1,2,3,4,5,6,7];
 

[0., 1, 2, 3, 4, 5, 6, 7] (1)
 

> YList:=[27.6,32.5,35.9,39.3,44.8,48.8,55.7,62.9];
 

[27.6, 32.5, 35.9, 39.3, 44.8, 48.8, 55.7, 62.9] (2)
 


Means:
 

> Xbar:=Mean(XList);
 

3.500000000 (3)
 

> Ybar:=Mean(YList);
 

43.43750000 (4)
 

 

Organizing the computation of the least squares estimators of the regression coefficients
as we described in class:
 

 

> SXY:=add((XList[i]-Xbar)*(YList[i]-Ybar),i=1..8);
 

203.6500000 (5)
 

> SXX:=add((XList[i]-Xbar)*(XList[i]-Xbar),i=1..8);
 

42.00000000 (6)
 

> hatbeta[1]:=SXY/SXX;
 

4.848809524 (7)
 

> hatbeta[0]:=Ybar-hatbeta[1]*Xbar;
 

26.46666667 (8)
 

 

We can ask whether there is evidence to say that the median house price was 

increasing at a rate less than 5 thousand dollars per year.


That is, we set up for testing
 

 

    H[0] : beta[1] = 5    (or perhaps ≥ 5 -- essentially equivalent)   versus the alternative 

    H[a] :  `<`(beta[1], 5) 

To compute the test statistic we need the estimator `*`(`^`(S, 2))  for the variance `*`(`^`(sigma, 2)) 

 

> SYY:=add((YList[i]-Ybar)*(YList[i]-YBar),i=1..8);
 

1004.158750 (9)
 

> S2:=(1/(8-2))*(SYY-hatbeta[1]*SXY);
 

2.7831151 (10)
 


Then the test statistic is  t = `/`(`*`(`+`(hatbeta[1], `-`(5))), `*`(S, `*`(sqrt(c[11])))),  where c[11] = `/`(1, `*`(S[xx]))
 

> t:=(hatbeta[1] - 5)/sqrt(S2/SXX);
 

-.5873317731 (11)
 

 

The test statistic has a  t-distribution with 8 - 2 = 6 d.f.  so the 

p-value for the lower tail test is: 

 

> `assign`(T, RandomVariable(StudentT(6))); 1
 

_R1 (12)
 

> CDF(T,t);
 

.289198656033010648 (13)
 

 

Note:  1 - CDF(T,-t)  gives the same result by symmetry of the t  

density function. 

 

 

This value is much too large to indicate rejection of H[0] .  There is  

not sufficient evidence to suggest that  `<`(beta[1], 5.)