From 849f1db3053e27a2879542ffebddb55909ce26ae Mon Sep 17 00:00:00 2001 From: Jason Stover Date: Mon, 23 Feb 2009 11:14:45 -0500 Subject: [PATCH] Fix bug 25677 --- src/language/stats/regression.q | 4 ++-- src/math/linreg.c | 5 +++++ src/math/linreg.h | 1 + tests/command/regression-qr.sh | 2 +- tests/command/regression.sh | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 1d31d184..19aa0ee3 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -148,7 +148,7 @@ reg_stats_r (pspp_linreg_cache * c) 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); @@ -281,7 +281,7 @@ reg_stats_anova (pspp_linreg_cache * c) 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); diff --git a/src/math/linreg.c b/src/math/linreg.c index 2fb98cf7..609a78b6 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -741,3 +741,8 @@ pspp_linreg_with_cov (const struct design_matrix *full_cov, covariance_matrix_destroy (cov); } +double pspp_linreg_mse (const pspp_linreg_cache *c) +{ + assert (c != NULL); + return (c->sse / c->dfe); +} diff --git a/src/math/linreg.h b/src/math/linreg.h index 05c81596..3b19e53a 100644 --- a/src/math/linreg.h +++ b/src/math/linreg.h @@ -214,4 +214,5 @@ void pspp_linreg_set_indep_variable_sd (pspp_linreg_cache *, const struct variab */ double pspp_linreg_get_indep_variable_mean (pspp_linreg_cache *, const struct variable *); void pspp_linreg_set_indep_variable_mean (pspp_linreg_cache *, const struct variable *, double); +double pspp_linreg_mse (const pspp_linreg_cache *); #endif diff --git a/tests/command/regression-qr.sh b/tests/command/regression-qr.sh index b90402d7..5f4936d8 100755 --- a/tests/command/regression-qr.sh +++ b/tests/command/regression-qr.sh @@ -1582,7 +1582,7 @@ diff -b $TEMPDIR/pspp.list - << EOF #============#========#=================#==========================# # R #R Square|Adjusted R Square|Std. Error of the Estimate# #========#===#========#=================#==========================# -# |.05# .00| .00| .00# +# |.05# .00| .00| 8.11# #========#===#========#=================#==========================# 2.2 REGRESSION. ANOVA #===================#==============#====#===========#=====#============# diff --git a/tests/command/regression.sh b/tests/command/regression.sh index db33445e..a8e1942e 100755 --- a/tests/command/regression.sh +++ b/tests/command/regression.sh @@ -95,7 +95,7 @@ diff -b $TEMPDIR/pspp.list - << EOF #============#========#=================#==========================# # R #R Square|Adjusted R Square|Std. Error of the Estimate# #========#===#========#=================#==========================# -# |.97# .94| .93| .33# +# |.97# .94| .93| 1.34# #========#===#========#=================#==========================# 2.2 REGRESSION. ANOVA #===================#==============#==#===========#======#============# -- 2.30.2