Let $Y_i=\beta_0 +\beta_1 x_i+\beta_2 x_i^2+\beta_3 x_i^3+\epsilon^2$

I need to plot the model: $E(Y)=\gamma_0+\gamma_1(x)+\gamma_2(x^2-4)+\gamma_3(x^3-7x)$ (Orthogonal polynomials)

y <- c(8,5,2,0,2,7,7)
x <- c(-3,-2,-1,0,1,2,3)

How can I do this directly in R? I found $\hat\beta=(\hat\gamma_0,\hat\gamma_1,\hat\gamma_2,\hat\gamma_3)^T=(26/7,-9/28,3/4,1/18)^T$ using $\hat\beta=(X^TX)^{-1}X^TY$

I also want to compare this model against $H0:\gamma_3=0$, are these the correct ways of doing it?

Way 1) Interference about $\gamma_3$: It has $\operatorname{var} \gamma_3=\hat\sigma^2(\textrm{4th diagonal element of } (X^TX)^{-1})$

Find t-statisctic with (7-4 df) using $t=\gamma_3/\hat\sigma\sqrt{\textrm{4th diagonal element of } (X^TX)^{-1}}$

Way 2) Fit both models, find the Residual SS for the full model using $Y^TY=\hat\beta^TX^TY$. Similarly do the same for the restricted model $E(Y)=\gamma_0+\gamma_1(x)+\gamma_2(x^2-4)$, but using appropriate $X$ matrix, it will be $7\times 3$ now.

Last step would be to use F-test with $f=\frac{(RSS_r-RSS_F)/1}{RSS_f/(7-4)}$. Compare with $F(1,7-4)$

Way 3) Find the extra SS by Regression SS with $\gamma_3$ - Regression SS without $\gamma_3$. I'm a bit stuck with this way, since I don't know whether I can even do it. Can I find regression SS by $\hat{\dot\beta}^T\dot X^T X \hat{\dot \beta}$ by ommiting the intercept $\gamma_0$? What is the difference between model SS and regression SS? To me it seems like a closely related thing.

SS about mean=RegressionSS+ResidualSS

Total SS=ModelSS+ResidualSS

In my notes: Regression SS$=\hat{\dot\beta}^T\dot X^TY$ and Model SS$=\hat{\beta}^T X^TY$

  • $\begingroup$ Too many question in one, and I think some belong to Stackoverflow (R programming question) and some on Statistics not math... $\endgroup$ – snoram Aug 25 '16 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.