Skip to content

Commit

Permalink
Per #2147, updates to the vx_statistics library to compute HSS_EC for…
Browse files Browse the repository at this point in the history
… the CTS line type.
  • Loading branch information
JohnHalleyGotway committed May 25, 2022
1 parent adc6759 commit 66236bd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 55 deletions.
30 changes: 27 additions & 3 deletions src/libcode/vx_statistics/compute_ci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@ void compute_cts_stats_ci_bca(const gsl_rng *rng_ptr,
cts_info[i].hss.v_bcl[j],
cts_info[i].hss.v_bcu[j]);

//
// Compute bootstrap interval for hss_ec
//
s = cts_info[i].hss_ec.v;
read_ldf(cts_i_file[i], c, si_na);
read_ldf(cts_r_file[i], c++, sr_na);
for(j=0; j<cts_info[i].n_alpha; j++)
compute_bca_interval(s, si_na, sr_na,
cts_info[i].alpha[j],
cts_info[i].hss_ec.v_bcl[j],
cts_info[i].hss_ec.v_bcu[j]);

//
// Compute bootstrap interval for odds
//
Expand Down Expand Up @@ -1664,6 +1676,17 @@ void compute_cts_stats_ci_perc(const gsl_rng *rng_ptr,
cts_info[i].hss.v_bcl[j],
cts_info[i].hss.v_bcu[j]);

//
// Compute bootstrap interval for hss_ec
//
s = cts_info[i].hss_ec.v;
read_ldf(cts_r_file[i], c++, sr_na);
for(j=0; j<cts_info[i].n_alpha; j++)
compute_perc_interval(s, sr_na,
cts_info[i].alpha[j],
cts_info[i].hss_ec.v_bcl[j],
cts_info[i].hss_ec.v_bcu[j]);

//
// Compute bootstrap interval for odds
//
Expand Down Expand Up @@ -3923,12 +3946,13 @@ void write_ctsinfo(ofstream &tmp_out, const CTSInfo &c) {
char line[max_line_len];

snprintf(line, max_line_len,
"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
c.baser.v, c.fmean.v, c.acc.v, c.fbias.v,
c.pody.v, c.podn.v, c.pofd.v, c.far.v,
c.csi.v, c.gss.v, c.hk.v, c.hss.v,
c.odds.v, c.lodds.v, c.orss.v, c.eds.v,
c.seds.v, c.edi.v, c.sedi.v, c.bagss.v
c.hss_ec.v, c.odds.v, c.lodds.v, c.orss.v,
c.eds.v, c.seds.v, c.edi.v, c.sedi.v,
c.bagss.v
);

tmp_out << line << "\n";
Expand Down
20 changes: 10 additions & 10 deletions src/libcode/vx_statistics/contable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,6 @@ void ContingencyTable::set_size(int N)

ContingencyTable::set_size(N, N);

//
// if square, set default expected correct value
//

if ( N > 0 ) {

ECvalue = 1.0 / N;

}

return;

}
Expand Down Expand Up @@ -514,6 +504,16 @@ E->resize(n, 0);
Nrows = NR;
Ncols = NC;

//
// if square, set default expected correct value
//

if ( Nrows == Ncols ) {

ECvalue = 1.0 / Nrows;

}

