151 |
struct tab_table *t; |
struct tab_table *t; |
152 |
|
|
153 |
assert (c != NULL); |
assert (c != NULL); |
154 |
n_rows = 2; |
n_rows = c->n_coeffs + 2; |
155 |
|
|
156 |
t = tab_create (n_cols, n_rows, 0); |
t = tab_create (n_cols, n_rows, 0); |
157 |
tab_headers (t, 2, 0, 1, 0); |
tab_headers (t, 2, 0, 1, 0); |
167 |
tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t")); |
tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t")); |
168 |
tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance")); |
tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance")); |
169 |
tab_text (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(Constant)")); |
tab_text (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(Constant)")); |
170 |
coeff = gsl_vector_get (c->param_estimates, 0); |
coeff = c->coeff[0].estimate; |
171 |
tab_float (t, 2, 1, 0, coeff, 10, 2); |
tab_float (t, 2, 1, 0, coeff, 10, 2); |
172 |
std_err = sqrt (gsl_matrix_get (c->cov, 0, 0)); |
std_err = sqrt (gsl_matrix_get (c->cov, 0, 0)); |
173 |
tab_float (t, 3, 1, 0, std_err, 10, 2); |
tab_float (t, 3, 1, 0, std_err, 10, 2); |
177 |
tab_float (t, 5, 1, 0, t_stat, 10, 2); |
tab_float (t, 5, 1, 0, t_stat, 10, 2); |
178 |
pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), 1.0); |
pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), 1.0); |
179 |
tab_float (t, 6, 1, 0, pval, 10, 2); |
tab_float (t, 6, 1, 0, pval, 10, 2); |
180 |
for (j = 0; j < c->n_indeps; j++) |
for (j = 1; j <= c->n_indeps; j++) |
181 |
{ |
{ |
182 |
i = indep_vars[j]; |
i = indep_vars[j]; |
183 |
struct variable *v = cmd.v_variables[i]; |
label = var_to_string (c->coeff[j].v); |
184 |
label = var_to_string (v); |
tab_text (t, 1, j + 1, TAB_CENTER, label); |
|
tab_text (t, 1, j + 2, TAB_CENTER, label); |
|
185 |
/* |
/* |
186 |
Regression coefficients. |
Regression coefficients. |
187 |
*/ |
*/ |
188 |
coeff = gsl_vector_get (c->param_estimates, j + 1); |
coeff = c->coeff[j].estimate; |
189 |
tab_float (t, 2, j + 2, 0, coeff, 10, 2); |
tab_float (t, 2, j + 1, 0, coeff, 10, 2); |
190 |
/* |
/* |
191 |
Standard error of the coefficients. |
Standard error of the coefficients. |
192 |
*/ |
*/ |
193 |
std_err = sqrt (gsl_matrix_get (c->cov, j + 1, j + 1)); |
std_err = sqrt (gsl_matrix_get (c->cov, j, j)); |
194 |
tab_float (t, 3, j + 2, 0, std_err, 10, 2); |
tab_float (t, 3, j + 1, 0, std_err, 10, 2); |
195 |
/* |
/* |
196 |
'Standardized' coefficient, i.e., regression coefficient |
'Standardized' coefficient, i.e., regression coefficient |
197 |
if all variables had unit variance. |
if all variables had unit variance. |
198 |
*/ |
*/ |
199 |
beta = gsl_vector_get (c->indep_std, j + 1); |
beta = gsl_vector_get (c->indep_std, j); |
200 |
beta *= coeff / c->depvar_std; |
beta *= coeff / c->depvar_std; |
201 |
tab_float (t, 4, j + 2, 0, beta, 10, 2); |
tab_float (t, 4, j + 1, 0, beta, 10, 2); |
202 |
|
|
203 |
/* |
/* |
204 |
Test statistic for H0: coefficient is 0. |
Test statistic for H0: coefficient is 0. |
205 |
*/ |
*/ |
206 |
t_stat = coeff / std_err; |
t_stat = coeff / std_err; |
207 |
tab_float (t, 5, j + 2, 0, t_stat, 10, 2); |
tab_float (t, 5, j + 1, 0, t_stat, 10, 2); |
208 |
/* |
/* |
209 |
P values for the test statistic above. |
P values for the test statistic above. |
210 |
*/ |
*/ |
211 |
pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), 1.0); |
pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), 1.0); |
212 |
tab_float (t, 6, j + 2, 0, pval, 10, 2); |
tab_float (t, 6, j + 1, 0, pval, 10, 2); |
213 |
} |
} |
214 |
tab_title (t, 0, _("Coefficients")); |
tab_title (t, 0, _("Coefficients")); |
215 |
tab_submit (t); |
tab_submit (t); |
607 |
j = i + 1; /* The first coeff is the intercept. */ |
j = i + 1; /* The first coeff is the intercept. */ |
608 |
lcache->coeff[j].v = |
lcache->coeff[j].v = |
609 |
(const struct variable *) design_matrix_col_to_var (X, i); |
(const struct variable *) design_matrix_col_to_var (X, i); |
610 |
|
assert (lcache->coeff[j].v != NULL); |
611 |
} |
} |
612 |
/* |
/* |
613 |
Find the least-squares estimates and other statistics. |
Find the least-squares estimates and other statistics. |