Question
The `Amsterdamsche Bos' Forestry wishes to estimate the total wood volume of the trees on its domain. To this end, the Forestry has cut a
The `Amsterdamsche Bos' Forestry wishes to estimate the total wood volume of the trees on its domain.
To this end, the Forestry has cut a sample of 59 trees of their most prevalent type `Beech' and `Oak'.
The volume of these trees alongside their height and trunk diameter have been measured. The latter two characteristics can be measured in the eld without sacrificing the tree. The Forestry hypothesizes that these are predictive of the tree's volume. The file treeVolume.txt (https://ideone.com/lvmqqh) (you can save the file as 'treeVolume') from the cut trees is to uncover this relationship, taking into account the tree type.
I want to figure out this question coding in R:
Propose a transformation of (a subset of) the explanatory variables that possibly yields a better model (verify this). (Hint: think of a natural link between the response and explanatory variables.)
I have a code below, but I am not sure if I need to conduct Log() transformation on X or Y variables.
diameter<-treeVolume[,1] diameter height <-treeVolume[,2] height volume<-treeVolume[,3] volume type<-treeVolume[,4] type beechVolume<-treeVolume[treeVolume$type=='beech',] beechVolume oakVolume<-treeVolume[treeVolume$type=='oak',] oakVolume is.data.frame(beechVolume) is.data.frame(oakVolume) summary(beechVolume) # The summary shows mean of diameter for beech as 13.25 and height as 76 newdataBeech = data.frame(type='beech',diameter=13.25,height=76) newdataBeech$type = factor(newdataBeech$type,levels = c('beech'),labels = c('beech')) newdataBeech summary(oakVolume) # The summary shows mean of diameter for beech as 14.64 and height as 75.68 newdataOak = data.frame(type='oak',diameter=14.64,height=75.68) newdataOak$type = factor(newdataOak$type,levels = c('oak'),labels = c('oak')) newdataOak # Encoding categorical data treeVolume$type = factor(treeVolume$type,levels = c('beech', 'oak'),labels = c('beech', 'oak')) str(treeVolume) treeVolume # Training set regressor = lm(formula = volume ~ type + diameter + height,data = treeVolume) # Prediction Intervals predict(regressor, newdataBeech) predict(regressor, newdataOak)
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started