Comparing approaches to forecasting species richness using the Breeding Bird Survey

This project attempts to develop and evaluate a variety of approaches to making relatively short-term forecasts for patterns of species richness in the Breeding Bird Survey of North America data (BBS). BBS is being used as a starting point to develop these forecasts for community ecology more generally.

Forecasting methods currently being used include:

  • Naive (last observed value in the time-series)
  • Long-term average of value
  • ARIMA models
  • Spatial environmental linear models (currently just MODIS NDVI)
  • Temporal environmental linear models (i.e., regressions fit to time-series at focal site; currently just MODIS NDVI)

Additional modeling approaches to be added include:

  • Stacked single-species SDMs
  • Joint SDMs
  • spatio-temporal models?
  • model averaging

In [1]:
library(forecast)
library(Hmisc)
library(dplyr)
library(broom)
library(ggplot2)
library(tidyr)
library(mgcv)
library(lme4)
library(caret)
library(gridExtra)
devtools::load_all()

library(sp)
library(raster)
library(maptools)
library(rgeos)
library(rgdal)
library(maps)
library(viridis)


Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: timeDate
This is forecast 7.1 

Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: ‘Hmisc’

The following objects are masked from ‘package:base’:

    format.pval, round.POSIXt, trunc.POSIXt, units


Attaching package: ‘dplyr’

The following objects are masked from ‘package:Hmisc’:

    combine, src, summarize

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Loading required package: nlme

Attaching package: ‘nlme’

The following object is masked from ‘package:dplyr’:

    collapse

The following object is masked from ‘package:forecast’:

    getResponse

This is mgcv 1.8-11. For overview type 'help("mgcv-package")'.
Loading required package: Matrix

Attaching package: ‘Matrix’

The following object is masked from ‘package:tidyr’:

    expand


Attaching package: ‘lme4’

The following object is masked from ‘package:nlme’:

    lmList


Attaching package: ‘caret’

The following object is masked from ‘package:survival’:

    cluster


Attaching package: ‘gridExtra’

The following object is masked from ‘package:dplyr’:

    combine

The following object is masked from ‘package:Hmisc’:

    combine

Loading BBSforecasting
Warning message:
In setup_ns_exports(pkg, export_all): Objects listed as exports, but not present in namespace: cleanup_multi_ts_forecasts
Attaching package: ‘raster’

The following object is masked from ‘package:nlme’:

    getData

The following object is masked from ‘package:tidyr’:

    extract

The following object is masked from ‘package:dplyr’:

    select

The following objects are masked from ‘package:Hmisc’:

    mask, zoom

Checking rgeos availability: TRUE

Attaching package: ‘maptools’

The following object is masked from ‘package:Hmisc’:

    label

rgeos version: 0.3-19, (SVN revision 524)
 GEOS runtime version: 3.5.0-CAPI-1.9.0 r4084 
 Linking to sp version: 1.2-1 
 Polygon checking: TRUE 


Attaching package: ‘rgeos’

The following object is masked from ‘package:Hmisc’:

    translate

rgdal: version: 1.1-10, (SVN revision 622)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.11.3, released 2015/09/16
 Path to GDAL shared files: /usr/share/gdal/1.11
 Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.2-1 

 # ATTENTION: maps v3.0 has an updated 'world' map.        #
 # Many country borders and names have changed since 1990. #
 # Type '?world' or 'news(package="maps")'. See README_v3. #


Initial data setup

Load the BBS data and limit it to sites with contiguous time-series from 2000 to 2014 (the range spanned by the MODIS data).


In [2]:
start_yr <- 1982
end_yr <- 2013
min_num_yrs <- 25
richness_w_env <- get_richness_ts_env_data(start_yr, end_yr, min_num_yrs)

In [3]:
head(richness_w_env)
cat("There are", length(unique(richness_w_env$site_id)), "time-series with at least", min_num_yrs, "years of data between", start_yr, "and", end_yr)


