projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fh_get_identity: Remove incorrect statement from comment.
[pspp]
/
src
/
language
/
stats
/
roc.c
diff --git
a/src/language/stats/roc.c
b/src/language/stats/roc.c
index 471b946ee817b17124836b4f601d9358fbd833cf..d011bf547e7a20fd4ab4acf9699d6e0db941ab99 100644
(file)
--- a/
src/language/stats/roc.c
+++ b/
src/language/stats/roc.c
@@
-49,6
+49,7
@@
struct cmd_roc
const struct variable *state_var;
union value state_value;
const struct variable *state_var;
union value state_value;
+ size_t state_var_width;
/* Plot the roc curve */
bool curve;
/* Plot the roc curve */
bool curve;
@@
-94,6
+95,7
@@
cmd_roc (struct lexer *lexer, struct dataset *ds)
roc.neg = roc.neg_weighted = 0;
roc.dict = dataset_dict (ds);
roc.state_var = NULL;
roc.neg = roc.neg_weighted = 0;
roc.dict = dataset_dict (ds);
roc.state_var = NULL;
+ roc.state_var_width = -1;
lex_match (lexer, T_SLASH);
if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars,
lex_match (lexer, T_SLASH);
if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars,
@@
-112,7
+114,8
@@
cmd_roc (struct lexer *lexer, struct dataset *ds)
goto error;
}
goto error;
}
- value_init (&roc.state_value, var_get_width (roc.state_var));
+ roc.state_var_width = var_get_width (roc.state_var);
+ value_init (&roc.state_value, roc.state_var_width);
parse_value (lexer, &roc.state_value, roc.state_var);
parse_value (lexer, &roc.state_value, roc.state_var);
@@
-121,7
+124,6
@@
cmd_roc (struct lexer *lexer, struct dataset *ds)
goto error;
}
goto error;
}
-
while (lex_token (lexer) != T_ENDCMD)
{
lex_match (lexer, T_SLASH);
while (lex_token (lexer) != T_ENDCMD)
{
lex_match (lexer, T_SLASH);
@@
-272,13
+274,14
@@
cmd_roc (struct lexer *lexer, struct dataset *ds)
if ( ! run_roc (ds, &roc))
goto error;
if ( ! run_roc (ds, &roc))
goto error;
- value_destroy (&roc.state_value, var_get_width (roc.state_var));
+ if ( roc.state_var)
+ value_destroy (&roc.state_value, roc.state_var_width);
free (roc.vars);
return CMD_SUCCESS;
error:
if ( roc.state_var)
free (roc.vars);
return CMD_SUCCESS;
error:
if ( roc.state_var)
- value_destroy (&roc.state_value,
var_get_width (roc.state_var)
);
+ value_destroy (&roc.state_value,
roc.state_var_width
);
free (roc.vars);
return CMD_FAILURE;
}
free (roc.vars);
return CMD_FAILURE;
}
@@
-996,7
+999,7
@@
show_auc (struct roc_state *rs, const struct cmd_roc *roc)
{
tab_text (tbl, 0, 2 + i, TAT_TITLE, var_to_string (roc->vars[i]));
{
tab_text (tbl, 0, 2 + i, TAT_TITLE, var_to_string (roc->vars[i]));
- tab_double (tbl, n_cols - n_fields, 2 + i, 0, rs[i].auc, NULL);
+ tab_double (tbl, n_cols - n_fields, 2 + i, 0, rs[i].auc, NULL
, RC_OTHER
);
if ( roc->print_se )
{
if ( roc->print_se )
{
@@
-1015,22
+1018,22
@@
show_auc (struct roc_state *rs, const struct cmd_roc *roc)
tab_double (tbl, n_cols - 4, 2 + i, 0,
se,
tab_double (tbl, n_cols - 4, 2 + i, 0,
se,
- NULL);
+ NULL
, RC_OTHER
);
ci = 1 - roc->ci / 100.0;
yy = gsl_cdf_gaussian_Qinv (ci, se) ;
tab_double (tbl, n_cols - 2, 2 + i, 0,
rs[i].auc - yy,
ci = 1 - roc->ci / 100.0;
yy = gsl_cdf_gaussian_Qinv (ci, se) ;
tab_double (tbl, n_cols - 2, 2 + i, 0,
rs[i].auc - yy,
- NULL);
+ NULL
, RC_OTHER
);
tab_double (tbl, n_cols - 1, 2 + i, 0,
rs[i].auc + yy,
tab_double (tbl, n_cols - 1, 2 + i, 0,
rs[i].auc + yy,
- NULL);
+ NULL
, RC_OTHER
);
tab_double (tbl, n_cols - 3, 2 + i, 0,
2.0 * gsl_cdf_ugaussian_Q (fabs ((rs[i].auc - 0.5 ) / sd_0_5)),
tab_double (tbl, n_cols - 3, 2 + i, 0,
2.0 * gsl_cdf_ugaussian_Q (fabs ((rs[i].auc - 0.5 ) / sd_0_5)),
- NULL);
+ NULL
, RC_PVALUE
);
}
}
}
}
@@
-1077,11
+1080,11
@@
show_summary (const struct cmd_roc *roc)
tab_text (tbl, 0, 3, TAB_LEFT, _("Negative"));
tab_text (tbl, 0, 3, TAB_LEFT, _("Negative"));
- tab_double (tbl, 1, 2, 0, roc->pos,
&F_8_0
);
- tab_double (tbl, 1, 3, 0, roc->neg,
&F_8_0
);
+ tab_double (tbl, 1, 2, 0, roc->pos,
NULL, RC_INTEGER
);
+ tab_double (tbl, 1, 3, 0, roc->neg,
NULL, RC_INTEGER
);
- tab_double (tbl, 2, 2, 0, roc->pos_weighted,
0
);
- tab_double (tbl, 2, 3, 0, roc->neg_weighted,
0
);
+ tab_double (tbl, 2, 2, 0, roc->pos_weighted,
NULL, RC_OTHER
);
+ tab_double (tbl, 2, 3, 0, roc->neg_weighted,
NULL, RC_OTHER
);
tab_submit (tbl);
}
tab_submit (tbl);
}
@@
-1158,10
+1161,10
@@
show_coords (struct roc_state *rs, const struct cmd_roc *roc)
);
tab_double (tbl, n_cols - 3, x, 0, case_data_idx (cc, ROC_CUTPOINT)->f,
);
tab_double (tbl, n_cols - 3, x, 0, case_data_idx (cc, ROC_CUTPOINT)->f,
- var_get_print_format (roc->vars[i]));
+ var_get_print_format (roc->vars[i])
, RC_OTHER
);
- tab_double (tbl, n_cols - 2, x, 0, se, NULL);
- tab_double (tbl, n_cols - 1, x, 0, 1 - sp, NULL);
+ tab_double (tbl, n_cols - 2, x, 0, se, NULL
, RC_OTHER
);
+ tab_double (tbl, n_cols - 1, x, 0, 1 - sp, NULL
, RC_OTHER
);
}
casereader_destroy (r);
}
casereader_destroy (r);