63 |
63 |
met_stations_outfiles_obj_file<-"/data/project/layers/commons/data_workflow/output_data_365d_gam_fus_lst_test_run_07172013/met_stations_outfiles_obj_gam_fusion__365d_gam_fus_lst_test_run_07172013.RData"
|
64 |
64 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
|
65 |
65 |
y_var_name <- "dailyTmax"
|
66 |
|
out_prefix<-"analyses_09092013"
|
|
66 |
out_prefix<-"analyses_09232013"
|
67 |
67 |
|
68 |
68 |
#method_interpolation <- "gam_daily"
|
69 |
69 |
covar_obj_file_1 <- "covar_obj__365d_gam_day_lst_comb3_08132013.RData"
|
... | ... | |
122 |
122 |
###Table 3a, baseline 1: s(lat,lon)
|
123 |
123 |
#Change here !!! need to reorder rows based on mod first
|
124 |
124 |
model_col<-c("Baseline1","Elevation","Northing","Easting","LST","DISTOC","Forest","CANHEIGHT","LST*Forest","LST*CANHEIGHT") #
|
|
125 |
names_table_col<-c("ΔMAE","ΔRMSE","ΔME","Δr","Model")
|
125 |
126 |
df3a<- as.data.frame(sapply(table_data2,FUN=function(x) x-x[1]))
|
126 |
127 |
df3a<- round(df3a,digit=3) #roundto three digits teh differences
|
127 |
128 |
df3a$Model <-model_col
|
... | ... | |
131 |
132 |
###Table 3b, baseline 2: s(lat,lon) + s(elev)
|
132 |
133 |
|
133 |
134 |
model_col<-c("Baseline2","Northness","Eastness","LST","DISTOC","Forest","CANHEIGHT","LST*Forest","LST*CANHEIGHT")
|
134 |
|
names_table_col<-c("ΔMAE","ΔRMSE","ΔME","Δr","Model")
|
135 |
135 |
|
136 |
136 |
df3b <- as.data.frame(sapply(table_data1,FUN=function(x) x-x[1])) #difference between baseline (line 1) and other models
|
137 |
137 |
df3b <- round(df3b,digit=3) #roundto three digits the differences
|
... | ... | |
223 |
223 |
|
224 |
224 |
### Figure 1: Oregon study area
|
225 |
225 |
#3 parameters from output
|
226 |
|
infile_monthly<-list_outfiles$monthly_covar_ghcn_data #outile4 from database_covar script
|
227 |
|
infile_daily<-list_outfiles$daily_covar_ghcn_data #outfile3 from database_covar script
|
228 |
|
infile_locs<- list_outfiles$loc_stations_ghcn #outfile2? from database covar script
|
|
226 |
#infile_monthly<-list_outfiles$monthly_covar_ghcn_data #outile4 from database_covar script
|
|
227 |
#infile_daily<-list_outfiles$daily_covar_ghcn_data #outfile3 from database_covar script
|
|
228 |
#infile_locs<- list_outfiles$loc_stations_ghcn #outfile2? from database covar script
|
229 |
229 |
|
230 |
230 |
ghcn_dat <- readOGR(dsn=dirname(met_stations_obj$monthly_covar_ghcn_data),
|
231 |
231 |
sub(".shp","",basename(met_stations_obj$monthly_covar_ghcn_data)))
|
... | ... | |
346 |
346 |
title_plot,y_lab_text,add_CI)
|
347 |
347 |
names(list_param_plot)<-c("list_dist_obj","col_t","pch_t","legend_text","mod_name","x_tick_labels","metric_name",
|
348 |
348 |
"title_plot","y_lab_text","add_CI")
|
349 |
|
debug(plot_dst_MAE)
|
|
349 |
#undebug(plot_dst_MAE)
|
350 |
350 |
plot_dst_MAE(list_param_plot)
|
351 |
351 |
title(xlab="Distance to closest fitting station (km)")
|
352 |
352 |
|
... | ... | |
384 |
384 |
legend_text <- c("GAM","Kriging","GWR")
|
385 |
385 |
mod_name<-c("mod1","mod1","mod1")#selected models
|
386 |
386 |
add_CI <- c(TRUE,TRUE,TRUE)
|
|
387 |
CI_bar <- c(TRUE,TRUE,TRUE)
|
387 |
388 |
#add_CI <- c(TRUE,FALSE,FALSE)
|
388 |
389 |
|
389 |
390 |
##### plot figure 4 for paper
|
... | ... | |
398 |
399 |
par(mfrow=c(row_mfrow,col_mfrow))
|
399 |
400 |
|
400 |
401 |
metric_name<-"mae"
|
401 |
|
list_param_plot<-list(list_prop_obj,col_t,pch_t,legend_text,mod_name,metric_name,add_CI)
|
402 |
|
names(list_param_plot)<-c("list_prop_obj","col_t","pch_t","legend_text","mod_name","metric_name","add_CI")
|
|
402 |
list_param_plot<-list(list_prop_obj,col_t,pch_t,legend_text,mod_name,metric_name,add_CI,CI_bar)
|
|
403 |
names(list_param_plot)<-c("list_prop_obj","col_t","pch_t","legend_text","mod_name","metric_name","add_CI","CI_bar")
|
403 |
404 |
|
404 |
405 |
#debug(plot_prop_metrics)
|
405 |
406 |
plot_prop_metrics(list_param_plot)
|
... | ... | |
409 |
410 |
|
410 |
411 |
#now figure 4b
|
411 |
412 |
metric_name<-"rmse"
|
412 |
|
list_param_plot<-list(list_prop_obj,col_t,pch_t,legend_text,mod_name,metric_name,add_CI)
|
413 |
|
names(list_param_plot)<-c("list_prop_obj","col_t","pch_t","legend_text","mod_name","metric_name","add_CI")
|
|
413 |
list_param_plot<-list(list_prop_obj,col_t,pch_t,legend_text,mod_name,metric_name,add_CI,CI_bar)
|
|
414 |
names(list_param_plot)<-c("list_prop_obj","col_t","pch_t","legend_text","mod_name","metric_name","add_CI","CI_bar")
|
414 |
415 |
plot_prop_metrics(list_param_plot)
|
415 |
416 |
title(main="RMSE for hold out and methods",
|
416 |
417 |
xlab="Hold out validation/testing proportion",
|
... | ... | |
483 |
484 |
|
484 |
485 |
col_t<-c("red","blue","black")
|
485 |
486 |
pch_t<- 1:length(col_t)
|
486 |
|
|
487 |
487 |
##Make this a function???
|
488 |
488 |
y_range<-range(prop_obj_kriging$avg_tb$rmse,prop_obj_kriging_s$avg_tb$rmse)
|
489 |
489 |
#y_range<-range(prop_obj_gam$avg_tb$rmse,prop_obj_gam_s$avg_tb$rmse)
|
490 |
|
plot(prop_obj_gam$avg_tb$rmse ~ prop_obj_gam$avg_tb$prop, ylab="",xlab="",type="b",col=c("red"),pch=pch_t[1],ylim=y_range,lty=2)
|
491 |
|
lines(prop_obj_gam_s$avg_tb$rmse ~ prop_obj_gam_s$avg_tb$prop, ylab="",xlab="",type="b",pch=pch_t[1],ylim=y_range,col=c("red"))
|
492 |
|
lines(prop_obj_gwr_s$avg_tb$rmse ~ prop_obj_gwr_s$avg_tb$prop, ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[3],col=c("black"))
|
493 |
|
lines(prop_obj_gwr$avg_tb$rmse ~ prop_obj_gam$avg_tb$prop, ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[3],,col=c("black"),lty=2)
|
494 |
|
lines(prop_obj_kriging$avg_tb$rmse ~ prop_obj_kriging$avg_tb$prop,ylab="",xlab="", type="b",ylim=y_range,pch=pch_t[2],,col=c("blue"),lty=2)
|
495 |
|
lines(prop_obj_kriging_s$avg_tb$rmse ~ prop_obj_kriging_s$avg_tb$prop,ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[2],col=c("blue"))
|
|
490 |
#plot(prop_obj_gam$avg_tb$rmse ~ prop_obj_gam$avg_tb$prop, ylab="",xlab="",type="b",col=c("red"),pch=pch_t[1],ylim=y_range,lty=2)
|
|
491 |
#lines(prop_obj_gam_s$avg_tb$rmse ~ prop_obj_gam_s$avg_tb$prop, ylab="",xlab="",type="b",pch=pch_t[1],ylim=y_range,col=c("red"))
|
|
492 |
#lines(prop_obj_gwr_s$avg_tb$rmse ~ prop_obj_gwr_s$avg_tb$prop, ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[3],col=c("black"))
|
|
493 |
#lines(prop_obj_gwr$avg_tb$rmse ~ prop_obj_gam$avg_tb$prop, ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[3],,col=c("black"),lty=2)
|
|
494 |
#lines(prop_obj_kriging$avg_tb$rmse ~ prop_obj_kriging$avg_tb$prop,ylab="",xlab="", type="b",ylim=y_range,pch=pch_t[2],,col=c("blue"),lty=2)
|
|
495 |
#lines(prop_obj_kriging_s$avg_tb$rmse ~ prop_obj_kriging_s$avg_tb$prop,ylab="",xlab="",type="b",ylim=y_range,pch=pch_t[2],col=c("blue"))
|
496 |
496 |
|
497 |
497 |
plot_ac_holdout_prop<- function(l_prop,l_col_t,l_pch_t,add_CI,y_range){
|
498 |
498 |
|
... | ... | |
515 |
515 |
l_col_t <- c("red","red","black","black","blue","blue")
|
516 |
516 |
l_pch_t <- c(1,1,3,3,2,2)
|
517 |
517 |
l_lty_t <- c(2,1,1,2,2,1)
|
518 |
|
add_CI <- c(TRUE,TRUE,FALSE,FALSE,FALSE,FALSE)
|
|
518 |
add_CI <- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE)
|
|
519 |
#add_CI <- c(TRUE,TRUE,TRUE,TRUE,TRUE,TRUE)
|
519 |
520 |
y_range<-c(0.5,3)
|
520 |
521 |
|
521 |
522 |
plot_ac_holdout_prop(l_prop,l_col_t,l_pch_t,add_CI,y_range)
|
522 |
523 |
|
523 |
|
legend_text <- c("GAM","Kriging","GWR","training","testing")
|
|
524 |
legend_text <- c("GAM","Kriging","GWR")
|
|
525 |
#legend_text <- c("GAM","Kriging","GWR","training","testing")
|
524 |
526 |
|
|
527 |
#legend("topleft",legend=legend_text,
|
|
528 |
# cex=0.9, pch=c(pch_t,NA,NA),col=c(col_t,"white","white"),lty=c(NA,NA,NA,1,2),bty="n")
|
525 |
529 |
legend("topleft",legend=legend_text,
|
526 |
|
cex=0.9, pch=c(pch_t,NA,NA),col=c(col_t,NA,NA),lty=c(NA,NA,NA,1,2),bty="n")
|
|
530 |
cex=0.9, pch=c(pch_t),col=c(col_t),lty=c(1,1,1),bty="n")
|
|
531 |
legend_text_data <-c("training","testing")
|
|
532 |
legend("top",legend=legend_text_data,
|
|
533 |
cex=0.9, lty=c(1,2),bty="n")
|
|
534 |
|
527 |
535 |
title(main="Training and testing RMSE for hold out and methods",
|
528 |
536 |
xlab="Hold out validation/testing proportion",
|
529 |
537 |
ylab="RMSE (C)")
|
modifications, contribution of covariates, figures and analyses for paper 1, OR