PS 8 Solutions 

 

11.8 

> read "/home/fac/little/public_html/ProbStat0910/MSP.map";
 

 

Warning, the use of _seed is deprecated.  Please consider using one of the alternatives listed on the _seed help page.
1852481 (1)
 

> XList:=[39.0,37.5,22.2,17.5,.64,.45,2.62,2.36,32.0,.77];
 

[39.0, 37.5, 22.2, 17.5, .64, .45, 2.62, 2.36, 32.0, .77] (2)
 

> YList:=[23.0,22.3,9.4,9.7,.15,.28,.75,.51,28.,.39];
 

[23.0, 22.3, 9.4, 9.7, .15, .28, .75, .51, 28., .39] (3)
 

> Xbar:=Mean(XList);
 

15.50400000 (4)
 

> Ybar:=Mean(YList);
 

9.448000000 (5)
 

> Sxx:=add((XList[i]-Xbar)^2,i=1..nops(XList));
 

2360.238840 (6)
 

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

1546.552980 (7)
 

> Syy:=add((YList[i]-Ybar)^2,i=1..nops(YList));
 

1101.168560 (8)
 

> beta[1]:=Sxy/Sxx;
 

.6552527455 (9)
 

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

-.711038570 (10)
 

> with(plots):
 

> PP:=plot([seq([XList[i],YList[i]],i=1..nops(XList))],style=point,symbol=diamond,color=blue):
 

> LP:=plot(beta[0]+beta[1]*x,x=0..40,color=red):
 

> display(PP,LP);
 

Plot_2d
 

Estimate of value for x = 12: 

> beta[0]+beta[1]*12;
 

7.151994376 (11)
 

11.12 

a) 

> XList:=[0.0,4,14,32,52];
 

[0., 4, 14, 32, 52] (12)
 

> YList:=[19.8,16.5,12.8,8.1,7.5];
 

[19.8, 16.5, 12.8, 8.1, 7.5] (13)
 

> Xbar:=Mean(XList);
 

20.40000000 (14)
 

> Ybar:=Mean(YList);
 

12.94000000 (15)
 

> Sxx:=add((XList[i]-Xbar)^2,i=1..nops(XList));
 

1859.200000 (16)
 

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

-425.4800000 (17)
 

> Syy:=add((YList[i]-Ybar)^2,i=1..nops(YList));
 

112.7720000 (18)
 

> beta[1]:=Sxy/Sxx;
 

-.2288511188 (19)
 

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

17.60856282 (20)
 

b) 

> with(plots):
 

> PP:=plot([seq([XList[i],YList[i]],i=1..nops(XList))],style=point,symbol=diamond,color=blue):
 

> LP:=plot(beta[0]+beta[1]*x,x=0..55,color=red):
 

> display(PP,LP);
 

Plot_2d
 

c)  Estimate for x = 20: 

> beta[0]+20*beta[1];
 

13.03154044 (21)
 

11.13 

> XList:=[7.23,8.53,9.82,10.26,8.96,12.27,10.28,4.45,1.78,4.0,3.3,4.3,0.8,0.5];
 

[7.23, 8.53, 9.82, 10.26, 8.96, 12.27, 10.28, 4.45, 1.78, 4.0, 3.3, 4.3, .8, .5] (22)
 

 

> YList:=[190,160,134,129,172,197,167,239,542,372,245,376,454,410];
 

[190, 160, 134, 129, 172, 197, 167, 239, 542, 372, 245, 376, 454, 410] (23)
 

> Xbar:=add(XList[i],i=1..nops(XList))/nops(XList);
 

6.177142857 (24)
 

> Ybar:=add(evalf(YList[i]),i=1..nops(YList))/nops(YList);
 

270.5000000 (25)
 

> Sxx:=add((XList[i]-Xbar)^2,i=1..nops(XList));
 

198.2882856 (26)
 

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

-5830.040000 (27)
 

> Syy:=add((YList[i]-Ybar)^2,i=1..nops(YList));
 

233081.5000 (28)
 

> beta[1]:=Sxy/Sxx;
 

-29.40183775 (29)
 

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

452.1193520 (30)
 

So the line is:   y = x 

b)  The plot of the data points with the regression line: 

> with(plots):
 

> PP:=plot([seq([XList[i],YList[i]],i=1..nops(XList))],style=point,symbol=diamond,color=blue):
 

> LP:=plot(beta[0]+beta[1]*x,x=0..14,color=red):
 

> display(PP,LP);
 

Plot_2d
 

11.24 

We must test the null hypothesis   :    against the alternative   

> SSE:=Syy-beta[1]*Sxy;
 

61667.6098 (31)
 

> S:=sqrt(SSE/(nops(XList)-2));
 

71.68659207 (32)
 

> t:=beta[1]/(S*sqrt(1/Sxx));
 

-5.775439925 (33)
 

> nops(XList)-2;
 

12 (34)
 

The  p-value of the test is < 2(.005)  since     so we reject the  

null hypothesis if .   A more accurate estimate of the p-value is: 

> p:=2*(1-TCDF(12,5.775));
 

0.88112e-4 (35)
 

>
 

11.26 

a) 

> XList:=[29.4,39.2,49.0,58.8,68.6,78.4];
 

[29.4, 39.2, 49.0, 58.8, 68.6, 78.4] (36)
 

> YList:=[4.25,5.25,6.5,7.85,8.75,10.0];
 

[4.25, 5.25, 6.5, 7.85, 8.75, 10.0] (37)
 

> Xbar:=add(XList[i],i=1..nops(XList))/nops(XList);
 

53.90000000 (38)
 

> Ybar:=add(evalf(YList[i]),i=1..nops(YList))/nops(YList);
 

