Homework_1S11_Sol

# Homework_1S11_Sol - 1(a The R code for tting the linear...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1. (a) The R code for tting the linear model is given below. Note that the training window includes all data except the last row. > # Import r e q u i r e d l i b r a r i e s . > library ( lawstat ) > library ( lmtest ) > # Read t h e assignment 1 data . > data = read . table ( " data . t x t " , header = T ) > # S t o r e t h e r e q u i r e d data in v e c t o r s . Omit t h e l a s t row . > JTSJOL = data\$ JTSJOL [- nrow ( data ) ] > CPIRECNS = data\$ CPIRECNS [- nrow ( data ) ] > GAS = data\$ GAS [- nrow ( data ) ] > # Construct t h e l i n e a r model and o b t a i n a summary . > mod = lm ( CPIRECNS ~ JTSJOL ) > summary ( mod ) Call : lm ( formula = CPIRECNS ~ JTSJOL ) Residuals : Min 1 Q Median 3 Q Max- 1064.8- 584.2- 187.2 6 3 4 . 8 1 2 2 8 . 0 Coefficients : Estimate Std . Error t value Pr ( >| t | ) ( Intercept ) 1 5 7 4 6 . 9 2 1 7 8 . 2 7 . 2 2 9 4 . 7 7 e- 11 *** JTSJOL- 109.7 1 9 . 8- 5.540 1 . 8 0 e- 07 ***--- Signif . codes : ' *** ' 0 . 0 0 1 ' ** ' 0 . 0 1 ' * ' 0 . 0 5 ' . ' 0 . 1 ' ' 1 Residual standard error : 6 7 7 . 5 on 121 degrees of freedom Multiple R- squared : 0 . 2 0 2 3 , Adjusted R- squared : 0 . 1 9 5 7 F- statistic : 3 0 . 6 9 on 1 and 121 DF , p- value : 1 . 7 9 9 e- 07 > > # S c a t t e r p l o t > plot ( JTSJOL , CPIRECNS , main = " S c a t t e r p l o t o f CPIRECNS vs . JTSJOL" , xlab = ←- "JTSJOL" , ylab = "CPIRECNS" ) Conclusions: i. The R-squared value of 0.2023 is very low, suggesting that the model provides a poor t to the data. ii. Let β 1 be the coe cient of the JTSJOL variable in the regression model. A t-test on the hypothesis β 1 = 0 gives a p-value of 1.80e-07 ( < . 05 ), which suggests 1 that JTSJOL is signi cant....
View Full Document

## This note was uploaded on 02/23/2012 for the course STAT 443 taught by Professor Yuliagel during the Spring '09 term at Waterloo.

### Page1 / 6

Homework_1S11_Sol - 1(a The R code for tting the linear...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online