site_idyearrichnesslatlongbio1bio2bio4bio5bio6bio10bio11bio16bio17bio18bio19ndvi_sumndvi_winndvi_annelevs
12001 1982 49 34.868688 -87.6041417 15.612916747729 12.1458334848285 765.160901860803 32.1599998474121 -2.9100000858306924.0583337148031 7.17500003178914 441.839996337891 283.299995422363 286.500003814697 398.770004272461 0.6876666666666670.3658333333333330.5605 210.126277474451
22001 1983 49 34.868688 -87.6041417 15.0962499578794 12.0424999545018 878.92348940742 34.4300003051758 -2.5299999713897725.5266666412354 6.63499983151754 711.889999389648 142.71000289917 142.71000289917 337.970008850098 0.6436666666666670.396 0.548833333333333210.126277474451
32001 1984 65 34.868688 -87.6041417 15.8524999022484 12.6483332763116 781.218674275284 31.3199996948242 -4.0399999618530323.9866669972738 6.45166659355164 428.110008239746 119.760004520416 119.760004520416 275.449993133545 0.7241666666666670.3691666666666670.565 210.126277474451
42001 1985 54 34.868688 -87.6041417 15.5324999888738 11.969999919335 890.206880304819 31.5100002288818 -5.3000001907348623.988333384196 5.71166666348775 301.029998779297 231.919998168945 301.029998779297 257.060001373291 0.7206666666666670.4165 0.595 210.126277474451
52001 1986 54 34.868688 -87.6041417 16.4687499205271 12.5474994579951 807.521006713121 34.0999984741211 -2.9900000095367425.5733331044515 8.13000011444092 567.989990234375 195.049999237061 245.440002441406 195.049999237061 0.647 0.4115 0.573208333333333210.126277474451
62001 1987 58 34.868688 -87.6041417 16.221249739329 13.2524997492631 820.299698883502 34.5299987792969 -1.3300000429153425.42999903361 7.77500009536743 337.099998474121 205.350002288818 238.249996185303 337.099998474121 0.6966666666666670.4085 0.578875 210.126277474451
There are 669 time-series with at least 25 years of data between 1982 and 2013

Maps of variables


In [4]:
states <- map_data("state")
map_year = 2009 #pick a year to map

richness_w_env_oneyear <- dplyr::filter(richness_w_env, year == map_year) %>%
  na.omit()
map_richness <- ggplot() +
  geom_polygon(data=states, aes(x=long, y=lat, group=group), color="black", fill="white") +
  geom_point(data=richness_w_env_oneyear, aes(x=long, y=lat, color=richness)) +
  scale_color_viridis() +
  coord_map()
ggsave("figures/map_richness.png", map_richness)

env_oneyear_long <- tidyr::gather(richness_w_env_oneyear, env_var, value, bio1:elevs)
maps_env_vars <- env_oneyear_long %>%
  group_by(env_var) %>%
  do(plots=ggplot() +
    geom_polygon(data=states, aes(x=long, y=lat, group=group), color="black", fill="white") +
    geom_point(data=., aes(x=long, y=lat, color=value)) +
    scale_color_viridis() +
    coord_map() +
    ggtitle(first(.$env_var))
    )
multi_panel_fig <- do.call("arrangeGrob", c(maps_env_vars$plots, ncol=4))
ggsave("figures/map_env_vars.png", multi_panel_fig, width = 20, height = 20)


Saving 6.67 x 6.67 in image

Map of Richness

Map of Environmental Variables

Forecasting

Generate forecasts for naive, average, and ARIMA time-series models for each site.


In [5]:
lag <- 10
richness_by_site <- group_by(richness_w_env, site_id)
tsmodel_forecasts <- get_ts_forecasts(richness_by_site, timecol = 'year',
                                      responsecol = 'richness',
                                      exogcols = c("ndvi_sum", "ndvi_win"), lag = lag, pred_int_levels=seq(1, 99, by=1))
head(tsmodel_forecasts$pt_est)
head(tsmodel_forecasts$intervals)


Warning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time seriesWarning message:
In ets(get_train_data(., responsecol)): Missing values encountered. Using longest contiguous portion of time series
site_idmodeltimeperiodobspt_fcast
12001 naive2004 58 63
22001 naive2005 56 63
32001 naive2006 62 63
42001 naive2007 60 63
52001 naive2008 59 63
62001 naive2009 55 63
site_idmodeltimeperiodobspt_fcastlevelslohi
12001 arima 2004 58 56.7 1 56.644606412905756.7553935870942
22001 arima 2004 58 56.7 10 56.144620441537257.2553795584628
32001 arima 2004 58 56.7 11 56.088743381528957.3112566184711
42001 arima 2004 58 56.7 12 56.032768441987357.3672315580126
52001 arima 2004 58 56.7 13 55.976686267514857.4233137324851
62001 arima 2004 58 56.7 14 55.920487379677657.4795126203224

