projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Closes patch #6359
[pspp-builds.git]
/
src
/
language
/
stats
/
regression.q
diff --git
a/src/language/stats/regression.q
b/src/language/stats/regression.q
index 12a7cf5efca6ed103957768c9032bec9d1f611aa..bed4f79dae561bfae4ac2a57e6205f1c33ac10e5 100644
(file)
--- a/
src/language/stats/regression.q
+++ b/
src/language/stats/regression.q
@@
-191,14
+191,12
@@
reg_stats_coeff (pspp_linreg_cache * c)
double std_err;
double beta;
const char *label;
double std_err;
double beta;
const char *label;
- char *tmp;
+
const struct variable *v;
const union value *val;
const struct variable *v;
const union value *val;
- const char *val_s;
struct tab_table *t;
assert (c != NULL);
struct tab_table *t;
assert (c != NULL);
- tmp = xnmalloc (MAX_STRING, sizeof (*tmp));
n_rows = c->n_coeffs + 2;
t = tab_create (n_cols, n_rows, 0);
n_rows = c->n_coeffs + 2;
t = tab_create (n_cols, n_rows, 0);
@@
-227,10
+225,13
@@
reg_stats_coeff (pspp_linreg_cache * c)
tab_float (t, 6, 1, 0, pval, 10, 2);
for (j = 1; j <= c->n_indeps; j++)
{
tab_float (t, 6, 1, 0, pval, 10, 2);
for (j = 1; j <= c->n_indeps; j++)
{
+ struct string tstr;
+ ds_init_empty (&tstr);
+
v = pspp_coeff_get_var (c->coeff[j], 0);
label = var_to_string (v);
/* Do not overwrite the variable's name. */
v = pspp_coeff_get_var (c->coeff[j], 0);
label = var_to_string (v);
/* Do not overwrite the variable's name. */
-
strncpy (tmp, label, MAX_STRING
);
+
ds_put_cstr (&tstr, label
);
if (var_is_alpha (v))
{
/*
if (var_is_alpha (v))
{
/*
@@
-240,11
+241,11
@@
reg_stats_coeff (pspp_linreg_cache * c)
*/
val = pspp_coeff_get_value (c->coeff[j], v);
*/
val = pspp_coeff_get_value (c->coeff[j], v);
- val_s = var_get_value_name (v, val);
-
strncat (tmp, val_s, MAX_STRING
);
+
+
var_append_value_name (v, val, &tstr
);
}
}
- tab_text (t, 1, j + 1, TAB_CENTER,
tmp
);
+ tab_text (t, 1, j + 1, TAB_CENTER,
ds_cstr (&tstr)
);
/*
Regression coefficients.
*/
/*
Regression coefficients.
*/
@@
-275,10
+276,10
@@
reg_stats_coeff (pspp_linreg_cache * c)
2 * gsl_cdf_tdist_Q (fabs (t_stat),
(double) (c->n_obs - c->n_coeffs));
tab_float (t, 6, j + 1, 0, pval, 10, 2);
2 * gsl_cdf_tdist_Q (fabs (t_stat),
(double) (c->n_obs - c->n_coeffs));
tab_float (t, 6, j + 1, 0, pval, 10, 2);
+ ds_destroy (&tstr);
}
tab_title (t, _("Coefficients"));
tab_submit (t);
}
tab_title (t, _("Coefficients"));
tab_submit (t);
- free (tmp);
}
/*
}
/*
@@
-782,10
+783,15
@@
reg_print_categorical_encoding (FILE * fp, pspp_linreg_cache * c)
for (j = 0; j < n_categories; j++)
{
for (j = 0; j < n_categories; j++)
{
+ struct string vstr;
const union value *val = cat_subscript_to_value (j, varlist[i]);
const union value *val = cat_subscript_to_value (j, varlist[i]);
+ ds_init_empty (&vstr);
+ var_append_value_name (varlist[i], val, &vstr);
fprintf (fp, "%s.values[%d] = \"%s\";\n\t",
var_get_name (varlist[i]), j,
fprintf (fp, "%s.values[%d] = \"%s\";\n\t",
var_get_name (varlist[i]), j,
- var_get_value_name (varlist[i], val));
+ ds_cstr (&vstr));
+
+ ds_destroy (&vstr);
}
}
fprintf (fp, "%s", reg_export_categorical_encode_2);
}
}
fprintf (fp, "%s", reg_export_categorical_encode_2);