void
pspp_linreg_coeff_free (struct pspp_linreg_coeff *c)
{
+ free (c->v_info);
free (c);
}
struct pspp_linreg_coeff *coeff;
c->coeff = xnmalloc (X->m->size2 + 1, sizeof (*c->coeff));
+ c->coeff[0] = xmalloc (sizeof (*c->coeff[0]));
+ c->coeff[0]->v_info = NULL; /* Intercept has no associated variable. */
for (i = 0; i < X->m->size2; i++)
{
j = i + 1; /* The first coefficient is the intercept. */
- coeff = c->coeff + j;
+ c->coeff[j] = xmalloc (sizeof (*c->coeff[j]));
+ coeff = c->coeff[j];
coeff->n_vars = n_vals; /* Currently, no procedures allow
interactions. This line will have to
change when procedures that allow
interaction terms are written.
- */
+ */
coeff->v_info = xnmalloc (coeff->n_vars, sizeof (*coeff->v_info));
assert (coeff->v_info != NULL);
coeff->v_info->v =
}
/*
- Which variable does this coefficient match?
+ Which variable does this coefficient match? I should be
+ 0 unless the coefficient refers to an interaction term.
*/
const struct variable *
pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *c, int i)
{
return NULL;
}
- if (v->type == NULL)
+ if (v->type == NUMERIC)
{
return NULL;
}
{
return NULL;
}
- if (c->coeff == NULL || c->n_indeps == NULL || v == NULL)
+ if (c->coeff == NULL || c->n_indeps == 0 || v == NULL)
{
return NULL;
}
- result = c->coeff + i;
+ result = c->coeff[i];
tmp = pspp_linreg_coeff_get_var (result, 0);
while (tmp->index != v->index && i < c->n_coeffs)
{
- result = c->coeff + i;
+ result = c->coeff[i];
tmp = pspp_linreg_coeff_get_var (result, 0);
i++;
}
- if (i == c->n_coeffs)
+ if (i > c->n_coeffs)
{
return NULL;
}
val, v->width))
{ /* FIX THIS */
i++;
- result = c->coeff + i;
+ result = c->coeff[i];
tmp = pspp_linreg_coeff_get_var (result, 0);
}
if (i == c->n_coeffs)