Making predictions

So far...

  • Build, check & select models for detectability
  • Build, check & select models for abundance
  • Make some ecological inference about smooths
  • What about predictions?

Let's talk about maps

What does a map mean?

plot of chunk predmap1

  • Grids!
  • Cells are abundance estimate
  • “snapshot”
  • Sum cells to get abundance
  • Sum a subset?

Going back to the formula

(Count) Model:

\[ n_j = A_j\hat{p}_j \exp\left[ \beta_0 + s(\text{y}_j) + s(\text{Depth}_j) \right] + \epsilon_j \]

Predictions (index \( r \)):

\[ n_r = A_r \exp\left[ \beta_0 + s(\text{y}_r) + s(\text{Depth}_r) \right] \]

Need to “fill-in” values for \( A_r \), \( \text{y}_r \) and \( \text{Depth}_r \).

Predicting

  • With these values can use predict in R
  • predict(model, newdata=data)

Prediction data

           x      y     Depth    SST      NPP DistToCAS    EKE off.set
126 547984.6 788254  153.5983 8.8812 1462.521 11788.974 0.0074   1e+08
127 557984.6 788254  552.3107 9.2078 1465.410  5697.248 0.0144   1e+08
258 527984.6 778254   96.8199 9.6341 1429.432 13722.626 0.0024   1e+08
259 537984.6 778254  138.2376 9.6650 1424.862  9720.671 0.0027   1e+08
260 547984.6 778254  505.1439 9.7905 1379.351  8018.690 0.0101   1e+08
261 557984.6 778254 1317.5952 9.9523 1348.544  3775.462 0.0193   1e+08
    LinkID    Nhat_tw
126      1 0.01417657
127      2 0.05123483
258      3 0.01118858
259      4 0.01277096
260      5 0.04180434
261      6 0.45935801

A quick word about rasters

  • We have talked about rasters a bit
  • In R, the data.frame is king
  • Fortunately as.data.frame exists
  • Make our “stack” and then convert to data.frame

Predictors

plot of chunk preddata-plot

Making a prediction

  • Add another column to the prediction data
  • Plotting then easier (in R)
predgrid$Nhat_tw <- predict(dsm_all_tw_rm, predgrid)

Maps of predictions