Spatial environment-richness model prediction

White & Hurlbert 2010 linear model


In [6]:
richness_w_env_2003 <- filter(richness_w_env, year == 2003)
richness_w_env_pre_2004 <- filter(richness_w_env, year <= 2003)
richness_w_env_2004_2013 <- filter(richness_w_env, year >= 2004)
spatial_bioclim_model_2003 <- lm(richness ~ bio10 + I(bio10^2) + bio11 +
                      I(bio11^2) + bio12 + I(bio12^2), data = richness_w_env_2003)
spatial_env_model_2003 <- lm(richness ~ ndvi_sum + I(ndvi_sum^2) + ndvi_win + I(ndvi_win^2) + bio10 + I(bio10^2) + bio11 +
                      I(bio11^2) + bio12 + I(bio12^2) + elevs + I(elevs^2), data = richness_w_env_pre_2004)
fcast_spatial_bioclim <- forecast(spatial_bioclim_model_2003, newdata = richness_w_env_2004_2013)
fcast_spatial_env <- forecast(spatial_env_model_2003, newdata = richness_w_env_2004_2013, level = seq(1, 99, by=1))
fcast_spatial_bioclim_data <- cbind(richness_w_env_2004_2013, fcast_spatial_bioclim)
fcast_spatial_env_data <- cbind(richness_w_env_2004_2013, fcast_spatial_env)

fcast_spatial_bioclim_data$model <- 'spat_bioclim'
fcast_spatial_bioclim <- dplyr::select(fcast_spatial_bioclim_data,
                                   site_id, model, timeperiod = year, obs = richness,
                                   everything(), -lat, -long, -starts_with("bio"),
                                   -starts_with("ndvi"), -elevs)
fcast_spatial_bioclim <- restruct_ts_forecasts(fcast_spatial_bioclim)

fcast_spatial_env_data$model <- 'spat_env'
fcast_spatial_env <- dplyr::select(fcast_spatial_env_data,
                                   site_id, model, timeperiod = year, obs = richness,
                                   everything(), -lat, -long, -starts_with("bio"),
                                   -starts_with("ndvi"), -elevs)
fcast_spatial_env <- restruct_ts_forecasts(fcast_spatial_env)

head(fcast_spatial_env$pt_est)
head(fcast_spatial_env$intervals)


site_idmodeltimeperiodobspt_fcast
12001 spat_env 2004 58 50.8520969820016
22001 spat_env 2005 56 48.3649997230175
32001 spat_env 2006 62 48.5288018420137
42001 spat_env 2007 60 48.2016290030079
52001 spat_env 2008 59 51.4674350603092
62001 spat_env 2009 55 50.972427428738
site_idmodeltimeperiodobspt_fcastlevelslohi
12001 spat_env 2004 58 50.85209698200161 50.741297320462350.9628966435409
22001 spat_env 2004 58 50.852096982001610 49.741212341341451.9629816226618
32001 spat_env 2004 58 50.852096982001611 49.629445516004652.0747484479987
42001 spat_env 2004 58 50.852096982001612 49.517482887358452.1867110766448
52001 spat_env 2004 58 50.852096982001613 49.405305740334952.2988882236684
62001 spat_env 2004 58 50.852096982001614 49.292895113725752.4112988502776

GAM


In [7]:
high_corr_vars <- colnames(richness_w_env_pre_2004)[findCorrelation(cor(richness_w_env_pre_2004, use = "complete.obs"))]
cat("The following highly correlated variables are remove from GAM & LME modeling: ", high_corr_vars)


The following highly correlated variables are remove from GAM & LME modeling:  bio11 bio1 bio7 bio16

Environmental smoothers


In [8]:
spatial_env_gam_model <- gam(richness ~ s(ndvi_sum, bs = "ts") + s(ndvi_win, bs = "ts") + s(elevs, bs = "ts") +
                            s(bio2, bs = "ts") + s(bio3, bs = "ts") + s(bio4, bs = "ts") + s(bio5, bs = "ts") + s(bio6, bs = "ts") +
                            s(bio8, bs = "ts") + s(bio9, bs = "ts") + s(bio10, bs = "ts") + s(bio12, bs = "ts") + s(bio13, bs = "ts") +
                            s(bio14, bs = "ts") + s(bio15, bs = "ts") + s(bio17, bs = "ts") + s(bio18, bs = "ts") + s(bio19, bs = "ts"),
                            family = gaussian, data = richness_w_env_pre_2004
                            )
