#include <libpspp/taint.h>
#include <math/design-matrix.h>
#include <math/coefficient.h>
-#include <math/linreg/linreg.h>
+#include <math/linreg.h>
#include <math/moments.h>
#include <output/table.h>
assert (c != NULL);
rsq = c->ssm / c->sst;
adjrsq = 1.0 - (1.0 - rsq) * (c->n_obs - 1.0) / (c->n_obs - c->n_indeps);
- std_error = sqrt ((c->n_indeps - 1.0) / (c->n_obs - 1.0));
+ std_error = sqrt (pspp_linreg_mse (c));
t = tab_create (n_cols, n_rows, 0);
tab_dim (t, tab_natural_dimensions);
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
int this_row;
double t_stat;
double pval;
- double coeff;
double std_err;
double beta;
const char *label;
tab_float (t, 2, 1, 0, c->intercept, 10, 2);
std_err = sqrt (gsl_matrix_get (c->cov, 0, 0));
tab_float (t, 3, 1, 0, std_err, 10, 2);
- beta = c->intercept / c->depvar_std;
- tab_float (t, 4, 1, 0, beta, 10, 2);
+ tab_float (t, 4, 1, 0, 0.0, 10, 2);
t_stat = c->intercept / std_err;
tab_float (t, 5, 1, 0, t_stat, 10, 2);
pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), 1.0);
tab_float (t, 6, 1, 0, pval, 10, 2);
for (j = 0; j < c->n_coeffs; j++)
{
- this_row = j + 2;
struct string tstr;
ds_init_empty (&tstr);
+ this_row = j + 2;
v = pspp_coeff_get_var (c->coeff[j], 0);
label = var_to_string (v);
/*
Regression coefficients.
*/
- coeff = c->coeff[j]->estimate;
- tab_float (t, 2, this_row, 0, coeff, 10, 2);
+ tab_float (t, 2, this_row, 0, c->coeff[j]->estimate, 10, 2);
/*
Standard error of the coefficients.
*/
std_err = sqrt (gsl_matrix_get (c->cov, j + 1, j + 1));
tab_float (t, 3, this_row, 0, std_err, 10, 2);
/*
- 'Standardized' coefficient, i.e., regression coefficient
+ Standardized coefficient, i.e., regression coefficient
if all variables had unit variance.
*/
- beta = gsl_vector_get (c->indep_std, j + 1);
- beta *= coeff / c->depvar_std;
+ beta = pspp_coeff_get_sd (c->coeff[j]);
+ beta *= c->coeff[j]->estimate / c->depvar_std;
tab_float (t, 4, this_row, 0, beta, 10, 2);
/*
Test statistic for H0: coefficient is 0.
*/
- t_stat = coeff / std_err;
+ t_stat = c->coeff[j]->estimate / std_err;
tab_float (t, 5, this_row, 0, t_stat, 10, 2);
/*
P values for the test statistic above.
int n_cols = 7;
int n_rows = 4;
const double msm = c->ssm / c->dfm;
- const double mse = c->sse / c->dfe;
+ const double mse = pspp_linreg_mse (c);
const double F = msm / mse;
const double pval = gsl_cdf_fdist_Q (F, c->dfm, c->dfe);
/* Degrees of freedom */
- tab_float (t, 3, 1, 0, c->dfm, 4, 0);
- tab_float (t, 3, 2, 0, c->dfe, 4, 0);
- tab_float (t, 3, 3, 0, c->dft, 4, 0);
+ tab_text (t, 3, 1, TAB_RIGHT | TAT_PRINTF, "%g", c->dfm);
+ tab_text (t, 3, 2, TAB_RIGHT | TAT_PRINTF, "%g", c->dfe);
+ tab_text (t, 3, 3, TAB_RIGHT | TAT_PRINTF, "%g", c->dft);
/* Mean Squares */
-
tab_float (t, 4, 1, TAB_RIGHT, msm, 8, 3);
tab_float (t, 4, 2, TAB_RIGHT, mse, 8, 3);
tab_title (t, _("ANOVA"));
tab_submit (t);
}
+
static void
reg_stats_outs (pspp_linreg_cache * c)
{
assert (c != NULL);
}
+
static void
reg_stats_zpp (pspp_linreg_cache * c)
{
assert (c != NULL);
}
+
static void
reg_stats_label (pspp_linreg_cache * c)
{
assert (c != NULL);
}
+
static void
reg_stats_sha (pspp_linreg_cache * c)
{
for (i = 0; i < n_variables; i++)
if (!is_depvar (i, depvar))
indep_vars[n_indep_vars++] = v_variables[i];
- if ((n_indep_vars < 2) && is_depvar (0, depvar))
+ if ((n_indep_vars < 1) && is_depvar (0, depvar))
{
/*
There is only one independent variable, and it is the same
{
moments1_calculate ((mom + j)->m, &weight, &mean, &variance,
&skewness, &kurtosis);
- gsl_vector_set (c->indep_means, i, mean);
- gsl_vector_set (c->indep_std, i, sqrt (variance));
+ pspp_linreg_set_indep_variable_mean (c, (mom + j)->v, mean);
+ pspp_linreg_set_indep_variable_sd (c, (mom + j)->v, sqrt (variance));
}
}
}
/*
Find the least-squares estimates and other statistics.
*/
- pspp_linreg ((const gsl_vector *) Y, X->m, &lopts, models[k]);
- compute_moments (models[k], mom, X, n_variables);
+ pspp_linreg ((const gsl_vector *) Y, X, &lopts, models[k]);
if (!taint_has_tainted_successor (casereader_get_taint (input)))
{