2

I am trying to select out variables using a correlation matrix as the "subset" argument with dredge() in MuMIn (R).

My problem is precisely as described in this unresolved post: I run a model fm1*, and use dredge to test all combinations of variables. To exclude some combinations I use a subset matrix sub1 following the method described in dredge.subset demo.

> sub1
       X1    X2    X3    X4    X5    X6    X7    X8    X9  X10  
X1     NA    NA    NA    NA    NA    NA    NA    NA    NA   NA 
X2   TRUE    NA    NA    NA    NA    NA    NA    NA    NA   NA  
X3  FALSE FALSE    NA    NA    NA    NA    NA    NA    NA   NA
X4  FALSE FALSE  TRUE    NA    NA    NA    NA    NA    NA   NA
X5  FALSE FALSE FALSE FALSE    NA    NA    NA    NA    NA   NA 
X6  FALSE FALSE FALSE FALSE  TRUE    NA    NA    NA    NA   NA
X7   TRUE FALSE  TRUE FALSE FALSE  TRUE    NA    NA    NA   NA
X8  FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE    NA    NA   NA 
X9   TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE FALSE    NA   NA
X10  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE   NA 

It works fine with up to 9 variables; with more I get an error message:

> form
N ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10
> fm1<-glm(form,data=dfmod)
> ms1<-pdredge(fm1,subset=sub1,cluster=clust) 
Warning message: In pdredge(fm1, subset = sub1, cluster = clust) :
non-missing values exist outside the lower triangle of 'subset'

This is not true, as shown by:

     any(!is.na(sub1[!lower.tri(sub1)]))
     [1] FALSE

In addition to the warning, the model selection table includes sets of variables that were not allowed by the correlation matrix.

I did find a workaround by converting the matrix sub1 into a logical expression, which then works fine as subsetting condition. But it would be interesting to understand what's going on with the matrix.

*note that the same happens with glm and glmer

www
  • 38,575
  • 12
  • 48
  • 84
PaulC
  • 23
  • 5

0 Answers0