dmcglinn / quant_methods

Applied Quantitative Methods course at the College of Charleston
http://dmcglinn.github.io/quant_methods/
Other
18 stars 26 forks source link

Understanding the results for the model for fir trees #41

Closed enriqueza closed 5 years ago

enriqueza commented 5 years ago

Hi all,

I'm having trouble understanding my linear model for fir trees. I ran a few models with just one single x variable and compared those models to see if they were different in terms of r squared values. I then made a linear model with all of the variables in it. What I don't understand is that the significance of the variables change when I added all those other variables. I guess I was wondering if anyone else had gotten significance in their models? (I hope that is ok to ask).

Here is some of my code for my fir tree model (this is without interactions):

all_var_firmod = lm (fir$cover~fir$elev+fir$tci+fir$streamdist+fir$disturb+fir$beers)
summary(all_var_firmod)

I hope this question makes sense...

dmcglinn commented 5 years ago

Hey @enriqueza thanks for posting! Any an all questions on HW are welcomed - this is collaborative effort. The fact that the significance of specific variables change depending on whether you run them individually or jointly is a very important thing to notice - so great job! Essentially what this is telling you is that not all of your explanatory variables are completely independent from each other. If they were then you wouldn't see the significance of those variables change. Did you examine all of the correlations in the dataset using a pairs plot as we did in the lesson? Those plots help to make the correlation structures of the dataset clearer.

strangebb commented 5 years ago

Just a quick question on the pairs function - How would you go about setting up the commands if you wanted to run the function for two different data subsets?

dmcglinn commented 5 years ago

here is an example

# all data 
pairs(iris)
# only those for versicolor
pairs(~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width + Species, subset = Species == "versicolor", data = iris)
# alternatively if you want to use . for all the variables
pairs(~ ., subset = Species == "versicolor", data = iris)
# alternatively you can manually subset
pairs(iris[iris$Species == "versicolor", ])
enriqueza commented 5 years ago

Oh, I hadn't thought of that. I will use it.