attach(trees)
The following objects are masked from trees (pos = 3):
Girth, Height, Volume
The following objects are masked from trees (pos = 4):
Girth, Height, Volume
The following objects are masked from trees (pos = 5):
Girth, Height, Volume
The following objects are masked from trees (pos = 7):
Girth, Height, Volume
The following objects are masked from trees (pos = 8):
Girth, Height, Volume
The following objects are masked from trees (pos = 9):
Girth, Height, Volume
The following objects are masked from trees (pos = 10):
Girth, Height, Volume
The following objects are masked from trees (pos = 11):
Girth, Height, Volume
The following objects are masked from trees (pos = 12):
Girth, Height, Volume
The following objects are masked from trees (pos = 13):
Girth, Height, Volume
The following objects are masked from trees (pos = 14):
Girth, Height, Volume
The following objects are masked from trees (pos = 15):
Girth, Height, Volume
The following objects are masked from trees (pos = 16):
Girth, Height, Volume
The following objects are masked from trees (pos = 17):
Girth, Height, Volume
names(trees) # list varibles of trees
[1] "Girth" "Height" "Volume"
plot(trees)
summary(trees)
Girth Height Volume
Min. : 8.30 Min. :63 Min. :10.20
1st Qu.:11.05 1st Qu.:72 1st Qu.:19.40
Median :12.90 Median :76 Median :24.20
Mean :13.25 Mean :76 Mean :30.17
3rd Qu.:15.25 3rd Qu.:80 3rd Qu.:37.30
Max. :20.60 Max. :87 Max. :77.00
head(trees)# view first few lines of the dataset
dim(trees)# get data dimensions
[1] 31 3
str(trees)# display an internal structure of an R object
'data.frame': 31 obs. of 3 variables:
$ Girth : num 8.3 8.6 8.8 10.5 10.7 10.8 11 11 11.1 11.2 ...
$ Height: num 70 65 63 72 81 83 66 75 80 75 ...
$ Volume: num 10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 ...
attach(trees)
The following objects are masked from trees (pos = 3):
Girth, Height, Volume
The following objects are masked from trees (pos = 4):
Girth, Height, Volume
The following objects are masked from trees (pos = 5):
Girth, Height, Volume
The following objects are masked from trees (pos = 6):
Girth, Height, Volume
The following objects are masked from trees (pos = 8):
Girth, Height, Volume
The following objects are masked from trees (pos = 9):
Girth, Height, Volume
The following objects are masked from trees (pos = 10):
Girth, Height, Volume
The following objects are masked from trees (pos = 11):
Girth, Height, Volume
The following objects are masked from trees (pos = 12):
Girth, Height, Volume
The following objects are masked from trees (pos = 13):
Girth, Height, Volume
The following objects are masked from trees (pos = 14):
Girth, Height, Volume
The following objects are masked from trees (pos = 15):
Girth, Height, Volume
The following objects are masked from trees (pos = 16):
Girth, Height, Volume
The following objects are masked from trees (pos = 17):
Girth, Height, Volume
The following objects are masked from trees (pos = 18):
Girth, Height, Volume
fm1 <- lm(Girth~Height)
summary(fm1)
Call:
lm(formula = Girth ~ Height)
Residuals:
Min 1Q Median 3Q Max
-4.2386 -1.9205 -0.0714 2.7450 4.5384
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -6.18839 5.96020 -1.038 0.30772
Height 0.25575 0.07816 3.272 0.00276 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.728 on 29 degrees of freedom
Multiple R-squared: 0.2697, Adjusted R-squared: 0.2445
F-statistic: 10.71 on 1 and 29 DF, p-value: 0.002758
plot(Girth~Height)
abline(fm1)
a=40
y=0.25575*a-6.18839
y
[1] 4.04161
b=60
y=0.25575*b-6.18839
y
[1] 9.15661
c=80
y=0.25575*c-6.18839
y
[1] 14.27161
attach(trees)
The following objects are masked from trees (pos = 3):
Girth, Height, Volume
The following objects are masked from trees (pos = 4):
Girth, Height, Volume
The following objects are masked from trees (pos = 5):
Girth, Height, Volume
The following objects are masked from trees (pos = 6):
Girth, Height, Volume
The following objects are masked from trees (pos = 7):
Girth, Height, Volume
The following objects are masked from trees (pos = 9):
Girth, Height, Volume
The following objects are masked from trees (pos = 10):
Girth, Height, Volume
The following objects are masked from trees (pos = 11):
Girth, Height, Volume
The following objects are masked from trees (pos = 12):
Girth, Height, Volume
The following objects are masked from trees (pos = 13):
Girth, Height, Volume
The following objects are masked from trees (pos = 14):
Girth, Height, Volume
The following objects are masked from trees (pos = 15):
Girth, Height, Volume
The following objects are masked from trees (pos = 16):
Girth, Height, Volume
The following objects are masked from trees (pos = 17):
Girth, Height, Volume
The following objects are masked from trees (pos = 18):
Girth, Height, Volume
The following objects are masked from trees (pos = 19):
Girth, Height, Volume
fm2 <- lm(Volume~Height)
summary(fm2)
Call:
lm(formula = Volume ~ Height)
Residuals:
Min 1Q Median 3Q Max
-21.274 -9.894 -2.894 12.068 29.852
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -87.1236 29.2731 -2.976 0.005835 **
Height 1.5433 0.3839 4.021 0.000378 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 13.4 on 29 degrees of freedom
Multiple R-squared: 0.3579, Adjusted R-squared: 0.3358
F-statistic: 16.16 on 1 and 29 DF, p-value: 0.0003784
plot(Volume ~ Height)
abline(fm2)
a=40
y=1.5433*a-87.1236
y
[1] -25.3916
b=60
y=1.5433*b-87.1236
y
[1] 5.4744
c=80
y=1.5433*c-87.1236
y
[1] 36.3404
,