Can you fix and share parameters at the same time?

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

Can you fix and share parameters at the same time?

Postby aber_r16 » Wed Jun 17, 2015 3:16 am

HI, Im still working away on the Robust model, specifically moving towards using the create.model.list and mark.wrapper functions to run the full suite of models I'm interested in.

I appear to have to go back to basics however when coding the different temperary emigration/immigration parameters.

Below are the parameter specifications I think should work
Code: Select all
GammaDoublePrime.share.zero<-list(formula=~1, fixed=0, share=TRUE)#For no temporary emigration
GammaDoublePrime.share.dot<-list(formula=~1,share=TRUE)#For random but constant temporary emigration
GammaDoublePrime.share.time<-list(formula=~time,share=TRUE)#For random but time varying temporary emigration


When I run the robust model the random emigration models (.dot, and .time) work as expected. The the no emigration model does not. I get estimates of zeros for GammaDoublePrime, but 0.5 for GammaPrime.

If I code no emigration without the share=TRUE, then it works as expected with the estimates as zeros for both parameters.

Code: Select all
GammaDoublePrime.zero<-list(formula=~1, fixed=0)
GammaPrime.zero<-list(formula=~1, fixed=0)


So...is it not possible to fix a parameter and share it? Its not idea to code them as separate parameters as that adds many extra models that I'm not interested in the the do_analysis() function with create.model.list

Thanks! R
aber_r16
 
Posts: 18
Joined: Wed Feb 04, 2015 4:45 pm

Re: Can you fix and share parameters at the same time?

Postby jCeradini » Wed Jun 17, 2015 10:38 am

This worked for me when using share = TRUE for p and c as well as fixing different values for p and c. However, I'm using the older fix method based on indices, which works, but maybe isn't as intuitive (or flexible?) as the new method Jeff now generally recommends: fixing via a new field ('fix') in the design data, described here viewtopic.php?f=21&t=2887 and here viewtopic.php?f=21&t=2576&p=8172&hilit=fix+parameters#p8172. I have not 'shared' and 'fixed' while using the new fix method.

Code: Select all
p.formula <- list(formula = ~cover, share = TRUE, fixed = list(index=p.indices, value=p.values))

mark(data.proc, data.ddl,
model.parameters = list(S=S.formula,
GammaPrime = GammaPrime.formula,
GammaDoublePrime = GammaDouble.formula,
p = p.formula,
c = list(fixed=list(index=c.indices, value=c.values))))


Joe
jCeradini
 
Posts: 74
Joined: Mon Oct 13, 2014 3:53 pm

Re: Can you fix and share parameters at the same time?

Postby jlaake » Wed Jun 17, 2015 11:30 am

Thanks for your reply Joe. The "new" approach to fixing real parameters only works if they are to be fixed for all models because the fixed parameters are specified in the design data list (ddl) which is then used for all models.

Robin I would have thought what you did should have worked, but it doesn't and I'll have to look into it. It probably doesn't work because I have to do some manipulation when parameters are shared. There are lots of other options here.

1) The first one is described in the NicholsMSOccupancy example. You can merge 2 model specifications into a single list so it does not create additional models that you don't want.

GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1, fixed=0),GammaPrime=list(formula=~1,fixed=0))

I did find one minor little bug with that approach that I'll fix eventually. At present it only works if you specify a model for at least one other parameter. But you are specifying the other parameter models so it should work fine. If you use that approach, all of the GammaDoublePrime and GammaPrime models should be paired in a list like above or specified for GammaDoublePrime with share=TRUE.

2) create.model.list creates a dataframe of all combinations of formula names. You can always subset it to remove any you don't want to run prior to calling mark.wrapper.

3) you can run separate sets of models with mark.wrapper and then use merge.mark to merge the sets.

4) Joe's solution also appears to work.
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Can you fix and share parameters at the same time?

Postby aber_r16 » Wed Jun 17, 2015 11:59 am

Thanks Guys!