pt_fcast <- predict(spatial_env_gam_model, newdata = richness_w_env_2004_2013)
fcast_spatial_env_gam <- dplyr::select(fcast_spatial_env$pt_est, site_id, model, timeperiod, obs) %>%
  mutate(model="spat_env_gam") %>%
  cbind(pt_fcast)

Spatial smoother


In [9]:
spatial_env_gam_spatial_model <- gam(richness ~ ndvi_sum + ndvi_win + elevs +
                            bio2 + bio3 + bio4 + bio5 + bio6 + 
                            bio8 + bio9 + bio10 + bio12 + bio13 +
                            bio14 + bio15 + bio17 + bio18 + bio19 +
                            s(long, lat, bs = "ds"),
                            family = gaussian, data = richness_w_env_pre_2004
                            )
pt_fcast <- predict(spatial_env_gam_spatial_model, newdata = richness_w_env_2004_2013)
fcast_spatial_env_gam_spatial <- dplyr::select(fcast_spatial_env$pt_est, site_id, model, timeperiod, obs) %>%
  mutate(model="spat_env_gam_spat") %>%
  cbind(pt_fcast)
plot(spatial_env_gam_spatial_model)


Linear mixed-effects


In [10]:
spatial_env_lme_model <- lmer(richness ~ ndvi_sum + ndvi_win + elevs +
                              bio2 + bio3 + bio4 + bio5 + bio6 + 
                              bio8 + bio9 + bio10 + bio12 + bio13 +
                              bio14 + bio15 + bio17 + bio18 + bio19 + (1|site_id),
                              data = richness_w_env_pre_2004)
pt_fcast <- predict(spatial_env_lme_model, newdata = richness_w_env_2004_2013)
fcast_spatial_env_lme <- dplyr::select(fcast_spatial_env$pt_est, site_id, model, timeperiod, obs) %>%
  mutate(model="spat_env_lme") %>%
  cbind(pt_fcast)


Warning message:
: Some predictor variables are on very different scales: consider rescaling

In [11]:
summary(spatial_env_lme_model)
var(richness_w_env_pre_2004$richness, na.rm = TRUE)


Correlation matrix not shown by default, as p = 19 > 12.
Use print(obj, correlation=TRUE)  or
	 vcov(obj)	 if you need it

Linear mixed model fit by REML ['lmerMod']
Formula: richness ~ ndvi_sum + ndvi_win + elevs + bio2 + bio3 + bio4 +  
    bio5 + bio6 + bio8 + bio9 + bio10 + bio12 + bio13 + bio14 +  
    bio15 + bio17 + bio18 + bio19 + (1 | site_id)
   Data: richness_w_env_pre_2004

REML criterion at convergence: 82740.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-5.4463 -0.5709  0.0154  0.6035  4.8789 

Random effects:
 Groups   Name        Variance Std.Dev.
 site_id  (Intercept) 89.42    9.456   
 Residual             22.58    4.752   
Number of obs: 13382, groups:  site_id, 669

Fixed effects:
              Estimate Std. Error t value
(Intercept) 53.3834821  2.6635921  20.042
ndvi_sum    10.6434279  1.3076618   8.139
ndvi_win     6.4567462  1.2412912   5.202
elevs       -0.0048659  0.0007963  -6.111
bio2         0.1225478  0.1695800   0.723
bio3        -0.1453126  0.0566397  -2.566
bio4         0.0020200  0.0011260   1.794
bio5        -0.3384564  0.0714537  -4.737
bio6         0.2208954  0.0526219   4.198
bio8         0.0095748  0.0084771   1.129
bio9        -0.0069520  0.0074265  -0.936
bio10        0.2142795  0.0793706   2.700
bio12       -0.0013105  0.0004710  -2.782
bio13        0.0004583  0.0016143   0.284
bio14        0.0127917  0.0044098   2.901
bio15        0.0003212  0.0051110   0.063
bio17       -0.0022753  0.0013182  -1.726
bio18        0.0000486  0.0006482   0.075
bio19        0.0014898  0.0006180   2.411
fit warnings:
Some predictor variables are on very different scales: consider rescaling
137.385353427481

