0

I am performing a onmibus anova to test for interaction on a dataset with one variable and three factors.

data$fac1
data$fac2
data$fac3

levels(data$fac1)
[1] "1"  "2"  "3" "4" "5" "6" "7" "8"     
[9] "9"  "10" "11"  "12" "13"  "14" "15" "16"  
[17] "17""18" "19"  "20" "21"  "22" "23" "24"
[25] "25""26" "27"  "28" "29"  "30" "31" "32"   
[33] "33" "34" "35" "36" "37" "38" "39" "40"      
[41] "41" "42" "43" "44" "45" "46" "47" "48"    
[49] 

levels(data$fac2)
[1] "1"  "2"  "3" "4" "5" "6" "7" "8"

levels(data$fac3)
 [1] "1"  "2"  "3"

The second factor is ignored.

The code is below:

anova(lm(var ~ fac1 * fac2 * fac3, data= data))

It returns:

Response: var
               Df Sum Sq Mean Sq F value  Pr(>F)    
fac1          48  31708  660.59  67.043 < 2e-16 ***
fac3          2    279  139.44  14.152 1.4e-06 ***
fac1:fac3     95  10384  109.31  11.094 < 2e-16 ***
Residuals     279   2749    9.85                    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

While I expecting something like:

Response: var
                   Df Sum Sq Mean Sq F value  Pr(>F)    
    fac1          48  31708  660.59  67.043 < 2e-16 ***
    fac2           7   ---   ------   -----    ---  ***
    fac3           2    279  139.44  14.152 1.4e-06 ***
    fac1:fac2     --   ----   -----  ------ ------- ---
    fac1:fac3     95  10384  109.31  11.094 < 2e-16 ***
    fac2:fac3     --  -----  ------  ------ ------- ---
    Residuals     279   2749    9.85                    
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Anyone can help?

Rosario
  • 183
  • 1
  • 11
  • 1
    Can you provide a sample of `data`? Are you sure that "fac2" has more than 1 unique value? – jdobres Nov 30 '19 at 14:18
  • I cannot provide an example of the data. Fac2 has 8 levels and each level includes at least 150 values. Hope this helps – Rosario Nov 30 '19 at 14:55
  • You could provide a sample with `dput(head(data, 100))` (and be sure that the sample produces the same behavior with "fac2"). Otherwise it's very difficult to provide you with assistance. – jdobres Nov 30 '19 at 15:04
  • The characteristics alone do not demonstrate the unexpected behavior. We need a sample of the data that reproduces the problem you're encountering. – jdobres Nov 30 '19 at 15:23
  • If I take the first 100 values as suggested, with 10 levels on the fac1 the anova result is complete. Could it be caused by the high number of levels in fac1 that makes impossible to take in more levles in the other vfactors? – Rosario Nov 30 '19 at 15:26

0 Answers0