In: Math
By Hand: Subjects were trained to respond to a 12-inch visual stimulus and then were tested on stimuli of different sizes (9, 10, 11, 12, 13, 13, 14, and 15 inches). The response measure was the degree to which the subjects responded on the first test trial. There were n = 14 subjects in each group. The means for the a = 7 groups are as follows:
9 in 10 in 11 in 12 in 13 in 14 in 15 in
1.52 2.64 4.28 3.86 3.86 2.79 3.70
Conduct an analysis of the linear and the quadratic trends (the within-groups mean square was 5.84). Plot the predicted group means and the actual group means. What do you conclude?
lm(formula = y ~ x)
Residuals:
1 2 3 4 5 6 7
-1.0279 -0.1371 1.2736 0.6243 0.3950 -0.9043 -0.2236
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.4843 2.0846 0.232 0.826
x 0.2293 0.1714 1.338 0.238
Residual standard error: 0.9067 on 5 degrees of freedom
Multiple R-squared: 0.2637, Adjusted R-squared: 0.1164
F-statistic: 1.79 on 1 and 5 DF, p-value: 0.2385
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x 1 1.4720 1.47201 1.7904 0.2385
Residuals 5 4.1108 0.82215
lm(formula = y ~ I(x) + I(x^2))
Residuals:
1 2 3 4 5 6 7
-0.20881 -0.13714 0.78214 -0.03095 -0.09643 -0.90429 0.59548
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -22.44905 10.52441 -2.133 0.0999 .
I(x) 4.16071 1.78873 2.326 0.0806 .
I(x^2) -0.16381 0.07434 -2.204 0.0923 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6813 on 4 degrees of freedom
Multiple R-squared: 0.6674, Adjusted R-squared: 0.5011
F-statistic: 4.014 on 2 and 4 DF, p-value: 0.1106
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
I(x) 1 1.4720 1.47201 3.1712 0.14955
I(x^2) 1 2.2540 2.25402 4.8559 0.09228 .
Residuals 4 1.8567 0.46418
From the plots and R-squared and Adjusted R squared (for linear model, Multiple R-squared: 0.2637, Adjusted R-squared: 0.1164 , for quadratic model, Multiple R-squared: 0.6674, Adjusted R-squared: 0.5011) the quadratic model is more appropriate than linear.
R code:
x=9:15
y=c(1.52,2.64,4.28,3.86,3.86,2.79,3.70)
summary(lm(y~x))
anova(lm(y~x))
summary(lm(y~I(x)+I(x^2)))
anova(lm(y~I(x)+I(x^2)))
Y1=0.4843+0.2293*x
Y2=-22.4490+4.1607*x-0.1638*x^2
plot(x,y,lwd=2,type="p",xlab="size(x)", ylab="Response(y)")
lines(x,Y1,lwd=2,type="o",col=2)
lines(x,Y2,lwd=2,type="o",col=3)
text(10.8,2.0,expression(hat(y)[2]==-22.4490+4.1607*x-0.1638*x^2))
text(11.3,2.8,expression(hat(y)[1]==0.4843+0.2293*x))