  [cc'ing back to r-help: this is good etiquette so that the responses
will be seen by others/
archived for future reference.]

On 10-08-25 04:35 PM, Marino Taussig De Bodonia, Agnese wrote:
> Yes, I meant "MuMIn"
>
> the global formula I introduced was:
>
> rc4.mod<-lm(central$hunting~ central$year + central$gender  +
central$hunter + central$k.score + central$seen.in.wild +
central$captivity + central$had.damage +
central$importance.of.being.informed + central$RC1+ central$RC2 +
central$year:central$hunter + central$year:central$had.damage +
central$year:central$seen.in.wild +central$year:central$RC1 +
central$year:central$RC2)

  In general it would be much clearer and more generalizable if you
instead used:

rc4.mod<-lm(hunting~ year + gender  + hunter + k.score + seen.in.wild +
captivity +
   had.damage + importance.of.being.informed + RC1+ RC2 + year:hunter +
year:had.damage +
   year:seen.in.wild +year:RC1 + year:RC2, data=central)

or even

rc4.mod <- lm(hunting ~ gender + k.score + captivity +
importance.of.being.informed+
     year*(RC1 + RC2 + hunter + had.damage + seen.in.wild), data=central)

  I don't know why those spurious interactions are showing up. It
*might* be a bug in MuMIn.

  So far, I can't reproduce this behavior with my simple example:

=================
library(MuMIn)
dat <- data.frame(y=runif(100),a=factor(sample(1:5,replace=TRUE,size=100)),
                  b= factor(sample(1:5,replace=TRUE,size=100)),
c=runif(100))

m1 <- lm(y~a+b+c+a:b,data=dat)
gm <- function(x) {
  model.avg(get.models(dredge(x),subset=delta<Inf))$relative.importance
}

gm(m1)

m1 <- lm(y~dat$a+dat$b+dat$c+dat$a:dat$b,data=dat)
gm(m1)
==================

  You have to keep working to simplify your example until you can get to
a pair
of examples, one simpler and one more complicated, that 'bracket' the
problem --
the simpler example doesn't show the problem, and the more complicated
(closer
to your original example) does.

  Alternatively, you may simplify the problem out of existence and
decide that you don't need to spend any more
time figuring out what it was ...

  Two more quick notes to consider:

  * why are you not considering models with delta<4 ... ?
  * it is quite tricky to compare relative importance of 'main effect'
parameters in models with and without interactions.


>
> There are 15 explanatory variables in this model.
>
> my code was:
>
> rc4.mod.Mu <- dredge(rc4.mod, rank = "AICc")
> rc4.mod.Mu
> rc4.mod.Mu.avg<-model.avg(get.models(rc4.mod.Mu, subset = delta < 4))
>
> the output for the command "rc4.mod.Mu.avg$relative.importance" was:
>
> central$hunter    1
> central$seen.in.wild    1
> central$year    0.986960449
> central$had.damage    0.89670109
> central$RC2    0.83866013
> central$k.score    0.656654734
> central$had.damage:central$year    0.517130185
> central$year:central$hunter    0.305988097
> central$hunter:central$year    0.212045101
> central$year:central$seen.in.wild    0.190520501
> central$seen.in.captivity    0.148263242
> central$gender    0.119314202
> central$RC1    0.098234445
> central$importance.of.being.informed    0.091842088
> central$year:central$RC2    0.069501158
> central$seen.in.wild:central$year    0.065788243
> central$RC2:central$year    0.024221603
>
> There are 17 variables above:  central$year:central$RC2  and
central$RC2:central$year are both present, as are
central$hunter:central$year  and  central$year:central$hunter .
>
> Can you tell me why, if they are the same thing, they are present twice
and have different values?
>
> Thanks a lot,
>
> Agnese
> ________________________________________
> From: r-help-bounces@r-project.org [r-help-bounces@r-project.org] On
Behalf Of Ben Bolker [bbolker@gmail.com]
> Sent: 25 August 2010 20:36
> To: r-help@stat.math.ethz.ch
> Subject: Re: [R] package MuMI
>
> Marino Taussig De Bodonia, Agnese <agnese.marino09 <at> imperial.ac.uk>
writes:
>
>> I am using the package "MuMI" to run all the possible combinations
>>  of variables in my full model, and select
>> my best models. When I enter my variables in the original model I
>> write them like this
>>
>> lm(y~ a +b +c +a:b)
>>
>> However,  "MuMI" will also use the variable b:a, which I do not want
>> in my model.
>>
>> How do I stop that from happening?
>>
>
>   (1) I think you mean "MuMIn".
>   (2) Please send a reproducible example! (Hint: see the posting
> guide that is referred to at the bottom of all R-help messages ...)
>   (3) [now proceeding to try to guess what you mean ...]
>
> a:b and b:a have identical meanings in the R formula syntax.
>
>   I tried to do something like what I thought you might have meant
> and got what seemed to be reasonable answers.
>
>> library(MuMIn)
>> dat <-
data.frame(y=runif(100),a=factor(sample(1:5,replace=TRUE,size=100)),
> +    b= factor(sample(1:5,replace=TRUE,size=100)), c=runif(100))
>> m1 <- lm(y~a+b+c+a:b,data=dat)
>> dredge(m1)
> Global model: lm(formula = y ~ a + b + c + a:b, data = dat)
> ---
> Model selection table
>    (Int)  a b c       a:b k  R.sq    Adj.R.sq  RSS   AIC   AICc 
delta   weight
> 4  0.6385     -0.1643      3 0.03019  0.020290 7.386 29.23 29.48 
0.0000 0.420
> 1  0.5530                  2 0.00000  0.000000 7.616 30.29 30.42 
0.9392 0.262
> 7  0.6283   + -0.1461      7 0.09397  0.045770 6.900 30.42 31.64 
2.1650 0.142
> 3  0.5533   +              6 0.07067  0.031540 7.077 30.96 31.87 
2.3890 0.127
> 6  0.6134 +   -0.2199      7 0.06700  0.017370 7.105 33.36 34.57 
5.0980 0.033
> 2  0.5202 +                6 0.01989 -0.021380 7.464 36.28 37.19 
7.7100 0.009
> 8  0.6232 + + -0.1941     11 0.12050  0.032540 6.698 35.45 38.45 
8.9760 0.005
> 5  0.5352 + +             10 0.08490  0.004455 6.969 37.42 39.89
10.4100 0.002
> 10 0.7433 + + -0.2504 +   27 0.27800  0.034140 5.498 47.71 68.71
39.2400 0.000
> 9  0.6193 + +         +   26 0.23150 -0.014420 5.853 51.96 71.19
41.7200 0.000
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



	[[alternative HTML version deleted]]