//
// done
//
Expand Down
87 changes: 46 additions & 41 deletions src/libcode/vx_statistics/met_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void CTSInfo::clear() {
bagss.clear();
hk.clear();
hss.clear();
hss_ec.clear();
odds.clear();
lodds.clear();
orss.clear();
Expand Down Expand Up @@ -270,6 +271,7 @@ void CTSInfo::assign(const CTSInfo &c) {
bagss = c.bagss;
hk = c.hk;
hss = c.hss;
hss_ec = c.hss_ec;
odds = c.odds;
lodds = c.lodds;
orss = c.orss;
Expand Down Expand Up @@ -310,6 +312,7 @@ void CTSInfo::allocate_n_alpha(int i) {
bagss.allocate_n_alpha(n_alpha);
hk.allocate_n_alpha(n_alpha);
hss.allocate_n_alpha(n_alpha);
hss_ec.allocate_n_alpha(n_alpha);
odds.allocate_n_alpha(n_alpha);
lodds.allocate_n_alpha(n_alpha);
orss.allocate_n_alpha(n_alpha);
Expand Down Expand Up @@ -345,26 +348,27 @@ void CTSInfo::add(double f, double o, double cmn, double csd) {

void CTSInfo::compute_stats() {

baser.v = cts.oy_tp();
fmean.v = cts.fy_tp();
acc.v = cts.accuracy();
fbias.v = cts.fbias();
pody.v = cts.pod_yes();
podn.v = cts.pod_no();
pofd.v = cts.pofd();
far.v = cts.far();
csi.v = cts.csi();
gss.v = cts.gss();
bagss.v = cts.bagss();
hk.v = cts.hk();
hss.v = cts.hss();
odds.v = cts.odds();
lodds.v = cts.lodds();
orss.v = cts.orss();
eds.v = cts.eds();
seds.v = cts.seds();
edi.v = cts.edi();
sedi.v = cts.sedi();
baser.v = cts.oy_tp();
fmean.v = cts.fy_tp();
acc.v = cts.accuracy();
fbias.v = cts.fbias();
pody.v = cts.pod_yes();
podn.v = cts.pod_no();
pofd.v = cts.pofd();
far.v = cts.far();
csi.v = cts.csi();
gss.v = cts.gss();
bagss.v = cts.bagss();
hk.v = cts.hk();
hss.v = cts.hss();
hss_ec.v = cts.gheidke_ec(cts.ec_value());
odds.v = cts.odds();
lodds.v = cts.lodds();
orss.v = cts.orss();
eds.v = cts.eds();
seds.v = cts.seds();
edi.v = cts.edi();
sedi.v = cts.sedi();

return;
}
Expand Down Expand Up @@ -432,27 +436,28 @@ double CTSInfo::get_stat(const char *stat_name) {
double v = bad_data_double;

// Find the statistic by name
if(strcmp(stat_name, "TOTAL") == 0) v = cts.n();
else if(strcmp(stat_name, "BASER") == 0) v = cts.baser();
else if(strcmp(stat_name, "FMEAN") == 0) v = cts.fmean();
else if(strcmp(stat_name, "ACC" ) == 0) v = cts.accuracy();
else if(strcmp(stat_name, "FBIAS") == 0) v = cts.fbias();
else if(strcmp(stat_name, "PODY" ) == 0) v = cts.pod_yes();
else if(strcmp(stat_name, "PODN" ) == 0) v = cts.pod_no();
else if(strcmp(stat_name, "POFD" ) == 0) v = cts.pofd();
else if(strcmp(stat_name, "FAR" ) == 0) v = cts.far();
else if(strcmp(stat_name, "CSI" ) == 0) v = cts.csi();
else if(strcmp(stat_name, "GSS" ) == 0) v = cts.gss();
else if(strcmp(stat_name, "HK" ) == 0) v = cts.hk();
else if(strcmp(stat_name, "HSS" ) == 0) v = cts.hss();
else if(strcmp(stat_name, "ODDS" ) == 0) v = cts.odds();
else if(strcmp(stat_name, "LODDS") == 0) v = cts.lodds();
else if(strcmp(stat_name, "ORSS" ) == 0) v = cts.orss();
else if(strcmp(stat_name, "EDS" ) == 0) v = cts.eds();
else if(strcmp(stat_name, "SEDS" ) == 0) v = cts.seds();
else if(strcmp(stat_name, "EDI" ) == 0) v = cts.edi();
else if(strcmp(stat_name, "SEDI" ) == 0) v = cts.sedi();
else if(strcmp(stat_name, "BAGSS") == 0) v = cts.bagss();
if(strcmp(stat_name, "TOTAL" ) == 0) v = cts.n();
else if(strcmp(stat_name, "BASER" ) == 0) v = cts.baser();
else if(strcmp(stat_name, "FMEAN" ) == 0) v = cts.fmean();
else if(strcmp(stat_name, "ACC" ) == 0) v = cts.accuracy();
else if(strcmp(stat_name, "FBIAS" ) == 0) v = cts.fbias();
else if(strcmp(stat_name, "PODY" ) == 0) v = cts.pod_yes();
else if(strcmp(stat_name, "PODN" ) == 0) v = cts.pod_no();
else if(strcmp(stat_name, "POFD" ) == 0) v = cts.pofd();
else if(strcmp(stat_name, "FAR" ) == 0) v = cts.far();
else if(strcmp(stat_name, "CSI" ) == 0) v = cts.csi();
else if(strcmp(stat_name, "GSS" ) == 0) v = cts.gss();
else if(strcmp(stat_name, "HK" ) == 0) v = cts.hk();
else if(strcmp(stat_name, "HSS" ) == 0) v = cts.hss();
else if(strcmp(stat_name, "HSS_EC") == 0) v = cts.gheidke_ec(cts.ec_value());
else if(strcmp(stat_name, "ODDS" ) == 0) v = cts.odds();
else if(strcmp(stat_name, "LODDS" ) == 0) v = cts.lodds();
else if(strcmp(stat_name, "ORSS" ) == 0) v = cts.orss();
else if(strcmp(stat_name, "EDS" ) == 0) v = cts.eds();
else if(strcmp(stat_name, "SEDS" ) == 0) v = cts.seds();
else if(strcmp(stat_name, "EDI" ) == 0) v = cts.edi();
else if(strcmp(stat_name, "SEDI" ) == 0) v = cts.sedi();
else if(strcmp(stat_name, "BAGSS" ) == 0) v = cts.bagss();
else {
mlog << Error << "\nCTSInfo::get_stat() -> "
<< "unknown categorical statistic name \"" << stat_name
Expand Down
2 changes: 1 addition & 1 deletion src/libcode/vx_statistics/met_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CTSInfo {

CIInfo baser, fmean, acc, fbias;
CIInfo pody, podn, pofd;
CIInfo far, csi, gss, bagss, hk, hss, odds;
CIInfo far, csi, gss, bagss, hk, hss, hss_ec, odds;
CIInfo lodds, orss, eds, seds, edi, sedi;

void clear();
Expand Down

0 comments on commit 66236bd

Please sign in to comment.