Random effect in combinations of models

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Random effect in combinations of models

Postby Ugoline Godeau » Fri Feb 27, 2015 10:49 am

Hello,
First I am sorry for my English. :wink:
I am, only until recently, working on the RMark package to calculate the survival of birds. I have little trouble to understand the documentation on it. I followed (and I think understandood) the steps of the “Workshop notes” (see below) because I want to compare several models. This gives me satisfactory results. But I want to improve some things.
First I would like that the function does not return phi for all sites but an average, but still integrate the effect of the site in the models for p. Is it possible ?
Then I want to put the effect of site in random effect, but I do not understand how to do this. Is this possible with this function ?
Thank you in advance :D

Code: Select all
TURMER.proc <- process.data (TURMER, model="CJS", begin.time=1989, groups= c("sexe","espece","site"))

TURMER.ddl<-make.design.data(TURMER.proc)

# Creation de la fonction do.analysis
do.analysis<-function(data.proc,data.ddl) {
    Phi.Time=list(formula=~Time)
    p.dot=list(formula=~1)
    p.sexe=list(formula=~sexe)
    p.sexe.espece=list(formula=~espece+sexe)
    p.sexe.iespece=list(formula=~sexe*espece)
    p.sexe.site=list(formula=~site+sexe)
    p.sexe.espece.site=list(formula=~espece+sexe+site)
    p.sexe.iespece.site=list(formula=~espece*sexe+site)
  cml<-create.model.list("CJS")
  model.list<-mark.wrapper(cml,data=data.proc,ddl=data.ddl)
  return(model.list)
}

results_TURMER<-do.analysis(TURMER.proc,TURMER.ddl)
Ugoline Godeau
 
Posts: 3
Joined: Fri Feb 27, 2015 9:55 am

Re: Random effect in combinations of models

Postby jlaake » Fri Feb 27, 2015 1:40 pm

You have to select the parameter values you want. Because any model is possible, any of the real parameter estimates can differ. The easiest way to get real estimates is with summary and if you specify se=TRUE it will return a list of databases (one for each parameter). Then you can select what you want or if you added design data you can merge them with the design data using model.index. See the dipper example below. You need to know R well enough to be able to understand and manipulate the results you get back from RMark.

Code: Select all
library(RMark)
data(dipper)
dp=process.data(dipper,groups="sex")
ddl=make.design.data(dp)
model=mark(dp,ddl,model.parameters=list(p=list(formula=~time+sex),Phi=list(formula=~Time)))
survival=summary(model,se=TRUE)$reals$Phi
survival=survival[survival$sex=="Female"&survival$cohort==1,]
with(survival,plot(Time,estimate))


With regard to random effects you need to use the cjsrandom model in MARK which you can run from RMark.
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Random effect in combinations of models

Postby Ugoline Godeau » Mon Mar 02, 2015 5:58 am

Thank you for your answer. But there still are some things I didn't understand well.
If I put like you said CJSrandom in the model in the function "process.data", I don't know how, in the function "do.analysis" after, I can say that I juste want the "site" to be in random effect, and the "sexe" and "espece" still be in fixed effects.
This case doesn't seem to appear in the documentation that I read.

Thank you in advance.

Code: Select all
TURMER.proc <- process.data (TURMER, model="CJSrandom", begin.time=1989, groups= c("sexe","espece","site"))

TURMER.ddl<-make.design.data(TURMER.proc)

# Creation de la fonction do.analysis
do.analysis<-function(data.proc,data.ddl) {
    Phi.Time=list(formula=~Time)
    p.dot=list(formula=~1)
    p.sexe=list(formula=~sexe)
    p.sexe.espece=list(formula=~espece+sexe)
    p.sexe.iespece=list(formula=~sexe*espece)
    p.sexe.site=list(formula=~site+sexe)
    p.sexe.espece.site=list(formula=~espece+sexe+site)
    p.sexe.iespece.site=list(formula=~espece*sexe+site)
  cml<-create.model.list("CJS")
  model.list<-mark.wrapper(cml,data=data.proc,ddl=data.ddl)
  return(model.list)
}
Ugoline Godeau
 
Posts: 3
Joined: Fri Feb 27, 2015 9:55 am

Re: Random effect in combinations of models

Postby jlaake » Mon Mar 02, 2015 12:25 pm

Sorry. I misunderstood. CJSRandom is only for individual random effects. What you want to do can be done in my R package marked but it is relatively new and a little more involved. When I get some time this week I'll create an example with some instructions on the marked sub-forum on how this can be done. There may be options with MCMC in MARK but it won't run from RMark at present. I suggest that you post to one of the other sub-forums asking how this can be done with MARK.
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Random effect in combinations of models

Postby Ugoline Godeau » Tue Mar 03, 2015 6:13 am

Thank you for your reply, I thought this was not possible with Rmark after all my research. I'll do otherwise, maybe I'll check your package when the examples will be available.
Thank you again
Ugoline
Ugoline Godeau
 
Posts: 3
Joined: Fri Feb 27, 2015 9:55 am

Re: Random effect in combinations of models

Postby Manon Ghislain » Sun Mar 29, 2015 4:18 pm

Hello Mr Laake,

I work with Ugoline and I've tried your R package marked.

First, it's a very good idea to use a similar language to Rmark it's very convenient, thank you!

But I have a problem when using random effects.

I've no problem when I use :

Code: Select all
model.12=crm(TURMER.proc,ddl=TURMER.ddl, external=FALSE, accumulate=FALSE
             , use.admb=TRUE
             , model.parameters=list(
               Phi=list(formula=~sexe+time+classAge),
               p=list(formula=~site+sexe+protoc)
             ))


but if I want to use a random effect on the site like that :

Code: Select all
model.13=crm(TURMER.proc,ddl=TURMER.ddl, external=FALSE, accumulate=FALSE
             , use.admb=TRUE
             , model.parameters=list(
               Phi=list(formula=~sexe+time+classAge),
               p=list(formula=~(1|site)+sexe+protoc)
             ))


It doesn't work... (I work with two values for sex, 25 for time, 2 for classAge, 2 for protocol, approximatly 200 for site and 10 000 individuals)

I probably made a mistake somewhere in the code, but I have not found an example using a random effect..

Would you have the solution to my problem?

Thank you very much for your handy package, I look forward to exploring MCMC options.

thank you for your answer

Manon Ghislain
Manon Ghislain
 
Posts: 3
Joined: Wed Oct 16, 2013 9:57 am

Re: Random effect in combinations of models

Postby Manon Ghislain » Mon Mar 30, 2015 7:41 am

in fact, it works with a species with fewer people (300 indivuals and 5 sites), but with the species of 10 000 individuals, I get this message :

2: running command 'C:\windows\system32\cmd.exe /c cjsre.exe -gh 14 -nohess > cjsre.out' had status 21
Manon Ghislain
 
Posts: 3
Joined: Wed Oct 16, 2013 9:57 am

Re: Random effect in combinations of models

Postby jlaake » Mon Mar 30, 2015 11:08 am

This message is about marked and should be on that sub-forum but I understand how it carries on from the previous message. This is very likely a lack of memory issue. Offlist send email to me jeff.laake@noaa.gov and let me know what version of R (32 or 64 bit) and marked you are using and how much memory you have in your computer. There are settings you can use with ADMB to help but 100K may end up being too much.

--jeff
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest