Resources from last time

Objectives

For class today

Here are the questions from last time:

  1. Modifying the code here, select four species to analyze for the time trend and the mapped changes in distribution. Referring back to the discussion, show evidence that agrees or not with interpretations in papers we discussed last time. Consider the catch distribution you see from these data, including its distribution in time and space, effort, and catch per effort. We will discuss these results in class as basis for a new set of experiments to sharpen our evidence for effects discussed previous papers.

  2. From NOAA’s list of endangered species, under Species category search for Fish and sharks. Which of the species here might you find for sale in a market here and why?

For today, in groups, compare notes on the analysis from last time, including its relevance for your readings. Then report back to the class. Specifically, show evidence that these data agree or not with interpretations in papers we discussed last time. Consider the catch distribution in time and space, effort, and catch per effort. We will discuss these results in class as basis for a new set of experiments to sharpen our evidence for effects discussed previous papers.

In advance of next class, place a summary of findings on Sakai dropbox, which can include graphics and interpretations.

  1. Modifying the code here, select four species to analyze for the time trend and the mapped changes in distribution. Referring back to the discussion, show evidence that agrees or not with interpretations in papers we discussed last time. Consider the catch distribution you see from these data, including its distribution in time and space, effort, and catch per effort. We will discuss these results in class as basis for a new set of experiments to sharpen our evidence for effects discussed previous papers.

  2. From NOAA’s list of endangered species, under Species category search for Fish and sharks. Which of the species here might you find for sale in a market here and why?

For next time

We will look at the exercises for factors and interactions in the data using the code below.

The longline data

We have available to us the long-line data used in the Tuna and swordfish catch paper that was included in the discussion. Here is software we will need:

library(gjam)
library(colorspace)
library(maps)
library(RColorBrewer)
source('clarkFunctions2022.r')

Here are the catch and predictor variables aggregated to a 1 degree grid:

load('longlineGrid.rdata', verbose = T)
## Loading objects:
##   xdata
##   ydata
##   edata

Here’s a map of the aggregated lon/lat data for catch per effort, where effort is the variable HOOKS_BETW, indicating the number of hooks on the line:

CPE    <- ydata/edata$HOOKS_BETW                                 # catch per effort
shade  <- sqrt(.01 + rowMeans( CPE, na.rm=T ) )                  # color shading
shade[ !is.finite(shade) ] <- .001                               # low value for missing
shade <- .getColor("black", shade/max(shade))

mapLonLat <- apply(xdata[,c('lon','lat')],2,range)               # map setup
map( xlim=mapLonLat[,1], ylim=mapLonLat[,2], fill=T, col='wheat')
points( xdata[,'lon'], xdata[,'lat'], col = shade, pch=15, cex=.2)
*Catch effort as shaded blocks*.

Catch effort as shaded blocks.

A movie of change over time could go like this:

ncols     <- 100                                    # length of color palette
cols      <- RColorBrewer::brewer.pal(5, 'YlOrRd')  # the palette of colors
colorGrad <- colorRampPalette( cols )               # function to generate ramp
colors    <- colorGrad(ncols)                       # the color ramp
cscale    <- seq(0, 1, length.out = ncols)            # color scale

years <- sort( unique(xdata$yr) )
spec  <- 'Swordfish'                       # I could select a different species
most  <- max(ydata[,spec], na.rm=T)        # maximum catch

par(bty='n', mar=c(.5, .5, 1, .5))

for(j in 1:length(years)){
  
  wj <- which(xdata$yr == years[j])
  yj <- (ydata[wj,spec]/most)^.2            # fraction of most, highlight low values
  
  col <- colors[ findInterval(yj, cscale) ] # relative abundance determines color
  z   <- rep(.2, length(wj))
  
  symbols(xdata[wj,'lon'], xdata[wj,'lat'], squares=z, inches=F, fg = col, 
          bg = col, add=F, xlim=mapLonLat[,1], ylim=mapLonLat[,2])
  map(xlim=mapLonLat[,1], ylim=mapLonLat[,2], fill=T, col='wheat', add=T)
  title(years[j])
  readline(prompt="Press [enter] to continue")
}

Season effects

I am concerned that the analysis from the previous vignette, because I know that temperature is increasing over time, as is fishing effort. However, I also know that temperature is changing throughout the year. Perhaps fish are being affected by simply shifting where they live at different times of year, seeking and finding a preferred temperature at different times of year. I think I might identify such an effect by including an interaction between SST and season. I want to use season, rather than month, because a small number of seasons (four) may better capture the effect than a large number of months(12).

