fdbk_dt_conttable: Calculates stratified contingency table entries (above...

Description Usage Arguments Value Author(s) Examples

View source: R/fdbk_asdataframe.R

Description

Calculates stratified contingency table entries (above threshold) for a data table

Usage

1
fdbk_dt_conttable(DT, vars = NULL, thrs = NULL, by = NULL, cores = 1)

Arguments

DT

data.table with relevant information

vars

character vector of varnos (if NULL take from DT)

thrs

list of vectors of thresholds for each varno (if NULL threshold are generated from quantiles)

by

stratify contingency entries by these DT columns

cores

number of CPU cores to split the calculation (helps for larger data tables)

Value

data.table with columns varno,thr, hits,false,miss,corrneg and the arguments of 'by'

Author(s)

Felix <felix.fundel@dwd.de>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#EXAMPLE (CSI for quantile thresholds) 
require(ggplot2)
fnames                = system("ls ~/examplesRfdbk/*/synop/verSYNOP.*",intern=T)
cond                  = list(veri_description="grepl('forecast',veri_description)",
                             veri_forecast_time="veri_forecast_time%in%c(2400,4800,7200,9600,12000,14400,16800)")
columnnames           = c("obs","veri_data","varno","veri_model","veri_forecast_time","statid","veri_initial_date")
DT                    = fdbk_dt_multi_large(fnames,cond,columnnames,20)
vars                  = c('1','3','4','29')
thrs                  = list('1'=c(50,60),'3'=c(-5,0,5),'4'=c(-5,0,5),'29'=c(.4,.6,.8))
xx                    = fdbk_dt_conttable(DT,vars=vars,thrs=thrs,by=c("veri_model","veri_forecast_time","varno"),cores=10)
CSI                   = xx[,list(csi =(hit)/(hit + miss + false) ),by=c("veri_forecast_time","veri_model","thr","varno")]
CSI[,varno:=varno_to_name(varno,T)]
ggplot(CSI,aes(x=thr,y=csi,color=factor(veri_forecast_time),linetype=factor(veri_model),group=interaction(varno,veri_forecast_time,veri_model)))+
geom_line()+
ggtitle("CSI")+
facet_wrap(~varno,scales="free_x")

rfxf/Rfdbk documentation built on May 27, 2019, 7:22 a.m.