Assembling forecasts from different approaches


In [12]:
forecasts = list()
forecasts$pt_est <- bind_rows(tsmodel_forecasts$pt_est, fcast_spatial_env$pt_est, fcast_spatial_env_gam, fcast_spatial_env_gam_spatial, fcast_spatial_env_lme) %>%
  group_by(site_id) %>%
  filter(min(timeperiod) == 2004, max(timeperiod) == 2013) #a couple of sites have missing environmental data for forecast years, which is currently breaking things a little

#TODO: Make interval predictions for other spatial models and add
forecasts$intervals <- bind_rows(tsmodel_forecasts$intervals, fcast_spatial_env$intervals) %>%
  group_by(site_id) %>%
  filter(min(timeperiod) == 2004, max(timeperiod) == 2013) #a couple of sites have missing environmental data for forecast years, which is currently breaking things a little


Warning message:
: Grouping rowwise data frame strips rowwise nature

Example single site forecast

General notes

  • rapid changes in S not uncommon in last five years
  • common for last 5 years S vs. NDVI relationship to differ subsustantially from first 20 years

In [13]:
sites <- unique(richness_w_env$site_id)
focal_site <- sample(sites, 1)
print(focal_site)
viz_forecast(richness_w_env, forecasts$pt_est, focal_site)


[1] 61089
Warning message:
: Removed 6 rows containing missing values (geom_point).

Comparison of forecasting approaches


In [14]:
obs_pred_by_method_lag <- ggplot(forecasts$pt_est, aes(x = pt_fcast, y = obs)) +
    geom_point(alpha = 0.25) +
    facet_grid(model ~ timeperiod) +
    theme(aspect.ratio = 1) +
    ggtitle("Observed-predicted plots by method and lag")
ggsave("figures/obs_pred_by_method_lag.png", obs_pred_by_method_lag)


Saving 6.67 x 6.67 in image
Warning message:
: Removed 4590 rows containing missing values (geom_point).


In [15]:
model_accuracies <- group_by(forecasts$pt_est, site_id, model) %>%
                    do(get_error_measures(.$obs, .$pt_fcast))
head(model_accuracies, 10)


site_idmodelMERMSEMAEMPEMAPE
12001 arima 2.500000000000034.382921400162243.320000000000013.877972819042985.36433645540659
22001 avg 2.5 4.382921400162223.32 3.877972819042935.36433645540657
32001 ets 2.210830402158664.224662242962043.204332160863463.387751162189125.18769481699109
42001 exog_arima 0.4607294872552143.89482934069614 3.37231633060298 0.4410389108313075.64338332403094
52001 naive -3.8 5.23450093132096 4.6 -6.802252423285628.02384333237653
62001 spat_env 9.089705845024229.760623965459999.0897058450242215.078405113346315.0784051133463
72001 spat_env_gam 8.805327832659979.724378037004418.8053278326599714.606248745836614.6062487458366
82001 spat_env_gam_spat4.68750440583019 5.96375191269393 4.88145113004713 7.5881108152039 7.94074122287107
92001 spat_env_lme 2.321332561758894.241366279523933.297615088911813.5834391560503 5.34935741962759
102007 arima 10.545454545454612.347332164085 10.545454545454618.019217654433418.0192176544334

In [16]:
cbPalette <- c("#F0E442", "#D55E00", "#E69F00", "#56B4E9", "#009E73", "#0072B2", "#999999", "#CC79A7")
# rearranged from http://www.cookbook-r.com/Graphs/Colors_%28ggplot2%29/#a-colorblind-friendly-palette

In [17]:
model_accuracies$model = with(model_accuracies, factor(model, levels = c("spat_env", "spat_env_gam", "spat_env_gam_spat", "spat_env_lme", "arima", "exog_arima", "ets", "avg", "naive")))
accuracy_by_model_violins <- ggplot(model_accuracies, aes(model, MAPE)) +
     geom_violin(aes(fill = model), draw_quantiles = c(0.5), size = 1) +
     coord_cartesian(ylim = c(0,75)) +
     labs(x = "Model", y = "Percentage Error") +
     #scale_x_discrete(labels=c("Spatial Env", "Spatial Env GAM", "Spatial Env GAM Spatial", "Spatial Env LME", "Time-series", "Time-series+Env", "Average", "Naive")) +
     scale_color_brewer("Set3") + 
     theme_grey(base_size = 24) +
     guides(fill=FALSE) +
     theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
