Unless specified otherwise, homework assignments should be emailed to the instructor as knitted R Markdown documents. Print (or compile) the markdown to a pdf, and provide the .Rmd file as well. Links to older homework solutions are below.

Week 4: (due Monday Feb 20, 2023)

This week, you’re going to do some deep dives into your movement data of choice using the fanstatstic mathemagics of likelihoods. For this assignment, pick just one individual (elephant, wolf, caribou, fisher, buffalo, whatever you can scrape up), ideally with well over 100 locations and more or less regular intervals.

I. Estimate and illustrate the turning angle and step-length distributions.

Use optim() to estimate:

  1. The shape and scale parameters of the Weibull distribution for step-lengths. Provide point estimates and confidence intervals.
  2. The \(\kappa\) parameter in the Wrapped-cauchy distribution for these data. Provide point estimates and confidence intervals.
  3. Visualize the quality of both fits by comparing distribution curves to histograms.

The likelihood for the Weibull distribution and an example for fitting to data is in the book chapter. For the Cauchy distribution, simply follow the template for the Weibull, but replace the dweibull with the dwrpcauchy() function from the CircStats package.

II. Multi-modal step lenghts

We saw in class with the buffalo data that the Weibull distribution was absolutely lousy at capturing the (very typical) bimodality of movement data. There are lots of locations when animals simply don’t move. In this exercise, fit a bimodal Weibull model to your movement data. In this model, there will be 5 parameters \(\alpha_1\) and \(\beta_1\) are the shape and scale, respectively, in one state, \(\alpha_2\) and \(\beta_2\) are the shape and scale in the second state, and \(p\) is the proportion of time spent in the first state.

At first blush this might seem really hard. But this link does exactly this for a bimodal normal distribution. So you will need to apply an exactly analogous approach, just with a slightly different distribution.

III. Test whether there is a relationship …

between turning angles and step lengths in your data. This might seem hard, but, in fact (or - in theory - ) you should be able to directly apply the FunkyModel.Likelihood() function described in the book chapter.

Week 3: (due Monday Feb 13, 2023)

I. Making maps with your spatial data

For this assignment, we recommend using whatever dataset(s) you hope to use for your final project. If you don’t have access to these yet, you can work with a Movebank (or via Dr. G) dataset of your choice.

