0

In dredge (MuMIn package) I want to use "subset" in order to exclude any model combining variable A with one of B,C or D. I tried

library(MuMIn) dg <- dredge (global.model, subset = !("A"&c("B","C","D"))

which delivers the same result as dg <- dredge (global.model, subset = !("A"&"B"), thus only excludes models containing A and B together. Is there any way to feed subset with a vector of variable names?

I could use subset=!(A&B)|!(A&C)|!(A&D), of course - however I'd prefer to use an "exclude-vector".

www
  • 38,575
  • 12
  • 48
  • 84
yenats
  • 531
  • 1
  • 3
  • 16

1 Answers1

0

Simplest expression for that is probably subset = !A | !sum(B, C, D). It has the same result as !A | !(B | C | D).

Kamil Bartoń
  • 1,482
  • 9
  • 10
  • Thank you for your suggestion. I changed to `subset = !(A & sum(B,C,D))` and it worked. Your code excludes the variables completely from analysis. Perhaps you can update your answer? As a topping: can I add a second subset like `!B&C`? – yenats Sep 16 '17 at 14:37
  • I think, I found a way: `subset = !(A&sum(B, C, D)) && !(B&C))` Just to understand it right: does this mean - exclude models containing A and at least one of B, C, D and - exclude models containing both B,C together? – yenats Sep 16 '17 at 14:52
  • `!(A & sum(B,C,D))` is effectively identical to my example (not x or not y == not (x and y)). In addition you can use `sum(B, C, D) < N)` to limit the number of concurrent variables, or `> N` to set minimum number of variables. The `*nvar*` special variable is also useful for this purpose. – Kamil Bartoń Sep 17 '17 at 16:05