Lab4.pdf - Lab4 Kaibo Gong Thursday 2.2.3 6 0 which means...

This preview shows page 1 - 3 out of 5 pages.

Lab4Kaibo GongThursday, February 11, 20162.2.3The OLS line isˆy=ˆβ0+ˆβ1x. Here we have interceptˆβ0= 0, which means it is hard to say if the price islower in 2009 or not.2.2.4Outliers.Non-constant variance.Too few data points forx >40.2.6Split Data into two subsetslibrary(alr4)data(ftcollinstemp)The first way is to compare the columnyearwith 1990 and return the indicator.data_early = ftcollinstemp[ftcollinstemp$year<1990,]data_later = ftcollinstemp[ftcollinstemp$year>=1990,]Alternatively, you could use functionifelse()to create the0-1or text indicators. And try to use functionupdate()on the linear model you created.# Indicator for "early" or "later"period =ifelse(ftcollinstemp$year <=1989,"early","late")# Original modelm1 =lm(winter~fall,data=ftcollinstemp)summary(m1)#### Call:## lm(formula = winter ~ fall, data = ftcollinstemp)#### Residuals:##Min1QMedian3QMax## -7.8186 -1.7837 -0.08732.13007.5896##1
## Coefficients:##Estimate Std. Error t value Pr(>|t|)## (Intercept)13.78437.55491.8250.0708 .## fall0.31320.15282.0490.0428 *## ---## Signif. codes:0***0.001**0.01*0.05.0.11#### Residual standard error: 3.179 on 109 degrees of freedom## Multiple R-squared:

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture