Reputation: 1
I am working with loglm(count~A+B+C+D+E, data=whatever)
.
My problem is that I would like to compute every possible combination of all of the effects. That is: A and A+A:B and A+C+C:B+A:B:C:D:E and so on into (seeming) infinity.
Any suggestions?
EDIT The data looks something like
df <- structure(list(count = c(0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L),
A = c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), B = c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L), C = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L),
D = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L), E = c(1L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L)), .Names = c("count", "A", "B", "C", "D", "E"),
class = "data.frame", row.names = c(NA, -29L))
the problem i get is:
> data(SampleData)
Warning message:
In data(SampleData) : data set ‘SampleData’ not found
> fm1 <- loglm(count ~ ., data = SampleData)
> dd <- dredge(fm1)
Error in rownames(ct)[match(names(coef1), rownames(ct))] <- fxdCoefNames :
NAs are not allowed in subscripted assignments
In addition: Warning messages:
1: In table(fac) : attempt to set an attribute on NULL (model 1 skipped)
2: In data[do.call("cbind", lapply(fac, as.numeric))] <- rsp :
number of items to replace is not a multiple of replacement length
3: In st[do.call("cbind", lapply(fac, as.numeric))] <- exp(offset) :
number of items to replace is not a multiple of replacement length
4: In double(nmar) : vector size cannot be NA/NaN (model 2 skipped)
5: In data[do.call("cbind", lapply(fac, as.numeric))] <- rsp :
number of items to replace is not a multiple of replacement length
6: In st[do.call("cbind", lapply(fac, as.numeric))] <- exp(offset) :
number of items to replace is not a multiple of replacement length
7: In double(nmar) : vector size cannot be NA/NaN (model 3 skipped)
> subset(dd, delta < 4)
Error in subset(dd, delta < 4) : object 'dd' not found
Upvotes: 0
Views: 711
Reputation: 21532
As I always say, "What is the problem you are trying to solve?" Presumably you don't actually need all those 2^N results, so what is it you are looking for? Perhaps you want some sort of sieve to zero in on the effects which have the strongest, errr... effect :-) on the outcome?
BTW, you might want to play a bit with Eureqa
, a package from http://creativemachines.cornell.edu/eureqa .
Upvotes: 1
Reputation: 7948
I believe this would get you want you want,
install.packages('MuMIn', dependencies = TRUE)
library(MuMIn)
Example from Burnham and Anderson (2002), page 100: (taken from ?dredge
)
data(Cement)
fm1 <- lm(y ~ ., data = Cement)
dd <- dredge(fm1)
subset(dd, delta < 4)
All you have to do is replace lm(y ~
with loglm(count~
and remove all none-explanatory variables from your data.
Upvotes: 1