Jaime FradeStat Apps 2: HW4Problem 5.1Problem 5.1.1Scatter plot for data Progeny Vs. ParentComment:From the scatter plot there seems to be positively correlated.CODE: (R-Code)#install.packages("alr3")library(alr3)data(galtonpeas)attributes(galtonpeas)plot(galtonpeas$Parent, galtonpeas$Progeny)Problem 5.1.2Jaime FradeStat Apps 2: HW4Problem 5.1Fitting a weighted regression of Progeny on the ParentCall:lm(formula = Progeny ~ Parent, data = galtonpeas, weights = 1/(SD * SD))Residuals: 1 2 3 4 5 6 7 0.08187 0.09162 -0.16753 -0.04067 -0.08950 0.06071 0.06328 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.79642 0.68112 18.787 7.87e-06 ***Parent 0.20480 0.03815 5.368 0.00302 ** ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.11 on 5 degrees of freedomMultiple R-squared: 0.8521, Adjusted R-squared: 0.8225 F-statistic: 28.81 on 1 and 5 DF, p-value: 0.003021Draw the fitted mean functionJaime FradeStat Apps 2: HW4Problem 5.1Comments: From above we have determined the weighted regression model. CODE: (R-Code)fit1 = lm(Progeny~Parent, galtonpeas,weights=1/(SD*SD))summary(fit1)plot(galtonpeas$Parent, galtonpeas$Progeny)abline(fit1)par(mfrow=c(2,2))plot(fit1)Problem 5.1.3Jaime FradeStat Apps 2: HW4Problem 5.1Testing β1 = 1 versus β1 < 1From the null hypothesis, y – x = β0 + error Using a t-testt = (0.2048 -1) / 0.03815 = -20.84403The p-value is close to zero. The null hypothesis is rejected. Thus, we conclude the β1 is less than one, which will suggest that the offspring are “reverting” toward what may be roughly and perhaps failry described as the average ancestral type.Call:lm(formula = Progenynew ~ +1, data = galtonpeasnew, weights = 1/(galtonpeas$SD * galtonpeas$SD))Residuals: Min 1Q Median 3Q Max -1.2216 -0.7653 -0.1416 0.5982 1.2998 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.3115 0.6467 -2.028 0.0889 .---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.9414 on 6 degrees of freedomRSS1 = 0.061 with DF1 = 5 and from anova of model above, RSS2 = 5.3179, with DF2 = 6Jaime FradeStat Apps 2: HW4Problem 5.1Now, with (RSS2 – RSS1)/(DF2 – DF1) / (RSS2/DF2) = 434.45 > F (1,5) . So reject the null hypothesis aCODE: (R-Code)Progenynew = galtonpeas$Progeny-galtonpeas$Parentgaltonpeasnew = data.frame(cbind(Progenynew , galtonpeas$Parent, galtonpeas$SD))galtonpeas$SDfit2 = lm(Progenynew ~+1, galtonpeasnew
View Full Document