# picking the best model

This is sort of homework so I'm not really looking for an answer, just pointers.

I have a dataset with 2,871 sample points from an aerial photograph in a GIS. Each random point was scored as being in forest (tree = 1) or not (tree = 0). Using a digital elevation model (DEM) that gave the height to the nearest meter (Elevation.m) one other variable was derived. The other variable was a factor variable describing if the sample point was more or less east facing (E.vs.W. = east) or west facing (E.vs.W. = west).

ex:

E.vs.W,Elevation.m,tree
west,7.896944379,1
west,6.897992018,1
west,-7.314651138,1
west,-10.88583519,1
west,128.6587367,1
west,102.8423517,1
west,205.0537347,1
west,169.6836871,1
west,201.2179048,1
west,210.6947441,1
...


I'm to "explore the variables and their interactions to predict the presence of a tree. Find the best model while showing how it compares to the other models using ΔAIC."

This is what I have:

dat <- read.csv("Data/treeData.csv")
str(dat)

mod1 <- lm(Elevation.m~tree, data=dat)
mod2 <- lm(Elevation.m~E.vs.W, data=dat)
AIC(mod1,mod2)

plot(Elevation.m~E.vs.W, data=dat)


I guess I'm not sure how to pick the "best model". Am I approaching this correctly?

• You need the homework or self study tag. May 1 '18 at 2:04
• There is know certain way to pick a best model unless you were to try every single one of them. Just pick a handful you have talked about in class and compare their error. Look at the independent variable coefficients to get at the "interactions" bit. I would include all variables in different types of models themselves rather than looking at combinations of variables in just one model (such as the linear model you have shown here).
– user136768
May 1 '18 at 2:07

I don't think you are approaching this correctly - shouldn't your outcome variable be the tree variable? After all, you need to predict the presence of a tree, not elevation!

If your outcome variable is tree, then you'll have to account for the fact that it is a binary variable (i.e., a variable which only takes values such as 0 and 1) and use binary logistic regression to model it as a function of elevation and facing. In other words, you should use the glm() function rather than the lm() function.

The models that you can fit will then look like:

mod1 <- glm(tree ~ Elevation,
data = dat)

mod2 <- glm(tree ~ E.vs.W,
data = dat)

mod3 <- glm(tree ~ Elevation + E.vs.W,