7.100000000 (39)
 

> Sxx:=add((XList[i]-Xbar)^2,i=1..nops(XList));
 

1680.700000 (40)
 

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

198.9400000 (41)
 

> Syy:=add((YList[i]-Ybar)^2,i=1..nops(YList));
 

23.60000000 (42)
 

> beta[1]:=Sxy/Sxx;
 

.1183673469 (43)
 

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

.720000002 (44)
 

b) 

> S:=sqrt((Syy-beta[1]*Sxy)/4);
 

.1140175513 (45)
 

> c11:=1/Sxx;
 

0.5949901827e-3 (46)
 

From table in text,    

> beta[1]-2.776*S*sqrt(c11),beta[1]+2.776*S*sqrt(c11);
 

.1106468354, .1260878584 (47)
 

c) 

> c00:=add(XList[i]^2,i=1..6)/(6*Sxx);
 

1.895238095 (48)
 

> t:=beta[0]/(S*sqrt(c00));
 

4.587001682 (49)
 

> 2*(1 - TCDF(4,t));
 

0.10129727e-1 (50)
 

p = attained sig. level is = is between 2(.01) = .02 and 2(.005) = .01 

since  t_(.01)(4) = 3.747 and t_(.005)(4) = 4.604.  At , 

we would reject the null hypothesis and conclude  . 

 

(11.27 on other sheets) 

11.69 

a) 

> XList:=[-7.,-5.,-3.,-1.,1.,3.,5.,7.];
 

[-7., -5., -3., -1., 1., 3., 5., 7.] (51)
 

> YList:=[18.5,22.6,27.2,31.2,33.0,44.9,49.4,35.0];
 

[18.5, 22.6, 27.2, 31.2, 33.0, 44.9, 49.4, 35.0] (52)
 

> Xbar:=Mean(XList);
 

0. (53)
 

> Ybar:=Mean(YList);
 

32.72500000 (54)
 

> Sxx:=add((XList[i]-Xbar)^2,i=1..nops(XList));
 

168. (55)
 

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

304.4000000 (56)
 

> Syy:=add((YList[i]-Ybar)^2,i=1..nops(YList));
 

769.2550000 (57)
 

> beta[1]:=Sxy/Sxx;
 

1.811904762 (58)
 

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

32.72500000 (59)
 

Using matrix formuation.  The model  Y =  

> with(linalg):
 

> X:=transpose(stackmatrix([seq(1,i=1..nops(XList))],[XList]));
 

array( 1 .. 8, 1 .. 2, [( 7, 1 ) = 1, ( 2, 2 ) = -5., ( 7, 2 ) = 5., ( 2, 1 ) = 1, ( 1, 2 ) = -7., ( 8, 1 ) = 1, ( 1, 1 ) = 1, ( 8, 2 ) = 7., ( 5, 2 ) = 1., ( 4, 1 ) = 1, ( 5, 1 ) = 1, ( 4, 2 ) = -1.,... (60)
 

> M:=multiply(transpose(X),X);
 

array( 1 .. 2, 1 .. 2, [( 2, 2 ) = 168., ( 2, 1 ) = 0., ( 1, 2 ) = 0., ( 1, 1 ) = 8 ] ) (61)
 

> linsolve(M,multiply(transpose(X),YList));
 

array( 1 .. 2, [( 1 ) = 32.72500000, ( 2 ) = 1.811904762 ] ) (62)
 

The model  Y =  

> X2:=transpose(stackmatrix([seq(1,i=1..nops(XList))],[XList],[seq(XList[i]^2,i=1..nops(XList))]));
 

array( 1 .. 8, 1 .. 3, [( 7, 1 ) = 1, ( 8, 3 ) = 49., ( 2, 2 ) = -5., ( 7, 2 ) = 5., ( 7, 3 ) = 25., ( 2, 1 ) = 1, ( 6, 3 ) = 9., ( 1, 2 ) = -7., ( 8, 1 ) = 1, ( 5, 3 ) = 1., ( 1, 1 ) = 1, ( 2, 3 ) = ... (63)
 

> M2:=multiply(transpose(X2),X2);
 

array( 1 .. 3, 1 .. 3, [( 2, 2 ) = 168., ( 2, 1 ) = 0., ( 1, 2 ) = 0., ( 1, 1 ) = 8, ( 2, 3 ) = 0., ( 1, 3 ) = 168., ( 3, 1 ) = 168., ( 3, 3 ) = 6216., ( 3, 2 ) = 0. ] ) (64)
 

> linsolve(M2,multiply(transpose(X2),YList));
 

array( 1 .. 3, [( 1 ) = 35.56249999, ( 2 ) = 1.811904762, ( 3 ) = -.1351190473 ] ) (65)
 

> with(plots):
 

> PP:=plot([seq([XList[i],YList[i]],i=1..nops(XList))],style=point,symbol=diamond,color=blue):
 

> LP:=plot(32.725+1.812*x,x=-7..7,color=red):
 

> `assign`(QP, plot(`+`(35.562, `*`(1.812, `*`(x)), `-`(`*`(.135, `*`(`^`(x, 2))))), x = -7 .. 7, color = black)); -1
 

> display(PP,LP,QP);
 

Plot_2d
 

>
 

In this case , it is more or less clear from the graphs that the point [7,35]  from  

the year 2003 is the ``culprit'' here.  If we excluded that point, the model Y = `+`(beta[0], `*`(beta[1], `*`(x)), epsilon)would fit very well and the quadratic model Y = `+`(beta[0], `*`(beta[1], `*`(x)), `*`(beta[2], `*`(`^`(x, 2))), epsilon)would not be 

much of an improvement.  With that point, neither model is all that good for  `>`(x, 5)(!) 

>