1
$\begingroup$

I run a GLM in what I believe is the same way in Minitab and R. With no interaction term, I get identical results. With the interaction, the results are completely different. I'd much appreciate any ideas as to why?

Gen is binary, ageInt1 and FaWofoT are continuous. When including the interaction between Gen and FaWofoT, FaWofoT stays significant in Minitab, but goes totally non-significant in R.

Minitab, no interaction

MTB > GLM 'Competes' = AgeInt1 Gen FaWoFoT;
SUBC>   Covariates 'AgeInt1' 'FaWoFoT';
SUBC>   Brief 3 ;
SUBC>   GFourpack;
SUBC>   RType 1 .

General Linear Model: Competes versus Gen 

Factor  Type   Levels  Values
Gen     fixed       2  F, M


Analysis of Variance for Competes, using Adjusted SS for Tests

Source   DF   Seq SS   Adj SS  Adj MS     F      P
ageInt1   1   17.025   18.333  18.333  7.49  0.009
Gen       1    5.941    5.803   5.803  2.37  0.131
FaWofoT   1   17.276   17.276  17.276  7.06  0.011
Error    43  105.195  105.195   2.446
Total    46  145.436


S = 1.56409   R-Sq = 27.67%   R-Sq(adj) = 22.62%


Term         Coef  SE Coef      T      P
Constant   -2.534    1.472  -1.72  0.092
ageInt1    0.7537   0.2753   2.74  0.009
Gen
F         -0.3542   0.2300  -1.54  0.131
FaWofoT   0.09786  0.03683   2.66  0.011

R, no interaction

> mod <- glm( Competes ~ ageInt1 + Gen + FaWofoT, data = d )
> summary(mod)

Call:
glm(formula = Competes ~ ageInt1 + Gen + FaWofoT, data = d)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-2.449  -1.085  -0.108   1.185   3.260  

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept) -2.88815    1.50686  -1.917  0.06194 . 
ageInt1      0.75362    0.27535   2.737  0.00898 **
GenM         0.70860    0.45993   1.541  0.13073   
FaWofoT      0.09791    0.03683   2.659  0.01098 * 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 2.446532)

    Null deviance: 145.44  on 46  degrees of freedom
Residual deviance: 105.20  on 43  degrees of freedom
  (34 observations deleted due to missingness)
AIC: 181.25

Number of Fisher Scoring iterations: 2

Minitab, with interaction

MTB > GLM 'Competes' = AgeInt1 Gen FaWoFoT|Gen;
                                           X

* NOTE * Repeated term at X ignored.

SUBC>   Covariates 'AgeInt1' 'FaWoFoT';
SUBC>   Brief 3 ;
SUBC>   GFourpack;
SUBC>   RType 1 .

General Linear Model: Competes versus Gen 

Factor  Type   Levels  Values
Gen     fixed       2  F, M


Analysis of Variance for Competes, using Adjusted SS for Tests

Source       DF   Seq SS  Adj SS  Adj MS     F      P
ageInt1       1   17.025  12.416  12.416  5.81  0.020
Gen           1    5.941   8.337   8.337  3.90  0.055
FaWofoT       1   17.276  18.190  18.190  8.52  0.006
Gen*FaWofoT   1   15.492  15.492  15.492  7.25  0.010
Error        42   89.703  89.703   2.136
Total        46  145.436


S = 1.46143   R-Sq = 38.32%   R-Sq(adj) = 32.45%


Term             Coef  SE Coef      T      P
Constant       -1.993    1.390  -1.43  0.159
ageInt1        0.6301   0.2613   2.41  0.020
Gen
F              1.2533   0.6343   1.98  0.055
FaWofoT       0.10046  0.03442   2.92  0.006
FaWofoT*Gen
        F    -0.09417  0.03497  -2.69  0.010

R, with interaction

> mod <- glm( Competes ~ ageInt1 + Gen + FaWofoT + Gen:FaWofoT, data = d )
> summary(mod)