ggsave(accuracy_by_model_violins, file = 'figures/accuracy_by_model_violins.png', width = 7, height = 7)
accuracy_by_model_violins




In [18]:
model_accuracies_by_year <- group_by(forecasts$pt_est, site_id, model, timeperiod) %>%
                    do(get_error_measures(.$obs, .$pt_fcast))
model_accuracies_by_year$model = with(model_accuracies_by_year, factor(model, levels = c("spat_env", "spat_env_gam", "spat_env_gam_spat", "spat_env_lme", "arima", "exog_arima", "ets", "avg", "naive")))
head(model_accuracies_by_year)


site_idmodeltimeperiodMERMSEMAEMPEMAPE
12001 arima 2004 1.300000000000031.300000000000031.300000000000032.241379310344872.24137931034487
22001 arima 2005 -0.6999999999999740.699999999999974 0.699999999999974 -1.24999999999995 1.24999999999995
32001 arima 2006 5.300000000000035.300000000000035.300000000000038.548387096774238.54838709677423
42001 arima 2007 3.300000000000033.300000000000033.300000000000035.500000000000045.50000000000004
52001 arima 2008 2.300000000000032.300000000000032.300000000000033.898305084745813.89830508474581
62001 arima 2009 -1.699999999999971.69999999999997 1.69999999999997 -3.090909090909043.09090909090904

In [19]:
model_accuracies_by_year_plot <- ggplot(model_accuracies_by_year, aes(x = timeperiod, y = MAPE, color = model)) +
    stat_summary(fun.data = "mean_cl_boot", position=position_dodge(width = 0.4), size=0.75) +
     labs(x = "Year", y = "Percentage Error") +
     coord_cartesian(ylim = c(0, 18), xlim = c(2004,2013)) +
     scale_color_brewer(palette = "Set3") +
     theme_grey(base_size = 24)

ggsave(model_accuracies_by_year_plot, file = "figures/model_accuracies_by_year.png", height = 5, width = 7)
model_accuracies_by_year_plot


Warning message:
: Removed 4590 rows containing non-finite values (stat_summary).Warning message:
: Removed 4590 rows containing non-finite values (stat_summary).

Forecast Coverage

Evaluate how well the 95% forecast intervals work


In [20]:
head(forecasts$intervals)


site_idmodeltimeperiodobspt_fcastlevelslohi
12001 arima 2004 58 56.7 1 56.644606412905756.7553935870942
22001 arima 2004 58 56.7 10 56.144620441537257.2553795584628
32001 arima 2004 58 56.7 11 56.088743381528957.3112566184711
42001 arima 2004 58 56.7 12 56.032768441987357.3672315580126
52001 arima 2004 58 56.7 13 55.976686267514857.4233137324851
62001 arima 2004 58 56.7 14 55.920487379677657.4795126203224

In [21]:
pred_interval_results <- forecasts$intervals %>%
                           group_by(model, levels) %>%
                           na.omit() %>%
                           summarize(coverage = sum(obs > lo & obs < hi) / n())
head(pred_interval_results)


modellevelscoverage
1arima 1 0.0257194244604317
2arima 2 0.031294964028777
3arima 3 0.037589928057554
4arima 4 0.0442446043165468
5arima 5 0.0510791366906475
6arima 6 0.0598920863309352

In [22]:
ggplot(pred_interval_results, aes(x = levels / 100, y = coverage, color = model)) +
  geom_line(size = 1) +
  geom_abline(intercept = 0, slope = 1, size = 2, linetype = "dashed") +
  xlab("Forecast Interval") +
  ylab("Coverage")




In [23]:
trends <- richness_w_env %>%
  group_by(site_id) %>%
  na.omit() %>%
  summarize(trend_rich = cor(richness, year), trend_ndvi_ann = cor(ndvi_ann, year), ndvi_rich_corr = cor(richness, ndvi_ann))
head(trends)


