---
title: "Lab 10"
author: "Name here"
output: html_document
---

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.

```{r}
library(knitr)
swiss.birds <- read.csv('http://www.math.montana.edu/ahoegh/teaching/stat491/data/willowtit2013.csv')
kable(head(swiss.birds))
```

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. 
\vfill

#### 2. (5 points) Priors
Describe and justify the necessary priors for this model.
\vfill

#### 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.

```{r, eval = F}
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. 
