fdbk_dt_conttable_2thrs: Calculates stratified contingency table entries (above or...

Description Usage Arguments Value Author(s) Examples

View source: R/fdbk_asdataframe.R

Description

Calculates stratified contingency table entries (above or between thresholds) for a data table

Usage

1
fdbk_dt_conttable_2thrs(DT, thrs, by, cores = 1, incores = 1)

Arguments

DT

data.table with relevant information (at least varno, obs and veri_data)

thrs

list of variable having each a list of lower/upper thresholds (set upper to Inf if only one threshold is required)

by

stratify contingency entries by these DT columns

cores

computing cores for the outer loop (splits computation by varnos)

incores

computing cores for the outer loop (splits computation by thresholds)(available cores have to be of number cores x incores)

Value

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

Author(s)

Felix <[email protected]>

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)
thrs                  = list('29'=list('lower'=c(.5,.8),'upper'=c(Inf,.9)),
                              '3'=list('lower'=c(-5,0,5),'upper'=c(Inf,Inf,Inf)))
xx                    = fdbk_dt_conttable_2thrs(DT,thrs,by=c("veri_model","veri_forecast_time","varno"),cores=2,incores=3)
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=veri_forecast_time,y=csi,group=interaction(veri_model,thr),linetype=veri_model,color=thr))+
geom_line()+
facet_grid(~varno)+
ggtitle("CSI")

rfxf/Rfdbk documentation built on Dec. 17, 2018, 9:14 a.m.