for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += X[i] * row_tot[i];
- sum_X2r += X[i] * X[i] * row_tot[i];
+ sum_X2r += pow2 (X[i]) * row_tot[i];
}
Xbar = sum_Xr / W;
Ybar = sum_Yc / W;
S = sum_XYf - sum_Xr * sum_Yc / W;
- SX = sum_X2r - sum_Xr * sum_Xr / W;
- SY = sum_Y2c - sum_Yc * sum_Yc / W;
+ SX = sum_X2r - pow2 (sum_Xr) / W;
+ SY = sum_Y2c - pow2 (sum_Yc) / W;
T = sqrt (SX * SY);
*r = S / T;
- *ase_0 = sqrt ((sum_X2Y2f - (sum_XYf * sum_XYf) / W) / (sum_X2r * sum_Y2c));
+ *ase_0 = sqrt ((sum_X2Y2f - pow2 (sum_XYf) / W) / (sum_X2r * sum_Y2c));
{
double s, c, y, t;
Dr = Dc = W * W;
for (r = 0; r < n_rows; r++)
- Dr -= row_tot[r] * row_tot[r];
+ Dr -= pow2 (row_tot[r]);
for (c = 0; c < n_cols; c++)
- Dc -= col_tot[c] * col_tot[c];
+ Dc -= pow2 (col_tot[c]);
}
{
}
for (sum_ri2 = 0., i = 0; i < n_rows; i++)
- sum_ri2 += row_tot[i] * row_tot[i];
+ sum_ri2 += pow2 (row_tot[i]);
for (sum_cj2 = 0., j = 0; j < n_cols; j++)
- sum_cj2 += col_tot[j] * col_tot[j];
+ sum_cj2 += pow2 (col_tot[j]);
v[3] = (W * sum_fij2_ci - sum_ri2) / (W * W - sum_ri2);
v[4] = (W * sum_fij2_ri - sum_cj2) / (W * W - sum_cj2);
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += rows[i].f * row_tot[i];
- sum_X2r += rows[i].f * rows[i].f * row_tot[i];
+ sum_X2r += pow2 (rows[i].f) * row_tot[i];
}
- SX = sum_X2r - sum_Xr * sum_Xr / W;
+ SX = sum_X2r - pow2 (sum_Xr) / W;
for (SXW = 0., j = 0; j < n_cols; j++)
{
for (cum = 0., i = 0; i < n_rows; i++)
{
- SXW += rows[i].f * rows[i].f * mat[j + i * n_cols];
+ SXW += pow2 (rows[i].f) * mat[j + i * n_cols];
cum += rows[i].f * mat[j + i * n_cols];
}
for (sum_Yc = sum_Y2c = 0., i = 0; i < n_cols; i++)
{
sum_Yc += cols[i].f * col_tot[i];
- sum_Y2c += cols[i].f * cols[i].f * col_tot[i];
+ sum_Y2c += pow2 (cols[i].f) * col_tot[i];
}
SY = sum_Y2c - sum_Yc * sum_Yc / W;
for (cum = 0., j = 0; j < n_cols; j++)
{
- SYW += cols[j].f * cols[j].f * mat[j + i * n_cols];
+ SYW += pow2 (cols[j].f) * mat[j + i * n_cols];
cum += cols[j].f * mat[j + i * n_cols];
}
struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
struct hsh_iterator g;
struct group_statistics *gs;
- double ssa=0;
+ double ssa = 0;
const char *s = var_to_string(vars[i]);
for (gs = hsh_first (group_hash,&g);
gs != 0;
gs = hsh_next(group_hash,&g))
{
- ssa += (gs->sum * gs->sum)/gs->n;
+ ssa += pow2 (gs->sum) / gs->n;
}
- ssa -= ( totals->sum * totals->sum ) / totals->n ;
+ ssa -= pow2 (totals->sum) / totals->n;
tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
{
struct group_proc *gp = group_proc_get (vars[i]);
- const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
+ const double sst = totals->ssq - pow2 (totals->sum) / totals->n ;
const double df1 = gp->n_groups - 1;
const double df2 = totals->n - gp->n_groups ;
const double msa = ssa / df1;
tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
-
{
const double F = msa/gp->mse ;
/* The significance */
tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
}
-
}
-
}
tab_float (t, 2, row + count, 0, gs->n, 8,0);
- tab_float (t, 3, row + count, 0, gs->mean,8,2);
+ tab_float (t, 3, row + count, 0, gs->mean, 8, 2);
- tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
+ tab_float (t, 4, row + count, 0, gs->std_dev, 8, 2);
std_error = gs->std_dev/sqrt(gs->n) ;
tab_float (t, 5, row + count, 0,
- std_error, 8,2);
+ std_error, 8, 2);
/* Now the confidence interval */
- T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
+ T = gsl_cdf_tdist_Qinv(q, gs->n - 1);
tab_float(t, 6, row + count, 0,
gs->mean - T * std_error, 8, 2);
const double coef = subc_list_double_at(&cmd.dl_contrast[i], ci);
struct group_statistics *gs = group_stat_array[ci];
- const double winv = (gs->std_dev * gs->std_dev) / gs->n;
+ const double winv = pow2 (gs->std_dev) / gs->n;
contrast_value += coef * gs->mean;
coef_msq += (coef * coef) / gs->n ;
- sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
+ sec_vneq += (coef * coef) * pow2 (gs->std_dev) /gs->n ;
df_numerator += (coef * coef) * winv;
df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
cmd.sbc_contrast,
TAB_RIGHT, contrast_value, 8,2);
- std_error_contrast = sqrt(grp_data->mse * coef_msq);
+ std_error_contrast = sqrt (grp_data->mse * coef_msq);
/* Std. Error */
tab_float (t, 4, (v * lines_per_variable) + i + 1,
{
struct group_statistics *totals = &gp->ugs;
- totals->n+=weight;
- totals->sum+=weight * val->f;
- totals->ssq+=weight * val->f * val->f;
+ totals->n += weight;
+ totals->sum += weight * val->f;
+ totals->ssq += weight * pow2 (val->f);
if ( val->f * weight < totals->minimum )
totals->minimum = val->f * weight;
if ( val->f * weight > totals->maximum )
totals->maximum = val->f * weight;
- gs->n+=weight;
- gs->sum+=weight * val->f;
- gs->ssq+=weight * val->f * val->f;
+ gs->n += weight;
+ gs->sum += weight * val->f;
+ gs->ssq += weight * pow2 (val->f);
if ( val->f * weight < gs->minimum )
gs->minimum = val->f * weight;
gs != 0;
gs = hsh_next(group_hash,&g))
{
- gs->mean=gs->sum / gs->n;
+ gs->mean = gs->sum / gs->n;
gs->s_std_dev= sqrt(
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ gs->ssq / gs->n - pow2 (gs->mean)
) ;
gs->std_dev= sqrt(
- gs->n/(gs->n-1) *
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ gs->n / (gs->n - 1) *
+ ( gs->ssq / gs->n - pow2 (gs->mean))
) ;
- gs->se_mean = gs->std_dev / sqrt(gs->n);
- gs->mean_diff= gs->sum_diff / gs->n;
-
+ gs->se_mean = gs->std_dev / sqrt (gs->n);
+ gs->mean_diff = gs->sum_diff / gs->n;
}
-
-
totals->mean = totals->sum / totals->n;
totals->std_dev= sqrt(
- totals->n/(totals->n-1) *
- ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
+ totals->n / (totals->n - 1) *
+ (totals->ssq / totals->n - pow2 (totals->mean))
) ;
- totals->se_mean = totals->std_dev / sqrt(totals->n);
-
+ totals->se_mean = totals->std_dev / sqrt (totals->n);
}
}