The assignment is to make a pretty (static) map with your movement data and at least one additional spatial variable of some kind (e.g., raster of environmental data, vector data of roads or barriers or habitat, etc.). You can make this map using any R package you want as long as you can make a “pretty” map with it but we recommend trying one of the packages introduced in class (e.g., ggspatial, basemaps…). Your map should include at minimum, a background map of some kind (could just be a polygon of land, could be a basemap (e.g., an OSM basemap from ggspatial or basemaps), labeled X/Y axes, a legend, and of course, your data (movement data, additional spatial data). If you are feeling fancy/brave, try to add a north arrow and scale bar!

Remember to make sure that all your layers have the same CRS, GCS or PCS, and spatial extent… don’t hesitate to email Nicki for help (barbour@esf.edu). And if you need help finding spatial data for your project, Elie likely has some layers he can send you.

II. Making maps … with birds!

On Monday we watched a very interesting lecture by Marie-Josée Fortin of the University of Toronto on modeling spatial data. The code and data from that lecture are available here: https://github.com/eco4cast/Statistical-Methods-Seminar-Series/tree/main/fortin_spatial-models. I believe the data are ovenbirds (Seiurus aurocapilla), with a nice song and the main question Prof. Fortin was exploring was whether or not their abundance is related to forest cover.

You can download the data directly in R as follows:

library(curl)
## Using libcurl 7.81.0 with OpenSSL/3.0.2
url <-  curl("https://raw.githubusercontent.com/eco4cast/Statistical-Methods-Seminar-Series/main/fortin_spatial-models/bird_forest.csv")
birds <- read.csv(url)
str(birds)
## 'data.frame':    1359 obs. of  5 variables:
##  $ xUTM  : num  1393512 1533512 1283512 1153512 1233512 ...
##  $ yUTM  : num  11908203 11948203 12098203 11758203 12218203 ...
##  $ Forest: int  3 4 5 6 7 14 15 18 30 35 ...
##  $ Bird  : num  0 0 0 0 0.08 ...
##  $ Zones : int  1 1 1 1 1 1 1 1 1 1 ...

Professor Fortin plotted the data in a very straightforward way, something like this:

plot(birds$xUTM, birds$yUTM, cex = sqrt(birds$Bird), asp = 1)

You can just make out the outlines of several Great Lakes in this image. (Did Syracuse make it onto this map?)

The challenge is to come up with a way to present this information on a more informative and attractive way.

Week 2: (due Friday Feb 3, 2023)

Solutions here

I. More manipulation of movement data

Pick a movement data set of your choice with multiple individuals (but no more than 20). Ideally, a dataset that you plan to investigate yourself. Alternatively, work with some subset of the Ya Ha Tinda elk dataset on Movebank, following the instructions in Chapter: Movement Data in R.

  1. Create a table that reports for each individual (i) the number of locations, (ii) the start, end time and duration of the monitoring, (iii) the median, mean and standard deviation of the duty cycle (i.e. the duration between subsequent observations).

  2. Report the following statistics:

    1. The mean, standard deviation, median, range, and interquartile range (25% and 75% quantiles) of the number of locations per individual;
    2. The median, mean, and standard deviation of the location frequency (aka “duty cycle”) over all the individuals.

II. Some Figures

Produce the following plots:

  1. A boxplot of the number of locations per individual
  2. A plot of the overall duration of each individual’s data (like the ones in the chapter).
  3. A plot of the duration for each individual’s data that also illustrates the gaps in the monitoring.

III. Some Movement Statistics

  1. For each location, compute the step-length preceding that location, the time interval of that step, and the movement rate.

  2. Produce a box-plot of the movement rate across all individuals against month of year, i.e. not just “Jan-Feb” and “July-August” like in the example, but for each month.

  3. Can you detect any patterns? Discuss.

  4. Extremely valuable extra credit: Fit some smoother (e.g. a GAM model or a LOESS smoother) to those movement rates across the year.

Week 1: (due Friday Jan 27, 2023)

Solutions here

I. Basic manipulations of movement data

  1. Provide a brief summary of the data - what is it, where did it come from,
  2. Load the data, convert the coordinates to complex numbers, plot the data (with a fixed aspect ratio)
  3. Report some basic stats: how many observations are there; what is the sampling rate (aka duty cycle); what is the total extent in the east-west direction and north-south direction?
  4. Compute the step lengths (\(S\)), report the mean, standard deviation, and draw a histogram,
  5. Compute the absolute orientations of the steps (\(\Phi\)), report the mean (\(\widehat{\mu} = \overline{\Phi}\)), the mean cosine (\(\widehat{\rho} = \overline{\cos(\Phi - \widehat{\mu})}\)), and draw a histogram and rose diagram of the angles.
  6. Perform the steps above for turning angles (\(\Theta\)).
  7. What do you think the statistic \(\widehat{\rho}\) tells you?

II. Simple statistics on spatial data (with some self-learning).

There are several amazing and underappreciated base R functions. For example, outer, which takes TWO vectors and ONE function (that takes two arguments) and applies that functon to every combination of the two vectors. For example, here’s a multiplication table (to 5’s):

a <- 1:5
b <- 1:5
outer(a,b,"*")
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1    2    3    4    5
## [2,]    2    4    6    8   10
## [3,]    3    6    9   12   15
## [4,]    4    8   12   16   20
## [5,]    5   10   15   20   25

Another very useful function is apply, which lets you apply a function across rows or columns of a matrix. So, for example, here’s the sum of the rows of this table:

apply(outer(a,b,"*"), 1, sum)
## [1] 15 30 45 60 75

I emailed you a file, AmericanBeech.csv which contains the coordinates of American beech trees (Fagus grandifola) measured at SUNY-ESF’s Adirondack Research Station in 1985, 2000 and 2009 (data courtesy of M. Dovciak).

  1. Load those data, convert the coordinates to complex numbers, and plot.

  2. Use outer and apply to compute the distance from each tree to it’s nearest neighbor,

  3. Report the mean nearest neighbor distance, the inter-quartile intervals, and plot a histogram. Describe

Note: (b) is a bit tricky, but when you get it, it’s very elegant (in my opinion). Just as a hint, you will need to create a new function that takes two locations, and computes the distance between them. Here’s a template:

getD <- function(Z1, Z1){
  ...
  return(distance)
}

III. Articulate (briefly) …

your goals for this class and - if possible - an idea for a final project.