example – black cherry trees. the data frame trees is made available in r with >data(trees) and...
TRANSCRIPT
![Page 1: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/1.jpg)
Example – Black Cherry TreesExample – Black Cherry Trees
![Page 2: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/2.jpg)
Example – Black Cherry TreesExample – Black Cherry Trees
The data frame trees is made available in R with
>data(trees)
and contains the well-known black cherry trees data. These record the girth in inches, height in feet and volume of timber in cubic feet of each of a sample of 31 felled black cherry trees in Allegheny National Forest, Pennsylvania. Note that girth is the diameter of the tree (in inches) measured at 4 ft 6 in above the ground.
![Page 3: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/3.jpg)
![Page 4: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/4.jpg)
We treat volume as the (continuous) response variable y and seek a reasonablemodel describing its distribution conditional on the explanatory variables girth and height.
This might be a first step to prediction of volume based on further observations ofthe explanatory variables.
Consider the R command
>pairs(trees, main = "trees data")
![Page 5: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/5.jpg)
![Page 6: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/6.jpg)
The relationship between girth and volume is especially noticeable.We therefore consider first a linear model
Yi=a + bxi +εi
where Y is volume and x is girth
![Page 7: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/7.jpg)
The R command for fitting linear models by least squares is lm. We have
> trees.model.1 = lm(Volume~Girth, data=trees)> summary(trees.model.1)
![Page 8: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/8.jpg)
![Page 9: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/9.jpg)
The fitted model is
volume = −36.9 + 5.07 × girth + residual
Now try:
> plot(Volume~Girth, data=trees)> abline(coef(trees.model.1))> plot(resid(trees.model.1)~Girth, data=trees,ylab="residuals from Model 1")
![Page 10: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/10.jpg)
![Page 11: Example – Black Cherry Trees. The data frame trees is made available in R with >data(trees) and contains the well-known black cherry trees data. These](https://reader036.vdocuments.us/reader036/viewer/2022082505/56649da05503460f94a8c282/html5/thumbnails/11.jpg)