Re: [R] R-help Digest, Vol 164, Issue 4

2016-10-04 Thread Kamil Bartoń

Hi Caitie,
whatever it is you want to achieve, you seem to be doing it in a very complicated way. The code you 
gave appears to be for producing a model selection table, yet you say you're trying to do model 
averaging.


If you want a model selection table, why not use the one `dredge` produces (with evaluate=TRUE, you 
can add R^2 via argument 'extra')?
If you actually mean model averaging, there is `model.avg` that can be used directly on `dredge`'s 
output.


cheers,
k



W dniu 2016-10-04 o 12:00, r-help-requ...@r-project.org pisze:

Message: 10
Date: Mon, 3 Oct 2016 05:47:11 +
From: Caitie Kuempel 
To: "r-help@r-project.org" 
Subject: [R] Error in aictab with CLM model "function not yet defined"
Message-ID: 
Content-Type: text/plain; charset="UTF-8"

Hi R help,

I am trying to do some AIC model averaging on a CLM model in R and keep getting 
the error:

Error in aictab.default(cand.set = Cand.model0, modnames = Modnames0,  :
Function not yet defined for this object class


The MuMIn package says that the functions should work for clm and clmm models 
so I'm not sure if I'm missing something or if there is an extra step?  Any 
help or examples would be appreciated.

My model (m1) works fine- which I fit using the clm() function from the package 
ordinal.  Then I run the following:

dred<-dredge(m1,rank="AICc",trace=TRUE,evaluate=FALSE)
Cand.model0<-list()
r2val<-rep(0,length(dred)) # r-square values
for(i in 1:length(dred))
{
  print(length(dred)-i)
  Cand.model0[[i]]<-clm(as.character(dred[[i]])[2],data=datt2,REML=FALSE)
  #r2val[i]<-summary(Cand.model0[[i]])$r.squared
}

Modnames0 <- paste("mod", 1:length(Cand.model0), sep = " ")
t0<-aictab(cand.set=Cand.model0, modnames=Modnames0, sort = TRUE, second.ord = 
TRUE,nobs = NULL)
Error in aictab.default(cand.set = Cand.model0, modnames = Modnames0,  :
Function not yet defined for this object class

Thanks for your time.

Best,

Caitie

[[alternative HTML version deleted]]




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Error in aictab with CLM model "function not yet defined"

2016-10-04 Thread Kamil Bartoń

Hi Caitie,
whatever it is you want to achieve, you seem to be doing it in a very complicated way. The code you 
gave appears to be for producing a model selection table, yet you say you're trying to do model 
averaging.


If you want a model selection table, why not use the one `dredge` produces (with evaluate=TRUE, you 
can add R^2 via argument 'extra')?
If you actually mean model averaging, there is `model.avg` that can be used directly on `dredge`'s 
output.


cheers,
k



W dniu 2016-10-04 o 12:00, r-help-requ...@r-project.org pisze:

Message: 10
Date: Mon, 3 Oct 2016 05:47:11 +
From: Caitie Kuempel 
To: "r-help@r-project.org" 
Subject: [R] Error in aictab with CLM model "function not yet defined"
Message-ID: 
Content-Type: text/plain; charset="UTF-8"

Hi R help,

I am trying to do some AIC model averaging on a CLM model in R and keep getting 
the error:

Error in aictab.default(cand.set = Cand.model0, modnames = Modnames0,  :
Function not yet defined for this object class


The MuMIn package says that the functions should work for clm and clmm models 
so I'm not sure if I'm missing something or if there is an extra step?  Any 
help or examples would be appreciated.

My model (m1) works fine- which I fit using the clm() function from the package 
ordinal.  Then I run the following:

dred<-dredge(m1,rank="AICc",trace=TRUE,evaluate=FALSE)
Cand.model0<-list()
r2val<-rep(0,length(dred)) # r-square values
for(i in 1:length(dred))
{
  print(length(dred)-i)
  Cand.model0[[i]]<-clm(as.character(dred[[i]])[2],data=datt2,REML=FALSE)
  #r2val[i]<-summary(Cand.model0[[i]])$r.squared
}

Modnames0 <- paste("mod", 1:length(Cand.model0), sep = " ")
t0<-aictab(cand.set=Cand.model0, modnames=Modnames0, sort = TRUE, second.ord = 
TRUE,nobs = NULL)
Error in aictab.default(cand.set = Cand.model0, modnames = Modnames0,  :
Function not yet defined for this object class

Thanks for your time.

Best,

Caitie

[[alternative HTML version deleted]]




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Submodel selection using dredge and gam (mgcv)

2014-11-12 Thread Kamil Bartoń

Hi Arnaud,
please read ?dredge - Details - Subsetting, where this is explained.


On 2014-11-12 15:19, Arnaud Mosnier wrote:

Hi Kamil,

Thanks for your answer. In fact, I already tried something with
operators in such a way you advise, but it seems more complicated due to
the use of the s() and ti() operators.

Can you provide a solution for the following example ?

library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,scale=2)

bt - gam(y~s(x0)+s(x1)+ti(x0,x1), data=dat,method=ML)

library(MuMIn)

# this does not work
dredge(bt, subset = (!(x0,x1) | (x0  x1)))
dredge(bt, subset = (!ti(x0,x1) | (s(x0)  s(x1

Cheers,

Arnaud


2014-11-11 4:11 GMT-05:00 Kamil Bartoń kamil.bar...@o2.pl
mailto:kamil.bar...@o2.pl:

Hi Arnaud,
your question has in fact nothing to do with gam or model selection.
What you are asking is: what is the logical expression that yields
True when AB is False or both A and B are True. Now replace the
words with operators (!AB | (A  B)) and voilà.

See also:
help(Logic, base)
fortunes::fortune(350)

best,
kamil



On 2014-11-10 21:26, Arnaud Mosnier wrote:

Hi,

I want to use dredge to test several gam submodels including
interactions.
I tried to find a way in order to keep models with interaction
only if
the single variables occurring in the interaction are also included.

i.e.: for
   y~s(x0)+s(x1)+ti(x0, x1)

I want to keep
y ~ s(x0)
y ~ s(x1)
y ~ s(x0) + s(x1)
y ~ s(x0) + s(x1) + ti(x0,x1)

and I want to remove

y ~ s(x0) + ti(x0,x1)
y ~ s(x1) + ti(x0,x1)
y ~ ti(x0,x1)


I know that I should use the subset option of the dredge function.
However, I can not find the correct matrix / expression to
obtain what I
need !


Here a small example.



# Create some data (use mgcv example)
library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,__scale=2)

# Create the global gam model
# Here a model with interaction. Note the use of ti()
bt - gam(y~s(x0)+s(x1)+s(x2)+s(x3)+__ti(x1,x2),
data=dat,method=ML)

# Use dredge to test sub-models
library(MuMIn)
print(modstab - dredge(bt))

# Here the 11th model include the interaction but do not include the
single variables x1 and x2
# ... I want to avoid that kind of model.
get.models(modstab, subset = 11)




Any help would be appreciated !

Arnaud





__
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.


Re: [R] Submodel selection using dredge and gam (mgcv)

2014-11-11 Thread Kamil Bartoń

Hi Arnaud,
your question has in fact nothing to do with gam or model selection. 
What you are asking is: what is the logical expression that yields True 
when AB is False or both A and B are True. Now replace the words with 
operators (!AB | (A  B)) and voilà.


See also:
help(Logic, base)
fortunes::fortune(350)

best,
kamil


On 2014-11-10 21:26, Arnaud Mosnier wrote:

Hi,

I want to use dredge to test several gam submodels including interactions.
I tried to find a way in order to keep models with interaction only if
the single variables occurring in the interaction are also included.

i.e.: for
  y~s(x0)+s(x1)+ti(x0, x1)

I want to keep
y ~ s(x0)
y ~ s(x1)
y ~ s(x0) + s(x1)
y ~ s(x0) + s(x1) + ti(x0,x1)

and I want to remove

y ~ s(x0) + ti(x0,x1)
y ~ s(x1) + ti(x0,x1)
y ~ ti(x0,x1)


I know that I should use the subset option of the dredge function.
However, I can not find the correct matrix / expression to obtain what I
need !


Here a small example.



# Create some data (use mgcv example)
library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,scale=2)

# Create the global gam model
# Here a model with interaction. Note the use of ti()
bt - gam(y~s(x0)+s(x1)+s(x2)+s(x3)+ti(x1,x2), data=dat,method=ML)

# Use dredge to test sub-models
library(MuMIn)
print(modstab - dredge(bt))

# Here the 11th model include the interaction but do not include the
single variables x1 and x2
# ... I want to avoid that kind of model.
get.models(modstab, subset = 11)




Any help would be appreciated !

Arnaud


__
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.


Re: [R] AICc in MuMIn package

2014-06-27 Thread Kamil Bartoń

On 2014-06-27 11:00, r-help-requ...@r-project.org wrote:

Date: Thu, 26 Jun 2014 15:12:08 +0200

 From: Carlos Bautista  Le?n carlosbautistal...@gmail.com
 To: r-help@r-project.org
 Subject: [R] AICc in MuMIn package

Hello, I am modelling in glmmADMB count data
(I??m using a negative binomial distribution to avoid possitive
overdispersion) with four fixed and one random effect. I??m also using
MuMIn package to calculate the AICc and also to model averaging using
the function dredge. What I do not understand is why dredge calculates a
different value of the AICc and degrees of freedom than the function
AICc (please see bellow). Also the logLik changes (as expected).

logLik (glmmadmb.Tot.Pr.nb)  12 in model selection table

'log Lik.' -379.739 (df=6)

logLik (glmmadmb.Tot.P.nb)-- 16 in model selection table

'log Lik.' -379.688 (df=7)

 df AICc
glmmadmb.Tot.Pr.nb  6   772.811312 in model selection table
glmmadmb.Tot.P.nb   7   775.1825 16 in model selection table


Model selection table
  (Int)  Agr/100 Brd/100 Frs/100  HD/100 df   logLik  AICc delta
weight
12 0.90850 -10.570   17.08   1.4220  5 -397.992 806.9  0.00
  0.713
16 1.10300 -10.470   17.39 -0.7603   1.5140   6 -397.730 808.8  1.87  0.280


Can anyone explain me why this happend? and which values are correct, those
from dredge function or those from AICc function?

Thank you very much in advace.

Carlos



your models 'glmmadmb.Tot.Pr.nb' and 'glmmadmb.Tot.P.nb' do not seem to
be identical to model '12' and '16', since 'df's do not match (5 and 6
vs 6 and 7). You can compare the model calls to see what differs them:

getCall( glmmadmb.Tot.Pr.nb )
getCall( model.selection.table , 12)








The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. 
SC013683.

__
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.


Re: [R] Model averaging using QAICc

2014-01-16 Thread Kamil Bartoń

On 2014-01-15 11:00, r-help-requ...@r-project.org wrote:

Date: Wed, 15 Jan 2014 16:39:17 +1000
From: Diana Virkkid.vir...@griffith.edu.au
To:r-help@r-project.org
Subject: [R] Model averaging using QAICc
Message-ID:
  CAL6nRQcAyN-3SVeZSMXoJq=vsxotpg3e0prwjw7iu7g20b+...@mail.gmail.com
Content-Type: text/plain

Hi all,

I am having some trouble running GLMM's and using model averaging with
QAICc.

Let me know if you need more detail here:
I am trying to run GLMM's on count data in the package glmmADMB with a
negative binomial distribution due to overdispersion. The dispersion
parameter has now reduced to 2.679 for the global model (from a dispersion
parameter of 27.507 with a poisson distribution), and I am not sure if this
is still considered too high for running the models?

I would like to try to use QAICc's for model selection and model averaging
with the package MuMIn. I have so far been able to produce a QAICc output
only for the models. I read that model averaging with QAICc can be done in
MuMIn but cannot find the syntax to get these outputs, including the model
weightings, parameter estimates, confidence intervals, and relative
variable importance.



Use argument 'rank' to provide the information criterion to use:
- with 'dredge': rank = QAICc, chat = c-hat
- with 'model.sel' and 'model.avg' : rank = QAICc, rank.args =
list(chat = c-hat)

See example(QAICc) and example(model.avg)

kamil

The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] Get average model after dredge function ran in a loop

2013-12-13 Thread Kamil Bartoń

You are trying to average coefficients from models fitted to different
data (as you have manipulated Lat+Long values), you cannot do it using
AIC weights.

kamil



On 2013-12-11 11:00, r-help-requ...@r-project.org wrote:

Message: 26
Date: Tue, 10 Dec 2013 15:44:28 -0500
From: Catarina Ferreiracatferre...@gmail.com
To: r-helpr-help@r-project.org
Subject: [R] Get average model after dredge function ran in a loop
Message-ID:
  caaiga1skpks9aqhys+rnrbwjxmxhrf3qn6dgaen1p8qst-2...@mail.gmail.com
Content-Type: text/plain

Dear all

I'm a beginner in R and I'm trying to get the final model after I run the
dredge function for 10 times (with a loop):

###Building the Model
Coy.glm0-glm(pa ~  shrub + snowdep + tree + bio5 + bio6 + bio12 +
log(human+1), data=Coy.pa, family=binomial)
summary(Coy.glm0)

install.packages('MuMIn')
library(MuMIn)
Coy.dredge-dredge(Coy.glm0)
head(Coy.dredge) ##Look in which colum is AIC
###Building a simulation
Coy.models-Coy.dredge[1,c(1:13)]
Coy.models


###Turn a loop who will create 10 models
run=1
while(run11) #11 means 10 models.
{
   Coy.abs$Long-runif(300,498,2579440)
   Coy.abs$Lat-runif(300,-51483,1377669)
   Coy.pa-rbind(Coy.train, Coy.abs) train ou prSS
   Coy.ppp-ppp(Coy.pa$Long,Coy.pa$Lat, window=win, unitname=meters)
   Coy.pa$snowdep-snowdepz.im[Coy.ppp, drop=F]
   Coy.pa$tree-treez.im[Coy.ppp, drop=F]
   Coy.pa$bio5-bio5z.im[Coy.ppp, drop=F]
   Coy.pa$bio6-bio6z.im[Coy.ppp, drop=F]
   Coy.pa$bio12-bio12z.im[Coy.ppp, drop=F]
   Coy.pa$human-humanz.im[Coy.ppp, drop=F]
   Coy.pa$shrub-shrub.im[Coy.ppp, drop=F]

   Coy.glm0-glm(pa ~ shrub + snowdep + tree + bio5 +  bio6 + bio12+
log(human+1), data=Coy.pa, family=binomial)
   Coy.dredge-dredge(Coy.glm0)
   Coy.models-rbind(Coy.models, Coy.dredge[1,c(1:13)])
   run=run+1
}

I do get a best model for each run which I then hand pick and add to a
table. The problem is that I have 11 models now in this table and I want
their average to get the final model. I don't know how to do it from the
table (as the model.avg() will tell me I only have one model in the table,
because it's not recognizing the different rows as different models), but
on the other hand there must be a way to do it directly in the loop, only
I'm not sure at what point of the script I should be asking for it and how
the code should be written.

I would very much appreciate any help you can give me.

Thank you.

Cat






The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] Error in MuMIn models are not all fitted to the same data

2013-11-17 Thread Kamil Bartoń

It's the (typical) na.action = na.omit problem. You have missing values
in your data, so the number of observations differs between models using
different variables.

BTW with the recent lme4 package, your code throws a lot of warnings
about the use of lmer with non-gaussian family and ignored REML
argument. Also, consider using update rather than rewriting the models
each time.

kamil

On 2013-11-15 17:10, Lilly Dethier wrote:

Of course! Here's my data file and R code file. Thanks so much for your
help!!


Lilly Dethier


On Fri, Nov 15, 2013 at 8:14 AM, Kamil Bartoń k.bar...@abdn.ac.uk
mailto:k.bar...@abdn.ac.uk wrote:

works ok with mock-up data. Can you give some code to reproduce this
error?

kamil



On 2013-11-15 11:00, r-help-requ...@r-project.org
mailto:r-help-requ...@r-project.org wrote:

Message: 56
Date: Thu, 14 Nov 2013 18:01:27 -0800
From: Lilly Dethierlillydeth...@gmail.com
mailto:lillydeth...@gmail.com__
To:r-help@r-project.org mailto:to%3ar-h...@r-project.org
Subject: [R] Error in MuMIn models are not all fitted to the same
   data
Message-ID:

CAOK+e=Z_0pMEFKdPxZ5Eub+__DYhHFjzGk3Lcqczsa9TimAP4n_w@__mail.gmail.com
mailto:z_0pmefkdpxz5eub%2bdyhhfjzgk3lcqczsa9timap4...@mail.gmail.com
Content-Type: text/plain

I'm pretty new to GLMMs and model averaging, but think I'm
getting some
understanding of it all through lots of reading. However, I keep
receiving
an error message when trying to average models that I don't
understand and
can't find any resources about. I'm doing science education
research trying
to evaluate population demographic factors that predict biology
student
math performance. I have a lot of factors and so I tested a lot
of models.
6 of my models had pretty similar AIC values (and evidence
ratios of less
than 2.7) so I'm trying to average them. I keep receiving an
error message
that says the models are not fitted to the same data, but I have
no idea
how this is possible because all the models are from the same
set of data
(same file and same variables)...strangely it seems to work when
I try to
average MEx7, MEx10,  MEx22 only OR MEx24, MEx29, and MEx47
only. My code
is below. Any ideas? Thanks for any advice you can offer!!

library(MuMIn)
MEx7=lmer(cbind(c.score, w.score) ~ year + transfer + gender +
p.math +
(1|section) + (1|quarter), family=binomial, data=survey.full,
REML=F)
MEx10=lmer(cbind(c.score, w.score) ~ transfer + gender + p.math
+ Pmajor +
(1|section) + (1|quarter), family=binomial, data=survey.full,
REML=F)
MEx22=lmer(cbind(c.score, w.score) ~ year + transfer + p.math +
(1|section)
+ (1|quarter), family=binomial, data=survey.full, REML=F)
MEx24=lmer(cbind(c.score, w.score) ~ transfer + gender + p.math +
(1|section) + (1|quarter), family=binomial, data=survey.full,
REML=F)
MEx29=lmer(cbind(c.score, w.score) ~ transfer + p.math + Pmajor +
(1|section) + (1|quarter), family=binomial, data=survey.full,
REML=F)
MEx47=lmer(cbind(c.score, w.score) ~ transfer + p.math +
(1|section) +
(1|quarter), family=binomial, data=survey.full, REML=F)
MExAvg=model.avg(rank=AIC, MEx24, MEx7, MEx10, MEx47, MEx29, MEx22)

Error in model.avg.default(rank = AIC, MEx24, MEx7, MEx10,
MEx47, MEx29,  :
models are not all fitted to the same data
Lilly Dethier








The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] R-help Digest, Vol 129, Issue 15

2013-11-15 Thread Kamil Bartoń

works ok with mock-up data. Can you give some code to reproduce this error?

kamil



On 2013-11-15 11:00, r-help-requ...@r-project.org wrote:

Message: 56
Date: Thu, 14 Nov 2013 18:01:27 -0800
From: Lilly Dethierlillydeth...@gmail.com
To:r-help@r-project.org
Subject: [R] Error in MuMIn models are not all fitted to the same
  data
Message-ID:
  CAOK+e=z_0pmefkdpxz5eub+dyhhfjzgk3lcqczsa9timap4...@mail.gmail.com
Content-Type: text/plain

I'm pretty new to GLMMs and model averaging, but think I'm getting some
understanding of it all through lots of reading. However, I keep receiving
an error message when trying to average models that I don't understand and
can't find any resources about. I'm doing science education research trying
to evaluate population demographic factors that predict biology student
math performance. I have a lot of factors and so I tested a lot of models.
6 of my models had pretty similar AIC values (and evidence ratios of less
than 2.7) so I'm trying to average them. I keep receiving an error message
that says the models are not fitted to the same data, but I have no idea
how this is possible because all the models are from the same set of data
(same file and same variables)...strangely it seems to work when I try to
average MEx7, MEx10,  MEx22 only OR MEx24, MEx29, and MEx47 only. My code
is below. Any ideas? Thanks for any advice you can offer!!

library(MuMIn)
MEx7=lmer(cbind(c.score, w.score) ~ year + transfer + gender + p.math +
(1|section) + (1|quarter), family=binomial, data=survey.full, REML=F)
MEx10=lmer(cbind(c.score, w.score) ~ transfer + gender + p.math + Pmajor +
(1|section) + (1|quarter), family=binomial, data=survey.full, REML=F)
MEx22=lmer(cbind(c.score, w.score) ~ year + transfer + p.math + (1|section)
+ (1|quarter), family=binomial, data=survey.full, REML=F)
MEx24=lmer(cbind(c.score, w.score) ~ transfer + gender + p.math +
(1|section) + (1|quarter), family=binomial, data=survey.full, REML=F)
MEx29=lmer(cbind(c.score, w.score) ~ transfer + p.math + Pmajor +
(1|section) + (1|quarter), family=binomial, data=survey.full, REML=F)
MEx47=lmer(cbind(c.score, w.score) ~ transfer + p.math + (1|section) +
(1|quarter), family=binomial, data=survey.full, REML=F)
MExAvg=model.avg(rank=AIC, MEx24, MEx7, MEx10, MEx47, MEx29, MEx22)

Error in model.avg.default(rank = AIC, MEx24, MEx7, MEx10, MEx47, MEx29,  :
   models are not all fitted to the same data
Lilly Dethier






The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] Error running MuMIn dredge function using glmer models

2013-11-08 Thread Kamil Bartoń

There is indeed a glitch in 'dredge' that prevents you from seeing the
actual error message. It is explained in ?dredge, in section Missing
values. (it's been corrected now in 1.9.14, on R-forge)

kamil



On 2013-11-08 11:00, r-help-requ...@r-project.org wrote:

--

Message: 26
Date: Thu, 7 Nov 2013 11:55:50 -0500
From: Martin Turcottemart.turco...@gmail.com
To:r-help@r-project.org
Subject: [R] Error running MuMIn dredge function using glmer models
Message-ID:1e4f5497-ccb4-4e8b-a23a-8aa5e1136...@gmail.com
Content-Type: text/plain

Dear list,
I am trying to use MuMIn to compare all possible mixed models using the dredge 
function on binomial data but I am getting an error message that I cannot 
decode. This error only occurs when I use glmer. When I use an lmer analysis on 
a different response variable every works great.

Example using a simplified glmer model
global model:
mod- glmer(cbind(st$X2.REP.LIVE, st$X2.REP.DEAD) ~ DOMESTICATION*GLUC + 
(1|PAIR), data=st, na.action=na.omit , family=binomial)

The response variables are the number of survival and dead insects (successes 
and failures)
DOMESTICATION is a 2 level factor.
GLUC is a continuous variable.
PAIR is coded as a factor or character (both ways fail).

This model functions correctly but when I try it with dredge() I get an error.

g- dredge(mod, beta=F, evaluate=F, rank='AIC')
Error in sprintf(gettext(fmt, domain = domain), ...) :
   invalid type of argument[1]: 'symbol'

When I try with another rank the same thing happens:
chat- deviance(mod)/58
g- dredge(mod, beta=F, evaluate=F, rank='QAIC', chat=chat)
Error in sprintf(gettext(fmt, domain = domain), ...) :
   invalid type of argument[1]: 'symbol'

Any suggestions would be greatly appreciated

thanks

Martin Turcotte, Ph. D.
mart.turco...@gmail.com






The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] Error message in dredge function (MuMIn package) used with binary GLM

2013-04-01 Thread Kamil Bartoń

Hi Cat,
are you using some very old version of MuMIn? That would explain the
missing 'QAICc'.
As for the error message about 'logLik', it usually occurs when there
are some misspelled arguments (that go into ... and are passed to the
rank function, 'AICc' in your case). Check if there is some argument (of
type logical) in your call to 'dredge' that is not its formal argument.

kamil

On 2013-03-30 03:13, cat.e.co...@gmail.com wrote:

Hi Kamil,

Thanks for your help. I do want to use rank=QAICc, but I when I try it I get 
the following error message:

Error in get(as.character(FUN), mode = function, envir = envir) :
   object 'QAICc' of mode 'function' was not found

Do I need to install another package that would recognise this?

When I leave the script with rank=AICc (to see if it will run), and having removed 
chat (which I put in after previously recieving an error message about it being missing 
from the formula), I still get my original error message:

Error in UseMethod(logLik) :
   no applicable method for 'logLik' applied to an object of class logical

Any further thoughts?
Thanks, Cat


quote author='Kamil Barton'
'rank' should be QAICc.
AICc does not have argument 'chat', hence the error.

kamil



Hi all,

I'm having trouble with the model generating 'dredge' function in the MuMIn
'Multi-model Inference' package.

Here's the script:

globalmodel- glm(TB~lat+protocol+tested+
streams+goats+hay+cattle+deer,
family=binomial)
chat- deviance(globalmodel)/59 #There we 59 residual degrees of freedom in
this global model.
models- dredge(globalmodel, beta=FALSE, evaluate=TRUE, rank=AICc,
chat=chat, fixed=NULL, trace=FALSE)

And the error message is:

Error in UseMethod(logLik) :
   no applicable method for 'logLik' applied to an object of class logical

I have trawled the literature and it seems to be ok to use a binary GLM as
the global model - could this be the problem? The variables are a mix of
binary and continuous data.

Any thoughts?
Thanks,
Cat


/quote
Quoted from:
http://r.789695.n4.nabble.com/Error-message-in-dredge-function-MuMIn-package-used-with-binary-GLM-tp4662842p4662881.html





The University of Aberdeen is a charity registered in Scotland, No SC013683.

__
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.


Re: [R] MuMIn Problem getting adjusted Confidence intervals

2012-06-28 Thread Kamil Bartoń

summary(model.avg(...)) gives much more information.

pozdrowienia,
kamil


Dnia 2012-06-28 12:00, KKulmakatarzyna.ku...@ebc.uu.se pisze:

Message: 60
From: KKulmakatarzyna.ku...@ebc.uu.se
To:r-help@r-project.org
Subject: Re: [R] MuMIn Problem getting adjusted Confidence intervals
Hello,

I seem to be having a similar problem, but with glmer models. Here,
model.avg() doesn't return anything but coefficient values:

fl19-glmer(  corrFLEDGE ~ INFECTION * rsLD * bin.age + (1 | year) + (1 |
RINGNO),data=corrmalaria,family=poisson)

fledglings-dredge(fl19)

top.fledglings- get.models(fledglings, subset = delta  5)

model.avg(top.fledglings)

Call:
model.avg.default(object = top.fledglings)

Component models:
?236? ?12346?   ?1236??123456?  ?12356?   ?1234567?

Coefficients:
  (Intercept) INFECTIONUninf   rsLD
 1.49862573 0.04925663
0.01954281



  INFECTIONUninf:rsLDbin.agejuv
bin.agejuv:INFECTIONUninf
 -0.03728832 0.10506037
-0.19701898


bin.agejuv:rsLD   bin.agejuv:INFECTIONUninf:rsLD
-0.01630556 0.02379715

Any ideas how I could solve that?

thanks for your help!
best,
Kasia



__
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.


Re: [R] MuMIn - assessing variable importance following model averaging, z-stats/p-values or CI?

2012-06-27 Thread Kamil Bartoń

p-value  0.05 means that the 95% confidence intervals span zero.
Use confint to get the CI. It is described in ?model.avg.

cheers,
kamil


Dnia 2012-06-27 12:00, Robertson, Andrew pisze:

Dear R users,

Recent changes to the MuMIn package now means that the model averaging command 
(model.avg) no longer returns confidence intervals, but instead returns zvalues 
and corresponding pvalues for fixed effects included in models.

Previously I have used this package for model selection/averaging following 
Greuber et al (2011) where it suggests that one should use confidence intervals 
from model averaging to assess whether your fixed effects have an affect or not 
 (If confidence intervals do not span zero then variable has an affect).

Can anyone tell me why MuMIn now gives z-stats and p-values and whether these 
should be used to assess the 'significance'/importance of variables when model 
averaging?


...

__
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.


Re: [R] R crashes due to stats.dll

2012-03-20 Thread Kamil Bartoń

Dnia 2012-03-18 01:15, Ted Stankowich pisze:

Hello!
I've been running a looped AIC analysis using several modules including ape, 
nlme, and MuMIn, and
during one particularly long analysis, R (ver 2.14.12) crashes several minutes 
into the routine with
the simple message R for windows GUI front-end has stopped working. I'm using 
a brand new laptop
with Windows 7, i7 processor, 8GB RAM. I've tried it on both the 64 bit and 32 
bit versions of R.
Using the 64 bit version, the analysis makes it through a few iterations before 
it crashes (maybe
about 20-25 min into the test).

...

Does anyone have any idea what might be going wrong here?



I assume you're using MuMIn::dredge. If so, most likely the model fitting function with some 
combination of parameters causes the crash. You can use 'trace = TRUE' argument for 'dredge' to find 
out which model is it. To see the output after the crash, use either R in console (not RGUI) or 
divert the output to a file with 'sink'.


kamil

__
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.


Re: [R] MuMIn package, problem using model selection table from manually created list of models

2012-01-17 Thread Kamil Bartoń

Dnieper 2012-01-17 10:51, Dunbar, Michael J. piste:


The subject says it all really.

Question 1.
Here is some code created to illustrate my problem, can anyone spot where I'm 
going wrong?

Question 2.
The reason I'm following a manual specification of models relates to the fact 
that in reality I am using mgcv::gam, and I'm not aware that dredge is able to 
separate individual smooth terms out of say s(a,b). Hence an additional 
request, if anyone has example code for using gam in a multimodel inference 
framework, especially with bivariate smooths, I'd be most grateful.


You can model average the coefficients, but not the terms.


Cheers and Thanks in Advance
Mike

require(MuMIn)
data(Cement)
# option 1, create model.selection object using dredge
fm0- lm(y ~ ., data = Cement)
print(dd- dredge(fm0))
fm1- lm(formula = y ~ X1 + X2, data = Cement)
fm2- lm(formula = y ~ X1 + X2 + X4, data = Cement)
fm3- lm(formula = y ~ X1 + X2 + X3, data = Cement)
fm4- lm(formula = y ~ X1 + X4, data = Cement)
fm5- lm(formula = y ~ X1 + X3 + X4, data = Cement)
# ranked with AICc by default
# obviously this works
model.avg(get.models(dd, delta  4))

#  option 2: the aim is to produce a model selection object comparable to that 
from get.models(dd, delta  4)
# but from a manually-specified list of models
my.manual.selection- mod.sel(list(fm1, fm2, fm3, fm4, fm5))
# works
model.avg(list(fm1, fm2, fm3, fm4, fm5)) # or jut model.avg(fm1, fm2, fm3, fm4, 
fm5)
# doesn't work
model.avg(my.manual.selection)



# hence this doesn't work
get.models(my.manual.selection, delta  4)


There is no need to recreate the models (which is what get.models does) once you have them already 
as a list.


models - list(fm1, fm2, fm3, fm4, fm5)
my.manual.selection - mod.sel(models)
model.avg(models[ my.manual.selection$delta  4 ])

__
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.


[R] Weird R's behaviour with a quoted name

2011-11-21 Thread Kamil Bartoń

Can someone explain why the following happens?
---
: quote(some.name)
some.name
: bar - structure(quote(some.name), class = foo)
: quote(some.name)
Error in print(some.name) : object 'some.name' not found
: bar - quote(some.name)
: quote(some.name)
Error in print(some.name) : object 'some.name' not found
: bar - as.name(some.name)
: quote(some.name)
some.name
---

__
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.


Re: [R] difficulties with MuMIn model generation with coxph

2011-10-26 Thread Kamil Bartoń

Dear Sophie,

The answer is 'typo'. 'dredge' does not have an argument named 'marge.ex'.

k


Dnia 2011-10-25 12:00, r-help-requ...@r-project.org pisze:

Message: 131
Date: Mon, 24 Oct 2011 17:08:41 -0700 (PDT)
From: sgilbertsophielgilb...@gmail.com
To:r-help@r-project.org
Subject: [R] difficulties with MuMIn model generation with coxph
Message-ID:1319501321733-3935078.p...@n4.nabble.com
Content-Type: text/plain; charset=us-ascii

Hi All,

I'm having trouble with the automatized model generation (dredge) function
in the MuMIn package. I'm trying to use it to automatically generate subsets
of models from a global cox proportional hazards model, and rank them based
on AICc. These seems like it's possible, and the Mumin documentation says
that coxph is supported. However, when I run the code (see below), it gives
me the following error message:

Error in UseMethod(logLik) :
   no applicable method for 'logLik' applied to an object of class logical

##RCode

#read in the data


data1-read.table('MaleData500.csv', sep=',', header=T)

survival-Surv(data1$Wks.at.dth, data1$Died)

#create the full (global) model, a coxph object


globemodel-coxph(survival~  edgeden + pctroad + pctcc90+ pctcc80 +

pctcrsog +  ravine + canfrag + pctoldc,  data=data1)

#evaluate all subsets of models using dredge


exhausting-dredge(globemodel, eval=TRUE, fixed=c(pctroad),m.max=3,

marge.ex=TRUE, rank=AICc)

Error in UseMethod(logLik) :
   no applicable method for 'logLik' applied to an object of class logical


any suggestions would be greatly appreciated. The globemodel works on its
own, and prints out a summary just fine. The only thing I can think of is
that in the names of globemodel, there is an attribute called loglik, not
logLik?

Thank you,

Sophie



__
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.


Re: [R] excluding models during dredge and model averaging in MuMIn

2011-09-06 Thread Kamil Bartoń

 dredge(x, subset = !(X1  (X2 | X3))  !(X2  X3)  !(X1  X3))
see  help(Logic, base)


Dnia 2011-08-26 12:00, r-help-requ...@r-project.org pisze:

--

Message: 157
Date: Fri, 26 Aug 2011 14:53:00 +0900
From: Andrew MacIntoshandyj...@gmail.com
To:R-help@r-project.org
Subject: [R] excluding models during dredge and model averaging in
MuMIn
Message-ID:
capsaz9rirdzxyn22jysmbunv7dvdwzbh44stab7wjcdtte_...@mail.gmail.com
Content-Type: text/plain; charset=ISO-8859-1

Dear R Users,

I am using the package MuMIn to sort through models, with the goal
of estimating parameters through model averaging of the candidate set.
I have been using the dredge function to build all possible models
based on my starting point (hypothetical global model). I see that
there is a simple way to control which models are excluded from this
set...

# exclude models containing both X1 and X2

dredge(x, subset = !(X1  X2))

However, I would like to add to this and exclude 4 different
combinations of predictors (i.e. X1X2, X1X3, X2X3, X1X2X3).

I would very much appreciate it if somebody had any ideas about how to
tackle this. Also,

Cheers,
Andrew


__
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.


Re: [R] MuMIn Problem getting adjusted Confidence intervals

2011-09-06 Thread Kamil Bartoń

Hi Marcos,

The 'adjusted CI' (based on the 'adjusted se estimator' as in section 4.3.3 of Burnham  Anderson 
2002) cannot be calculated for 'lmer' model because it does not give df's for the coefficients.


kamil


Dnia 2011-08-30 12:00, r-help-requ...@r-project.org pisze:

Message: 42
Date: Mon, 29 Aug 2011 08:28:22 -0700 (PDT)
From: Marcos Limarobalinho.l...@googlemail.com
To:r-help@r-project.org
Subject: [R] MuMIn Problem getting adjusted Confidence intervals
Message-ID:1314631702645-3776500.p...@n4.nabble.com
Content-Type: text/plain; charset=UTF-8

Hello R users

I'm using MuMIn but for some reason I'm not getting the adjusted confidence
interval and uncoditional SE whe I use model.avg().

I took into consideration the steps provided by Grueber et al (2011)
Multimodel inference in ecology and evolution: challenges and solutions in
JEB.

I created a global model to see if malaria prevalence (binomial
distribution) is related to any life history traits of 14 different birds
species, while controling for Family and genus in a GLMM:

global.model.Para-lmer(cbind(Parahaemoproteus,FailPh)~factor(SS)+factor(NT)+NH+W+IT+factor(MS)+(1|Family/Genus),family=binomial,data=malaria)

I than standardize the input variables using the function standardize form
the arm package:

stdz.model.Para-standardize(global.model.Para,standardize.y=FALSE)

But I get this message:
Warning messages lost:
In is.na(thedata):
is.na() aplied to an object different from list or vector of type Null

I then proceed to use the dredge fucntion:
model.set.Para-dredge(stdz.model.Para)
...



top.models.Para-get.models(model.set.Para,subset=delta=7)
top.models

But when I do the model average I do not seem to be getting  the variance or
Uncoditional SE and I'm guessing that the Confidence interval are no
conditional either:

model.avg(top.models.Para,method=NA)

...

Averaged model parameters:
 CoefficientSE Lower CI Upper CI
(Intercept)   -4.75 1.410   -7.510  -1.9900
factor(MS)1   -1.54 0.809   -3.120   0.0471
factor(NT)12.28 1.310   -0.286   4.8500
factor(SS)13.30 0.9681.400   5.2000
z.IT  -2.79 2.230   -7.160   1.5800
z.NH   2.28 1.660   -0.968   5.5300
z.W   -1.74 1.490   -4.650   1.1800
Confidence intervals are unadjusted

Relative variable importance:
factor(SS) factor(MS)   z.NH   z.ITz.W factor(NT)
   0.82   0.33   0.32   0.20   0.07   0.01

Does anyone know what I might be doing wrong?

thanks for the help

Marcos


__
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.


[R] Re: Sum weights of independent variables across models (AIC)

2011-07-14 Thread Kamil Bartoń
?model.avg

Look at relative importance.


 Message: 102
 Date: Wed, 13 Jul 2011 18:01:14 -0500
 From: Michael Just mgj...@gmail.com
 To: r-help r-help@r-project.org
 Subject: [R] Sum weights of independent variables across models (AIC)
 Message-ID:
   CAHdFeLNoQBAHYL=CJ3dB=jbculdpycgk03dncypf2obvkca...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1
 
 Hello,
 I'd like to sum the weights of each independent variable across linear
 models that have been evaluated using AIC.
 
 For example:
 
  library(MuMIn)
  data(Cement)
  lm1  -  lm(y  ~  .,  data  =  Cement)
  dd  -  dredge(lm1,  beta  = TRUE,  eval  =  TRUE,  rank  =  AICc)
  get.models(dd, subset = delta 4)
 There are 5 models with a Delta AIC Score of less than 4.  I would
 like to sum the weights for each of the independent variables across
 the five models.

__
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.