Please use D2L to turn in both the PDF or Word output and your R Markdown file in.

We will revisit the Swiss birds dataset for this lab to construct a logistic regression model for presence of the Willow Tit.

library(knitr)
swiss.birds <- read.csv('http://www.math.montana.edu/ahoegh/teaching/stat491/data/willowtit2013.csv')
kable(head(swiss.birds))
siteID elev rlength forest birds searchDuration
Q001 450 6.4 3 0 160
Q002 450 5.5 21 0 190
Q003 1050 4.3 32 1 150
Q004 950 4.5 9 0 180
Q005 1150 5.4 35 0 200
Q006 550 3.6 2 0 115

This dataset contains 242 sites and 6 variables:

- siteID, a unique identifier for the site, some were not sampled during this period 
- elev, mean elevation of the quadrant in meters 
- rlength, the length of the route walked by the birdwatcher, in kilometers 
- forest, percent forest cover 
- birds, binary variable for whether a bird is observed, 1 = yes 
- searchDuration, time birdwatcher spent searching the site, in minutes

1. (5 points) Model Specification

Clearly write out the model, using proper notation for the variables in bird dataset. You don’t need use all variables, but you should state which are included.

2. (5 points) Priors

Describe and justify the necessary priors for this model.

3. (5 points) Fit MCMC

Fit the JAGS code for this model. You will have to put this together following the specification in the previous examples, but the following statement can be used for the sampling model portion.

model {
  for (i in 1:Ntotal) {
    y[i] ~ dbern(mu[i])
    mu[i] <- ilogit(beta0 + sum( beta[1:Nx] * x[i,1:Nx] ))
  }
  # priors inserted here
  
}

4. (5 points) Summarize inferences from model

Talk about the model and discuss which and how predictor variables influence the observation of a bird.