#Lecture 4 - testing the position of Johnson et al. 2006 ### Import the data datum=read.csv(file.choose()) head(datum) #Make sure that it is imported correctly ### run the model - know what the model is, so I'll just run the ### correct model results=glm(Presence~Medium+High+Elevation,data=datum,family=binomial) summary(results) ### use coefficients from results to generate a predicted ### probability of use (will be proportional to true probability of use) testing=exp(0.2771073-1.5640112*datum$Medium-1.3587885*datum$High -0.0046661*datum$Elevation) head(testing) ### make sure it worked plot(testing,datum$Proportion) #Plot relationship between estimated ### probability of use and true probability of use ### Run regression between true probability of use and estimated ### probability of use results=lm(datum$Proportion~testing) summary(results) ### estimate of slope is "proportionality constant" that converts ### estimated probability of use to true probability of use ### Note that you will never be able to calculate what this ### proportionality constant is ### this exercise just demonstrates that the estimated probability ### of use is indeed proportional to the true probability of use.