From bad83ff5129a404a11ef8dd54fa198044c1be6d1 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 16 Apr 2011 09:52:34 -0700 Subject: [PATCH] CROSSTABS: Fix output of multiway statistics tables. Bug #27452. --- src/language/stats/crosstabs.q | 8 ++-- tests/language/stats/crosstabs.at | 63 ++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index b230702e..cf9473e8 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -1751,7 +1751,7 @@ display_chisq (struct pivot_table *pt, struct tab_table *chisq, calc_chisq (pt, chisq_v, df, &fisher1, &fisher2); - tab_offset (chisq, pt->n_vars - 2, -1); + tab_offset (chisq, pt->n_consts + pt->n_vars - 2, -1); for (i = 0; i < N_CHISQ; i++) { @@ -1828,7 +1828,7 @@ display_symmetric (struct crosstabs_proc *proc, struct pivot_table *pt, somers_d_v, somers_d_ase, somers_d_t)) return; - tab_offset (sym, pt->n_vars - 2, -1); + tab_offset (sym, pt->n_consts + pt->n_vars - 2, -1); for (i = 0; i < N_SYMMETRIC; i++) { @@ -1873,7 +1873,7 @@ display_risk (struct pivot_table *pt, struct tab_table *risk) if (!calc_risk (pt, risk_v, upper, lower, c)) return; - tab_offset (risk, pt->n_vars - 2, -1); + tab_offset (risk, pt->n_consts + pt->n_vars - 2, -1); for (i = 0; i < 3; i++) { @@ -1998,7 +1998,7 @@ display_directional (struct crosstabs_proc *proc, struct pivot_table *pt, if (!calc_directional (proc, pt, direct_v, direct_ase, direct_t)) return; - tab_offset (direct, pt->n_vars - 2, -1); + tab_offset (direct, pt->n_consts + pt->n_vars - 2, -1); for (i = 0; i < N_DIRECTIONAL; i++) { diff --git a/tests/language/stats/crosstabs.at b/tests/language/stats/crosstabs.at index 2657cc45..eb511ced 100644 --- a/tests/language/stats/crosstabs.at +++ b/tests/language/stats/crosstabs.at @@ -299,7 +299,7 @@ END DATA. LIST. -CROSSTABS TABLES x by y by z. +CROSSTABS TABLES x BY y BY z/STATISTICS=ALL. ]]) AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [[Table: Reading 1 record from INLINE. @@ -340,6 +340,67 @@ Total,,4.0,1.0,5.0 ,6,1.0,.0,1.0 ,9,1.0,.0,1.0 Total,,3.0,1.0,4.0 + +Table: Chi-square tests. +z,Statistic,Value,df,Asymp. Sig. (2-tailed) +1,Pearson Chi-Square,5.00,4,.29 +,Likelihood Ratio,5.00,4,.29 +,Linear-by-Linear Association,.01,1,.94 +,N of Valid Cases,5,, +2,Pearson Chi-Square,4.00,3,.26 +,Likelihood Ratio,4.50,3,.21 +,Linear-by-Linear Association,1.58,1,.21 +,N of Valid Cases,4,, + +Table: Symmetric measures. +z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig. +1,Nominal by Nominal,Phi,1.00,,, +,,Cramer's V,1.00,,, +,,Contingency Coefficient,.71,,, +,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00, +,,Kendall's tau-c,.00,.32,.00, +,,Gamma,.00,.50,.00, +,,Spearman Correlation,.00,.22,.00, +,Interval by Interval,Pearson's R,.04,.22,.18, +,N of Valid Cases,,5,,, +2,Nominal by Nominal,Phi,1.00,,, +,,Cramer's V,1.00,,, +,,Contingency Coefficient,.71,,, +,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73, +,,Kendall's tau-c,-.75,.43,-1.73, +,,Gamma,-1.00,.00,-1.73, +,,Spearman Correlation,-.77,.17,-6.77, +,Interval by Interval,Pearson's R,-.73,.18,-5.49, +,N of Valid Cases,,4,,, + +Table: Directional measures. +z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig. +1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.02, +,,,x Dependent,.25,NaN,1.12, +,,,y Dependent,1.00,NaN,1.12, +,,Goodman and Kruskal tau,x Dependent,.25,,, +,,,y Dependent,1.00,,, +,,Uncertainty Coefficient,Symmetric,.47,.18,1.51, +,,,x Dependent,.31,.15,2.02, +,,,y Dependent,1.00,.00,2.02, +,Ordinal by Ordinal,Somers' d,Symmetric,.00,.09,.00, +,,,x Dependent,.00,.50,.00, +,,,y Dependent,.00,.20,.00, +,Nominal by Interval,Eta,x Dependent,.04,,, +,,,y Dependent,1.00,,, +2,Nominal by Nominal,Lambda,Symmetric,.50,.25,1.51, +,,,x Dependent,.33,NaN,1.15, +,,,y Dependent,1.00,NaN,1.15, +,,Goodman and Kruskal tau,x Dependent,.33,,, +,,,y Dependent,1.00,,, +,,Uncertainty Coefficient,Symmetric,.58,.17,1.56, +,,,x Dependent,.41,.17,2.36, +,,,y Dependent,1.00,.00,2.36, +,Ordinal by Ordinal,Somers' d,Symmetric,-.67,.04,-1.73, +,,,x Dependent,-1.00,.00,-1.73, +,,,y Dependent,-.50,.29,-1.73, +,Nominal by Interval,Eta,x Dependent,.73,,, +,,,y Dependent,1.00,,, ]]) AT_CLEANUP -- 2.30.2