Here is a model to estimate parameters. Note that I include an interaction between SST and yr to determine if the SST effect might be changing over time:

edata$HOOKS_BETW[ edata$HOOKS_BETW == 0 ] <- 1


for( k in 1:ncol(ydata) ){
  xdata$y <- ydata[k]/edata$HOOKS_BETW
  tmp <- summary( lm( y ~ SST*yr + season, data = xdata ) )$coefficients
  if( k == 1 ){
    betaMu <- matrix( signif(tmp[,1], 3), 1 )
    colnames( betaMu ) <- rownames( tmp )
    betaSe <- matrix( signif(tmp[,2], 3), 1 )
    colnames( betaSe ) <- rownames( tmp )
  } else{
    betaMu <- rbind( betaMu, signif(tmp[,1], 3) )
    betaSe <- rbind( betaSe, signif(tmp[,2], 3) )
  }
}
rownames(betaMu) <- rownames(betaSe) <- colnames(ydata)

This is slow to run, so the next block loads output from this run. Here are the interactions involving SST

load( 'gjamLongLine.rdata' )

orderPlot( vnames = c('SST','yr','SST:yr'), out )
*Interactions involving SST show the tendency for high-salinity species to be increasing over time*.

Interactions involving SST show the tendency for high-salinity species to be increasing over time.

Interpreting interactions

If the signs of the main effect and the interaction are the same (both positive or both negative), then the interaction with a second variable amplifies the main effect. Conversely, opposite signs means that the second variable damps the main effect.

Consider the model with an interaction between sea-surface temperature and year, or SST and yr. The interpretation of these effects is as follows:

  • Positive yr: Species that increase through time

  • Positive SST: Species caught in warm waters

  • Positive SST:yr: Two (equally valid) interpretations, i) Effect of SST increases through time (yr) and ii) Rate of increase in catch increases with SST.

In the model we can see this with a simple derivative. Here is a regression with terms for two main effects and the interaction between them,

\[ y = \dots + \beta_{SST} \times SST + \beta_{yr} \times yr + \beta_{SST:yr} \times SST \times yr + \dots \] The response \(y\) is the catch per effort. The \(\beta\)’s are the fitted coefficients, positive meaning increase, and negative meaning decrease. The ellipsis ‘…’ refers to other terms in the model. Here is the effect of SST from this model:

\[ \frac{\partial y}{\partial SST} = \beta_{SST} + \beta_{SST:yr} \times yr \] If the main effect of SST is positive (\(\beta_{SST} > 0\)), and the interaction is negative (\(\beta_{SST:yr} < 0\)), then the positive effect of warms seas is declining over time.

If the main effect of yr is positive, then this negative interaction means that the increasing trend (\(\beta_{yr} > 0\)) is lowest in cold seas,

\[ \frac{\partial y}{\partial yr} = \beta_{yr} + \beta_{SST:yr} \times SST \]

For example, Sandbar is increasing over time and it tends to be caught in cold waters. The positive interaction suggests that its rate of catch increase is greatest in warm waters. Equivalently, the negative effect of temperature is reduced over time.

Conversely, hammerhe9 are in decline and they tend to be caught in cold waters. The negative interaction suggests that the decline is fastest in cold waters. Alternatively, the effect of SST has diminished over time.

Interpreting factors

Factors have discrete levels. Most commonly, a reference factor level is represented by the intercept for the model, and coefficients for the remaining factor levels are added to this overall intercept. In other words, the coefficients must be interpreted relative to the reference.

Here are the year and season effects:

orderPlot( vnames = c('yr','seasonJAS','seasonJFM','seasonOND'), out )
*Species that are increasing (positive year effect) do not show clear seasonal differences*.

Species that are increasing (positive year effect) do not show clear seasonal differences.

The reference season in this model is the one that does not appear, seasonAMJ. The second graph has season coefficients that are above (positive) or below (negative) seasonAMJ.

Interpret the fitted model

On the basis of the two graphs for this analysis, discuss the following:

  1. Select four species that are increasing and four that are decreasing. Based on their interactions with SST, describe how their increases or declines are affected by temperature.

  2. The three seasons in the second graph have coefficients that are relative to a reference class, i.e., the one that is not shown, the spring season seasonAMJ. Select three strongly seasonal species, and use coefficients to speculate on why they might be increasing or decreasing.