I do like the first option of merging the specifications into a single list as that will eliminate the necessity of editing the data frame created by create.model.list - keeps it as tidy as possible!. In my case it will work because I will be specifying several other parameter models.

Cheers, R
aber_r16
 
Posts: 18
Joined: Wed Feb 04, 2015 4:45 pm

Re: Can you fix and share parameters at the same time?

Postby aber_r16 » Thu Jun 18, 2015 12:24 am

jlaake wrote:
1) The first one is described in the NicholsMSOccupancy example. You can merge 2 model specifications into a single list so it does not create additional models that you don't want.

GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1, fixed=0),GammaPrime=list(formula=~1,fixed=0))

I did find one minor little bug with that approach that I'll fix eventually. At present it only works if you specify a model for at least one other parameter. But you are specifying the other parameter models so it should work fine. If you use that approach, all of the GammaDoublePrime and GammaPrime models should be paired in a list like above or specified for GammaDoublePrime with share=TRUE.


Sorry to be a nuisance but...this list approach is not working. I tried the following two approaches (yours as above, and also with share=FALSE as done in NicholsMSOccupancy) both with the robust, and RDFullHet models and get this error message

Code: Select all
GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1,fixed=0),GammaPrime=list(formula=~1,fixed=0))
GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1,fixed=0, share=FALSE),GammaPrime=list(formula=~1,fixed=0))


Code: Select all
Invalid model specification for parameter GammaDoublePrime.
Unrecognized element GammaDoublePrime
Error in make.mark.model(data.proc, title = title, parameters = model.parameters,  :
 
Error in mark(fw.hist1.proc.FULLHET, model = "RDFullHet", model.name = "S(*) GDP=GP=0 p=c(*) pi=1",  :
  Misspecification of model or internal error in code


Perhaps another bug?
aber_r16
 
Posts: 18
Joined: Wed Feb 04, 2015 4:45 pm

Re: Can you fix and share parameters at the same time?

Postby jlaake » Thu Jun 18, 2015 10:13 am

Works fine for me. See below. I can only guess that you did what I said would fail by not including another parameter specification. The first one of these works and the second does not which is the bug I mentioned.

WORKS!
Code: Select all
library(RMark)
data(robust)
dp=process.data(robust,model="RDFullHet",time.intervals=c(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0))
ddl=make.design.data(dp)
doit=function()
{
#Parameters for survival.  Include constant and time.   
S.dot<-list(formula=~1)
#Parameters for GammaDoublePrime (dominant when shared)
GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1,fixed=0),GammaPrime=list(formula=~1,fixed=0))
GammaDoublePrime.both.zero.ns<-list(GammaDoublePrime=list(formula=~1,fixed=0, share=FALSE),GammaPrime=list(formula=~1,fixed=0))
#Parameters for p
p.dot<-list(formula=~1,share=TRUE)#constant propability of capture over all sessions all years
#Parameters for pi
pi.dot<-list(formula=~1)#time constant heterogenity
#With these three parameter specifications I would expect one model S(*)GDP=GP(*)p=c(*)
cml<-create.model.list("RDFullHet")
mark.wrapper(cml,data=dp,ddl=ddl)
}
doit()


DOESN'T WORK - Have to specify one other parameter
Code: Select all
library(RMark)
data(robust)
dp=process.data(robust,model="RDFullHet",time.intervals=c(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0))
ddl=make.design.data(dp)
doit=function()
{
GammaDoublePrime.both.zero<-list(GammaDoublePrime=list(formula=~1,fixed=0),GammaPrime=list(formula=~1,fixed=0))
GammaDoublePrime.both.zero.ns<-list(GammaDoublePrime=list(formula=~1,fixed=0, share=FALSE),GammaPrime=list(formula=~1,fixed=0))
#With these three parameter specifications I would expect one model S(*)GDP=GP(*)p=c(*)
cml<-create.model.list("RDFullHet")
mark.wrapper(cml,data=dp,ddl=ddl)
}
doit()
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 0 guests