Call:
glm(formula = Competes ~ ageInt1 + Gen + FaWofoT + Gen:FaWofoT, 
    data = d)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-2.19520  -1.19430  -0.03902   0.93912   2.98946  

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)  -0.739776   1.618087  -0.457   0.6499  
ageInt1       0.630095   0.261320   2.411   0.0204 *
GenM         -2.506858   1.268621  -1.976   0.0547 .
FaWofoT       0.006305   0.048376   0.130   0.8969  
GenM:FaWofoT  0.188379   0.069929   2.694   0.0101 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 2.135759)

    Null deviance: 145.436  on 46  degrees of freedom
Residual deviance:  89.702  on 42  degrees of freedom
  (34 observations deleted due to missingness)
AIC: 175.76

Number of Fisher Scoring iterations: 2

EDIT: It was pointed out that Minitab and R are using different reference levels for Gen. Here is the R interaction model with the reference level done the same as Minitab. The p-values are now almost identical to Minitab, but the coefficients are still a bit different.

> d$Gen <- relevel(d$Gen,"M")
> mod <- glm( Competes ~ ageInt1 + Gen + FaWofoT + Gen:FaWofoT, data = d )
> summary(mod)

Call:
glm(formula = Competes ~ ageInt1 + Gen + FaWofoT + Gen:FaWofoT, 
    data = d)

Deviance Residuals:   
     Min        1Q    Median        3Q       Max  
-2.19520  -1.19430  -0.03902   0.93912   2.98946  

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  -3.24663    1.43290  -2.266 0.028681 *  
ageInt1       0.63010    0.26132   2.411 0.020352 *  
GenF          2.50686    1.26862   1.976 0.054742 .  
FaWofoT       0.19468    0.04974   3.914 0.000327 ***
GenF:FaWofoT -0.18838    0.06993  -2.694 0.010108 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 2.135759)

    Null deviance: 145.436  on 46  degrees of freedom
Residual deviance:  89.702  on 42  degrees of freedom
  (34 observations deleted due to missingness)
AIC: 175.76

Number of Fisher Scoring iterations: 2
$\endgroup$
  • 4
    $\begingroup$ You are reporting different analyses. In particular, your variables Gen differ: one uses "F" as the response and the other uses "M". You therefore cannot compare coefficients one-to-one; you have to convert one model into the other before you can decide whether they agree or not. An easy check is to compare the predicted values of both models. Do they agree? $\endgroup$ – whuber Sep 26 '16 at 23:26
  • 2
    $\begingroup$ It's not just M-vs-F -- you can see by the size of the coefficient that Minitab is also not using 0-vs-1 coding for that variable; presumably it's using -1-vs-1 there $\endgroup$ – Glen_b Sep 27 '16 at 2:58
  • $\begingroup$ Thanks for identifying that one model uses M and another F as reference level. I fixed R to do the same as Minitab (see above). The p-values are now almost identical between the packages, although not the coefficients. This rocks my world, in a bad way. Just by arbitrarily changing between (M=0,F=1) and (M=1,F=0) for Gen, I get the p-value for FaWoFoT to shift between .8969 and .0003. I'm not exaggerating to say I just lost major confidence in the tools I use to try and understand the world. Is the main effect of FaWoFoT important for Competes or not? $\endgroup$ – Amorphia Sep 27 '16 at 7:45
  • 2
    $\begingroup$ I can't inspect it without data, but it is due to the method of contrasts ? (I heard Minitab uses different contrasts from R). If you run options(contrasts = c("contr.helmert", "contr.poly")) or options(contrasts = c("contr.sum", "contr.poly")) in R, perhapos you get the same result. (note; default is options(contrasts = c("contr.treatment", "contr.poly"))) $\endgroup$ – cuttlefish44 Sep 27 '16 at 10:52
1
$\begingroup$

you should be using the aov() command on your glm in R. Did you notice that you aren't getting any SS outputs the way you've coded your question in R?

glm(completes ~ ageInt1 + Gen + FaWofto + Gen*FaWofto) also works instead of how you've written the interaction.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.