GLM: Do not print the intercept if the model is unbalanced
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 19 Jan 2016 16:47:04 +0000 (17:47 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 26 Jan 2016 19:47:05 +0000 (20:47 +0100)
I cannot find any reliable explanation of how to calculate this
figure for unbalanced models not what it actually means.  So
let's not even bother with it until an expert comes along.

src/language/stats/glm.c
src/math/categoricals.c
src/math/categoricals.h
tests/language/stats/glm.at

index e4b3c17b21bb66ec4f46a30a52114668059cd90b..a5e047e86d1dcb118a5785b126a30411e52ea695 100644 (file)
@@ -775,12 +775,17 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws)
       const double df = 1.0;
       const double F = intercept_ssq / df / mse;
       tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Intercept"));
-      tab_double (t, 1, r, 0, intercept_ssq, NULL, RC_OTHER);
-      tab_double (t, 2, r, 0, 1.00, NULL, RC_WEIGHT);
-      tab_double (t, 3, r, 0, intercept_ssq / df, NULL, RC_OTHER);
-      tab_double (t, 4, r, 0, F, NULL, RC_OTHER);
-      tab_double (t, 5, r, 0, gsl_cdf_fdist_Q (F, df, n_total - df_corr),
-                 NULL, RC_PVALUE);
+      /* The intercept for unbalanced models is of limited use and
+        nobody knows how to calculate it properly */
+      if (categoricals_isbalanced (ws->cats))
+       {
+         tab_double (t, 1, r, 0, intercept_ssq, NULL, RC_OTHER);
+         tab_double (t, 2, r, 0, 1.00, NULL, RC_WEIGHT);
+         tab_double (t, 3, r, 0, intercept_ssq / df, NULL, RC_OTHER);
+         tab_double (t, 4, r, 0, F, NULL, RC_OTHER);
+         tab_double (t, 5, r, 0, gsl_cdf_fdist_Q (F, df, n_total - df_corr),
+                     NULL, RC_PVALUE);
+       }
       r++;
     }
 
index b621d982931c72c0eadbb04e420d943e10a5cded..140542fe02de630b4e3443857532851d2d8b6c23 100644 (file)
@@ -196,6 +196,31 @@ struct categoricals
   const struct payload *payload;
 };
 
+
+bool
+categoricals_isbalanced (const struct categoricals *cat)
+{
+  int i;
+
+  for (i = 0 ; i < cat->n_iap; ++i)
+    {
+      int v;
+      const struct interact_params *iap = &cat->iap[i];
+
+      double oval = -1.0;
+      for (v = 0; v < hmap_count (&iap->ivmap); ++v)
+       {
+         const struct interaction_value *iv = iap->reverse_interaction_value_map[v];
+         if (oval == -1.0)
+           oval = iv->cc;
+         if (oval != iv->cc)
+           return false;
+       }
+    }
+  return true;
+}
+
+
 static void
 categoricals_dump (const struct categoricals *cat)
 {
index c5919bc455e883e131bb2aa637b1165d0bf36ea2..fbb45aadb7e05f9d25c77340e7fbe4709b78add4 100644 (file)
@@ -124,5 +124,6 @@ struct payload
 
 void  categoricals_set_payload (struct categoricals *cats, const struct payload *p, const void *aux1, void *aux2);
 
+bool categoricals_isbalanced (const struct categoricals *cat);
 
 #endif
index ec9a6799e379cd31f4852f07ac256e1b2d93bb35..e56c150820ce138f0b952b1b17a58e3ad6d0e09d 100644 (file)
@@ -214,7 +214,7 @@ warning: GLM is experimental.  Do not rely on these results.
 Table: Tests of Between-Subjects Effects
 Source,Type I Sum of Squares,df,Mean Square,F,Sig.
 Corrected Model,216.017,7,30.860,5.046,.001
-Intercept,3410.526,1,3410.526,557.709,.000
+Intercept,,,,,
 Agrp,9.579,1,9.579,1.566,.220
 Bgrp,186.225,3,62.075,10.151,.000
 Agrp * Bgrp,20.212,3,6.737,1.102,.364
@@ -227,7 +227,7 @@ warning: GLM is experimental.  Do not rely on these results.
 Table: Tests of Between-Subjects Effects
 Source,Type I Sum of Squares,df,Mean Square,F,Sig.
 Corrected Model,216.017,7,30.860,5.046,.001
-Intercept,3410.526,1,3410.526,557.709,.000
+Intercept,,,,,
 Bgrp,193.251,3,64.417,10.534,.000
 Agrp,2.553,1,2.553,.418,.523
 Bgrp * Agrp,20.212,3,6.737,1.102,.364
@@ -253,7 +253,7 @@ warning: GLM is experimental.  Do not rely on these results.
 Table: Tests of Between-Subjects Effects
 Source,Type II Sum of Squares,df,Mean Square,F,Sig.
 Corrected Model,216.017,7,30.860,5.046,.001
-Intercept,3410.526,1,3410.526,557.709,.000
+Intercept,,,,,
 Agrp,2.553,1,2.553,.418,.523
 Bgrp,186.225,3,62.075,10.151,.000
 Agrp * Bgrp,20.212,3,6.737,1.102,.364