Project

General

Profile

« Previous | Next » 

Revision 6cb81608

Added by Benoit Parmentier over 11 years ago

Validation functions, degugging, missing parameters and library

View differences:

climate/research/oregon/interpolation/GAM_fusion_function_multisampling_validation_metrics.R
2 2

  
3 3
#The interpolation is done first at the monthly add delta.
4 4
#AUTHOR: Benoit Parmentier                                                                        
5
#DATE: 03/12/2013                                                                                 
5
#DATE: 03/27/2013                                                                                 
6 6

  
7 7
#Change this to allow explicitly arguments...
8 8
#Arguments: 
......
38 38
  }
39 39
  
40 40
  calc_val_metrics_rast <-function(df,y_ref,pred_names){
41
    #
41
    #Input parameters:
42
    #1) df: data frame containing the observed and predicted variables (data_s or data_v)
43
    #2) y_ref: observed variable correspond to y_var_name??
44
    #3) pred_names: models run containig predicted values
45
    
46
    # library
47
    library(maptools)
48
    
49
    ## START SCRIPT
42 50
    
43 51
    list_metrics<-vector("list",length(pred_names))
44 52
    list_residuals<-vector("list",length(pred_names))
......
60 68
    return(accuracy_obj)
61 69
  }  
62 70
  
63
  ## BEGIN ##
71
  ############### BEGIN SCRIPT ###########
64 72
  
65 73
  #PARSING INPUT PARAMETERS
66 74
  day_list<- list_param$rast_day_year_list[[i]]
......
70 78
  #Change to results_mod_obj[[i]]$data_s to make it less specific
71 79
  data_v <- method_mod_obj[[i]]$data_v
72 80
  data_s <- method_mod_obj[[i]]$data_s
81
  y_var_name <- list_param$y_var_name #missing--debugging
73 82
  
74 83
  ## Now create the stack
75 84
  
......
124 133

  
125 134
boxplot_from_tb <-function(tb_diagnostic,metric_names,out_prefix){
126 135
  #now boxplots and mean per models
136
  library(gdata) #Nesssary to use cbindX
137
  
138
  ### Start script
139
  
127 140
  mod_names<-sort(unique(tb_diagnostic$pred_mod)) #models that have accuracy metrics
128 141
  t<-melt(tb_diagnostic,
129 142
          #measure=mod_var, 
......
138 151
  tb_mod_list<-lapply(mod_names, function(k) subset(tb, pred_mod==k)) #this creates a list of 5 based on models names
139 152
  names(tb_mod_list)<-mod_names
140 153
  #mod_metrics<-do.call(cbind,tb_mod_list)
154
  #debug here
141 155
  mod_metrics<-do.call(cbindX,tb_mod_list)
142 156
  test_names<-lapply(1:length(mod_names),function(k) paste(names(tb_mod_list[[1]]),mod_names[k],sep="_"))
143 157
  names(mod_metrics)<-unlist(test_names)
......
164 178
## Function to display metrics by months/seasons
165 179
boxplot_month_from_tb <-function(tb_diagnostic,metric_names,out_prefix){
166 180
  #Add code here...
181
  #d_month<-aggregate(TMax~month, data=tb_diagnostic, mean)  #Calculate monthly mean for every station in OR
182
  #d_month<-aggregate(TMax~month, data=tb_diagnostic, legnth)  #Calculate monthly mean for every station in OR
183
  
184

  
167 185
}
168 186

  
169 187

  

Also available in: Unified diff