Graphics Reference
In-Depth Information
summary(model)
Call:
lm(formula = heightIn ~ ageYear, data = heightweight)
Residuals:
Min 1 Q Median 3 Q Max
-8.3517 -1.9006 0.1378 1.9071 8.3371
Coefficients:
Estimate Std. Error t value Pr( >| t | )
(Intercept) 37.4356
1.8281
20.48
< 2 e - 16 ***
ageYear
1.7483
0.1329
13.15
< 2 e - 16 ***
---
Signif. codes: 0 ' *** ' 0.001 ' ** ' 0.01 ' * ' 0.05 ' . ' 0.1 ' ' 1
Residual standard error: 2.989 on 234 degrees of freedom
Multiple R - squared: 0.4249 , Adjusted R - squared: 0.4225
F - statistic: 172.9 on 1 and 234 DF, p - value: < 2.2 e - 16
This shows that the r 2 value is 0.4249. We'll create a graph and manually add the text using an-
notate() ( Figure 5-26 ):
# First generate prediction data
pred <- predictvals(model, "ageYear" , "heightIn" )
sp <- ggplot(heightweight, aes(x = ageYear, y = heightIn)) + geom_point() +
geom_line(data = pred)
sp + annotate( "text" , label = "r^2=0.42" , x = 16.5 , y = 52 )
Search WWH ::




Custom Search