Skip to content

Commit

Permalink
Test predictions with new column names
Browse files Browse the repository at this point in the history
  • Loading branch information
gmyenni committed Aug 17, 2017
1 parent a1c4fd4 commit f656693
Show file tree
Hide file tree
Showing 14 changed files with 2,486 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DevelopingModels/abundance-gam.R
@@ -1,4 +1,4 @@
abundance-gam=function(level,date,forecastmonth,forecastyear,NewMoonNumber,CI_level) {
abundance-gam=function(level,date,forecastmonth,forecastyear,newmoonnumber,CI_level) {

mc.cores = 8 # How many species to run in parallel
new_yday = yday(Sys.Date()) # Replace Sys.Date with the next Portal sampling date
Expand Down Expand Up @@ -324,7 +324,7 @@ CIs = function(sp, new_date, n_samples = 10000){

ci_predictions = lapply(species, CIs, new_date=Sys.Date())

return(bind_rows(date,forecastmonth,forecastyear,NewMoonNumber,"abundance","GAM",level,ci_predictions) %>%
return(bind_rows(date,forecastmonth,forecastyear,newmoonnumber,"abundance","GAM",level,ci_predictions) %>%
rename(LowerPI = X1, UpperPI = X2))

}
Binary file modified docs/index_files/figure-html/highabund_ts_forecasts-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/index_files/figure-html/highabund_ts_forecasts-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/index_files/figure-html/highabund_ts_forecasts-3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/index_files/figure-html/speciesforecasts-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/index_files/figure-html/unnamed-chunk-1-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/report_files/figure-html/speciesforecasts-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion forecast_tools.R
Expand Up @@ -123,7 +123,7 @@ plot_data = function(data) {
#'
#' Will only return values where there are matching comparison columns (currency, level, species)
#'
#' @param observations dataframe Has the columns NewMoonNumber, currency, level, species, actual
#' @param observations dataframe Has the columns newmoonnumber, currency, level, species, actual
#' @param forecasts dataframe passes the forecast validity check. Must have matching values in
#' the comparison columns
#' @param error_metric chr either 'mse' for mean squared error or 'likelihood' for the likelihood of the observation
Expand Down
10 changes: 5 additions & 5 deletions models/model_functions.R
Expand Up @@ -15,7 +15,7 @@ get_moon_data <- function(){
}

get_rodent_data <- function(moons, forecast_date, filename_suffix){
#Period 203/NewMoonNumber 217 will be when the training data timeseries
#Period 203/newmoonnumber 217 will be when the training data timeseries
#begins. Corresponding to Jan 1995
historic_start_period=203
historic_start_newmoon=217
Expand All @@ -27,7 +27,7 @@ get_rodent_data <- function(moons, forecast_date, filename_suffix){
#Control plots
#The total rodent count in each treatment
controls$total = rowSums(controls[,-(1:2)])
#Drop non-control treatments and add in NewMoonNumber
#Drop non-control treatments and add in newmoonnumber
controls = controls %>%
filter(treatment == 'control') %>%
select(-treatment) %>%
Expand Down Expand Up @@ -55,7 +55,7 @@ get_weather_data <- function(moons, all, first_forecast_newmoon, last_forecast_n
ungroup() %>%
left_join(moons, by=c('year','month'))

#Offset the NewMoonNumber to create a 6 month lag between
#Offset the newmoonnumber to create a 6 month lag between
#rodent observations and weather
weather_data$NewMoonNumber_with_lag = weather_data$newmoonnumber + 6

Expand All @@ -73,8 +73,8 @@ get_weather_data <- function(moons, all, first_forecast_newmoon, last_forecast_n
weather_forecast_months = moons %>%
filter(newmoonnumber >= first_forecast_newmoon-5, newmoonnumber <= last_forecast_newmoon-5)

# x=subset(weather,NewMoonNumber>=first_forecast_newmoon-5) %>%
# subset(NewMoonNumber<=last_forecast_newmoon-5)
# x=subset(weather,newmoonnumber>=first_forecast_newmoon-5) %>%
# subset(newmoonnumber<=last_forecast_newmoon-5)

weathermeans=weather_data[dim(weather_data)[1]-36:dim(weather_data)[1],] %>%
group_by(month) %>%
Expand Down
1,561 changes: 1,561 additions & 0 deletions predictions/2017-08-17Allforecasts.csv

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions predictions/2017-08-17Allforecasts_model_aic.csv
@@ -0,0 +1,89 @@
"date","currency","model","level","species","aic","fit_start_newmoon","fit_end_newmoon","initial_newmoon"
2017-08-17,"abundance","Forecast","All","total",3034.60905229841,217,495,495
2017-08-17,"abundance","AutoArima","All","total",91.6324260132344,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","BA",384.428584411101,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DM",1619.66569476751,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DO",1406.53591968049,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DS",210.824782951823,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","NA",819.825386119389,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","OL",752.414537331397,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","OT",1357.92431694639,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PB",1647.6533009071,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PE",1101.22977607059,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PF",979.150769576377,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PH",69.7529763394115,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PL",330.5131889748,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PM",644.09415520891,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PP",2123.32674855875,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RF",54.4160054117943,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RM",1017.66468317416,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RO",264.191906955607,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SF",443.915119000338,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SH",512.612175218924,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SO",25.9847290527406,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","total",2432.51309905006,217,495,495
2017-08-17,"abundance","Poisson Env","All","BA",630.520320082472,217,495,495
2017-08-17,"abundance","Poisson Env","All","DM",1648.64210410767,217,495,495
2017-08-17,"abundance","Poisson Env","All","DO",1461.0569689118,217,495,495
2017-08-17,"abundance","Poisson Env","All","DS",301.196540529903,217,495,495
2017-08-17,"abundance","Poisson Env","All","NA",816.878722711045,217,495,495
2017-08-17,"abundance","Poisson Env","All","OL",805.512059636401,217,495,495
2017-08-17,"abundance","Poisson Env","All","OT",1455.22472687595,217,495,495
2017-08-17,"abundance","Poisson Env","All","PB",1999.45148560436,217,495,495
2017-08-17,"abundance","Poisson Env","All","PE",1151.45011622835,217,495,495
2017-08-17,"abundance","Poisson Env","All","PF",1186.77733831323,217,495,495
2017-08-17,"abundance","Poisson Env","All","PH",65.0195026688012,217,495,495
2017-08-17,"abundance","Poisson Env","All","PL",403.105046547161,217,495,495
2017-08-17,"abundance","Poisson Env","All","PM",753.062701323725,217,495,495
2017-08-17,"abundance","Poisson Env","All","PP",4630.90697419721,217,495,495
2017-08-17,"abundance","Poisson Env","All","RF",49.5879839469814,217,495,495
2017-08-17,"abundance","Poisson Env","All","RM",1239.11456255679,217,495,495
2017-08-17,"abundance","Poisson Env","All","RO",299.458133928879,217,495,495
2017-08-17,"abundance","Poisson Env","All","SF",598.736678051361,217,495,495
2017-08-17,"abundance","Poisson Env","All","SH",598.017529551761,217,495,495
2017-08-17,"abundance","Poisson Env","All","SO",16.9928952446082,217,495,495
2017-08-17,"abundance","Poisson Env","All","total",3887.79500372605,217,495,495
2017-08-17,"abundance","Forecast","All","total",3034.60905229841,217,495,495
2017-08-17,"abundance","AutoArima","All","total",91.6324260132344,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","BA",384.428584411101,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DM",1619.66569476751,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DO",1406.53591968049,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","DS",210.824782951823,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","NA",819.825386119389,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","OL",752.414537331397,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","OT",1357.92431694639,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PB",1647.6533009071,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PE",1101.22977607059,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PF",979.150769576377,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PH",69.7529763394115,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PL",330.5131889748,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PM",644.09415520891,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","PP",2123.32674855875,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RF",54.4160054117943,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RM",1017.66468317416,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","RO",264.191906955607,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SF",443.915119000338,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SH",512.612175218924,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","SO",25.9847290527406,217,495,495
2017-08-17,"abundance","NegBinom Time Series","All","total",2432.51309905006,217,495,495
2017-08-17,"abundance","Poisson Env","All","BA",630.520320082472,217,495,495
2017-08-17,"abundance","Poisson Env","All","DM",1648.64210410767,217,495,495
2017-08-17,"abundance","Poisson Env","All","DO",1461.0569689118,217,495,495
2017-08-17,"abundance","Poisson Env","All","DS",301.196540529903,217,495,495
2017-08-17,"abundance","Poisson Env","All","NA",816.878722711045,217,495,495
2017-08-17,"abundance","Poisson Env","All","OL",805.512059636401,217,495,495
2017-08-17,"abundance","Poisson Env","All","OT",1455.22472687595,217,495,495
2017-08-17,"abundance","Poisson Env","All","PB",1999.45148560436,217,495,495
2017-08-17,"abundance","Poisson Env","All","PE",1151.45011622835,217,495,495
2017-08-17,"abundance","Poisson Env","All","PF",1186.77733831323,217,495,495
2017-08-17,"abundance","Poisson Env","All","PH",65.0195026688012,217,495,495
2017-08-17,"abundance","Poisson Env","All","PL",403.105046547161,217,495,495
2017-08-17,"abundance","Poisson Env","All","PM",753.062701323725,217,495,495
2017-08-17,"abundance","Poisson Env","All","PP",4630.90697419721,217,495,495
2017-08-17,"abundance","Poisson Env","All","RF",49.5879839469814,217,495,495
2017-08-17,"abundance","Poisson Env","All","RM",1239.11456255679,217,495,495
2017-08-17,"abundance","Poisson Env","All","RO",299.458133928879,217,495,495
2017-08-17,"abundance","Poisson Env","All","SF",598.736678051361,217,495,495
2017-08-17,"abundance","Poisson Env","All","SH",598.017529551761,217,495,495
2017-08-17,"abundance","Poisson Env","All","SO",16.9928952446082,217,495,495
2017-08-17,"abundance","Poisson Env","All","total",3887.79500372605,217,495,495

0 comments on commit f656693

Please sign in to comment.