double std_error;
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);
+ rsq = linreg_ssreg (c) / linreg_sst (c);
+ adjrsq = 1.0 - (1.0 - rsq) * (linreg_n_obs (c) - 1.0) / (linreg_n_obs (c) - linreg_n_coeffs (c));
std_error = sqrt (linreg_mse (c));
t = tab_create (n_cols, n_rows, 0);
tab_dim (t, tab_natural_dimensions, NULL);
tab_text (t, 1, 3, TAB_LEFT | TAT_TITLE, _("Total"));
/* Sums of Squares */
- tab_double (t, 2, 1, 0, c->ssm, NULL);
- tab_double (t, 2, 3, 0, c->sst, NULL);
- tab_double (t, 2, 2, 0, c->sse, NULL);
+ tab_double (t, 2, 1, 0, linreg_ssreg (c), NULL);
+ tab_double (t, 2, 3, 0, linreg_sst (c), NULL);
+ tab_double (t, 2, 2, 0, linreg_sse (c), NULL);
/* Degrees of freedom */
result = gsl_matrix_get (ssizes, rows[i], dep_subscript);
}
}
+ gsl_matrix_set (cov, cov->size1 - 1, cov->size1 - 1,
+ gsl_matrix_get (cm, dep_subscript, dep_subscript));
free (rows);
return result;
}
linreg *c;
size_t i;
- c = xmalloc (sizeof (linreg));
+ c = xmalloc (sizeof (*c));
c->depvar = depvar;
c->indep_vars = xnmalloc (p, sizeof (*indep_vars));
for (i = 0; i < p; i++)
Default settings.
*/
c->method = LINREG_SWEEP;
- c->resid = NULL; /* The variable storing my residuals. */
- c->pred = NULL; /* The variable storing my predicted values. */
+ c->pred = NULL;
+ c->resid = NULL;
return c;
}
params = gsl_matrix_calloc (cov->size1, cov->size2);
gsl_matrix_memcpy (params, cov);
+ l->sst = gsl_matrix_get (cov, cov->size1 - 1, cov->size2 - 1);
if (l->method == LINREG_SWEEP)
{
return c->n_obs;
}
+double
+linreg_sse (const linreg *c)
+{
+ return c->sse;
+}
+
double
linreg_ssreg (const linreg *c)
{
- return c->ssm;
+ return (c->sst - c->sse);
+}
+
+double linreg_sst (const linreg *c)
+{
+ return c->sst;
}
double
*/
gsl_matrix *hat;
- struct variable *resid;
struct variable *pred;
-
+ struct variable *resid;
};
typedef struct linreg_struct linreg;
const struct variable * linreg_indep_var (const linreg *, size_t);
size_t linreg_n_coeffs (const linreg *);
size_t linreg_n_obs (const linreg *);
+double linreg_sse (const linreg *);
double linreg_ssreg (const linreg *);
double linreg_dfmodel (const linreg *);
+double linreg_sst (const linreg *);
#endif