site_idtrend_richtrend_ndvi_annndvi_rich_corr
12001.0000000 0.3501663 0.6648884 0.1443165
22007.0000000 0.7086010 0.5167732 0.2274567
32010.0000000 0.7316861 0.6438039 0.5142819
42014.0000000 0.2679702 0.5370923 0.1064633
52015.0000000 0.3213840 0.3299191 0.3795420
62017.00000000 -0.40716514 0.65627174 -0.09613597

In [24]:
trends <- richness_w_env %>%
  group_by(site_id) %>%
  na.omit() %>%
  do(tidy(lm(richness ~ year, data = .))) %>%
  filter(term == 'year')
trends$adj_pval <- p.adjust(trends$p.value, method = 'fdr')
trends_rich_plot <- ggplot(trends, aes(x = estimate)) +
  geom_histogram(fill = 'gray')
trends_rich_sig_plot <- ggplot(trends, aes(x = estimate)) +
  geom_histogram(fill = 'gray') + 
  geom_histogram(data = filter(trends, adj_pval < 0.05), fill = 'gray', color = 'black')

ggsave(trends_rich_plot, file = "figures/trends_rich_plot.png")
ggsave(trends_rich_sig_plot, file = "figures/trends_rich_sig_plot.png")
trends_rich_sig_plot


Saving 6.67 x 6.67 in image
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Saving 6.67 x 6.67 in image
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.


In [25]:
sig_sites <- trends %>%
  filter(adj_pval < 0.05, estimate > 0.333 | estimate < -0.333) %>%
  dplyr::select(site_id)
model_accuracies_sig <- filter(model_accuracies, site_id %in% sig_sites$site_id)

sig_accuracy_by_model_violins <- ggplot(model_accuracies_sig, aes(model, MAPE)) +
     geom_violin(aes(fill = model), draw_quantiles = c(0.5), size = 1) +
     coord_cartesian(ylim = c(0,75)) +
     labs(x = "Model", y = "Percentage Error") +
#     scale_x_discrete(labels=c("Spatial Env", "Time-series", "Time-series+Env", "Average", "Naive")) +
#     scale_fill_manual(values = cbPalette) + 
     scale_color_brewer("Set3") +
     theme_grey(base_size = 24) +
     guides(fill=FALSE) +
     theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
ggsave(sig_accuracy_by_model_violins, file = 'figures/sig_accuracy_by_model_violins.png', width = 7, height = 7)
sig_accuracy_by_model_violins



Comparison of bioclim and simple environmental model


In [26]:
forecasts_spatial <- rbind(fcast_spatial_bioclim$pt_est, fcast_spatial_env$pt_est) %>%
  group_by(site_id) %>%
  filter(min(timeperiod) == 2004, max(timeperiod) == 2013)

model_accuracies_spatial <- group_by(forecasts_spatial, site_id, model) %>%
  do(get_error_measures(.$obs, .$pt_fcast))

ggplot(model_accuracies_spatial, aes(model, MAPE)) +
     geom_violin(aes(fill = model), draw_quantiles = c(0.5), size = 1) +
     #coord_cartesian(ylim = c(0,75)) +
     labs(x = "Model", y = "Percentage Error") +
     #scale_x_discrete(labels=c("Spatial Env", "Time-series", "Time-series+Env", "Average", "Naive")) +
     scale_fill_manual(values = cbPalette) + 
     theme_grey(base_size = 24) +
     guides(fill=FALSE) +
     theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))



Models combining spatial & temporal information


In [27]:
richness_w_env_prev_yr_rich <- richness_w_env %>%
  dplyr::select(site_id, year, prev_yr_rich=richness) %>%
  mutate(year = year + 1) %>%
  inner_join(richness_w_env, by = c("site_id", "year"))
head(richness_w_env_prev_yr_rich)


site_idyearprev_yr_richrichnesslatlongbio1bio2bio4bio5bio10bio11bio16bio17bio18bio19ndvi_sumndvi_winndvi_annelevs
12001 1983 49 49 34.868688 -87.6041417 15.0962499578794 12.0424999545018 878.92348940742 34.4300003051758 25.5266666412354 6.63499983151754 711.889999389648 142.71000289917 142.71000289917 337.970008850098 0.6436666666666670.396 0.548833333333333210.126277474451
22001 1984 49 65 34.868688 -87.6041417 15.8524999022484 12.6483332763116 781.218674275284 31.3199996948242 23.9866669972738 6.45166659355164 428.110008239746 119.760004520416 119.760004520416 275.449993133545 0.7241666666666670.3691666666666670.565 210.126277474451
32001 1985 65 54 34.868688 -87.6041417 15.5324999888738 11.969999919335 890.206880304819 31.5100002288818 23.988333384196 5.71166666348775 301.029998779297 231.919998168945 301.029998779297 257.060001373291 0.7206666666666670.4165 0.595 210.126277474451
42001 1986 54 54 34.868688 -87.6041417 16.4687499205271 12.5474994579951 807.521006713121 34.0999984741211 25.5733331044515 8.13000011444092 567.989990234375 195.049999237061 245.440002441406 195.049999237061 0.647 0.4115 0.573208333333333210.126277474451
52001 1987 54 58 34.868688 -87.6041417 16.221249739329 13.2524997492631 820.299698883502 34.5299987792969 25.42999903361 7.77500009536743 337.099998474121 205.350002288818 238.249996185303 337.099998474121 0.6966666666666670.4085 0.578875 210.126277474451
62001 1988 58 65 34.868688 -87.6041417 15.4616668224335 13.3283332232386 862.05464414433 33.810001373291 25.4516671498617 5.98999993006388 395.599998474121 164.449995040894 297.400001525879 226.840000152588 0.6538333333333330.4185 0.587041666666667210.126277474451

In [28]:
spatial_statespace_model_1983 <- gam(richness ~ prev_yr_rich + s(ndvi_sum) + s(ndvi_win) + s(elevs) +
                                  s(bio1) + s(bio2) + s(bio3) + s(bio4) + s(bio5) + s(bio6) + s(bio7) +
                                  s(bio8) + s(bio9) + s(bio10) + s(bio11) + s(bio12) + s(bio13) +
                                  s(bio14) + s(bio15) + s(bio16) + s(bio17) + s(bio18) + s(bio19),
                                  family = gaussian, data = richness_w_env_prev_yr_rich
                                 )

summary(spatial_statespace_model_1983)


Family: gaussian 
Link function: identity 

Formula:
richness ~ prev_yr_rich + s(ndvi_sum) + s(ndvi_win) + s(elevs) + 
    s(bio1) + s(bio2) + s(bio3) + s(bio4) + s(bio5) + s(bio6) + 
    s(bio7) + s(bio8) + s(bio9) + s(bio10) + s(bio11) + s(bio12) + 
    s(bio13) + s(bio14) + s(bio15) + s(bio16) + s(bio17) + s(bio18) + 
    s(bio19)

Parametric coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  8.043804   0.214599   37.48   <2e-16 ***
prev_yr_rich 0.848615   0.004015  211.34   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
              edf Ref.df      F  p-value    
s(ndvi_sum) 6.721  7.819 13.891  < 2e-16 ***
s(ndvi_win) 8.225  8.832  8.568 1.06e-12 ***
s(elevs)    5.128  6.280  4.423 0.000146 ***
s(bio1)     6.382  7.589  2.703 0.007633 ** 
s(bio2)     2.993  3.935  1.660 0.201304    
s(bio3)     4.709  5.945  2.488 0.021164 *  
s(bio4)     2.460  3.283  1.552 0.189240    
s(bio5)     4.820  5.961  1.498 0.179296    
s(bio6)     3.526  4.666  1.888 0.144666    
s(bio7)     1.415  1.897  0.358 0.623336    
s(bio8)     2.072  2.635  0.997 0.324792    
s(bio9)     1.000  1.000  4.453 0.034858 *  
s(bio10)    6.743  7.927  2.247 0.021868 *  
s(bio11)    2.845  3.780  4.459 0.001770 ** 
s(bio12)    3.225  4.220  2.911 0.017972 *  
s(bio13)    1.000  1.000  5.894 0.015201 *  
s(bio14)    1.148  1.280  0.133 0.836366    
s(bio15)    4.885  6.058  2.385 0.025672 *  
s(bio16)    1.000  1.000  0.196 0.657632    
s(bio17)    3.466  4.433  1.100 0.400339    
s(bio18)    3.788  4.799  1.914 0.124795    
s(bio19)    4.053  5.155  0.811 0.562821    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Rank: 199/200
R-sq.(adj) =  0.851   Deviance explained = 85.2%
GCV = 20.311  Scale est. = 20.214    n = 17472