time.bins and non identifiable N in RD

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

time.bins and non identifiable N in RD

Postby monicaarso » Fri Jun 22, 2012 11:41 am

Hi,

I have searched through help files, read Appendix C, read other posts... and I am officially stuck; any help would be much appreciated.

I am running robust design on a 13 primary occasion dataset starting in 1998 all the way to 2010. Each primary occasion (which corresponds to the May-September period for each year) has a variable number of secondary occasions. In all of the models, p=c, S can be constant or time dependant. Data are based on photo-id data of well-marked individuals from a dolphin population.

I have problems defining time.bins, having tried the following:

#1a- For my set of random movement models I want to constrain the gammas so that the g'(k-1)=g'(k) and g''(k-1)=g''(k) being k number of primary sampling occasions. With the code shown below, some models get an error message (shown below), and others run, but when I check the results (real) or the PIM structure for the gammas, they are not constrained. Any ideas what am I doing wrong?

Code: Select all
#convert inp file
rd.data=convert.inp("G:/PhD/MR Analysis/analysis 1989-2010/rmark RD/CH 1998-2010 all areas_RD.inp",use.comments=T)

#Process data specifying primary and secondary capture occasions
time.intervals=c(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0)
rd.process=process.data(rd.data,begin.time=1998,model="Robust",time.intervals=time.intervals)

#Create the design data
rd.ddl=make.design.data(rd.process)

#Create time bins for GammaPrime and GammaDoublePrime
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaPrime",type="time",bins=c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gammaconstrain",replace=TRUE)
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaDoublePrime",type="time",bins=c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gamma2constrain",replace=TRUE)

rd.random.models=function()
{
  S.dot=list(formula=~1)
  S.time=list(formula=~time)
  p.dot=list(formula=~1+c,share=T)
  p.time.session=list(formula=~-1+session:time+c,share=TRUE)
  p.session=list(formula=~session+c,share=T)
  GammaDoublePrime.GammaPrime.random=list(formula=~1,share=T)
  GammaDoublePrime.GammaPrime.session.random=list(formula=~time,share=T)
  N.session=list(formula=~session)
  cml=create.model.list("Robust")
  results=mark.wrapper(cml,data=rd.process,ddl=rd.ddl,adjust=FALSE)
  return(results) 
}
rd.random.results=rd.random.models()


when I run the models, some of them get the following type of error message:

Code: Select all
S.dot.GammaDoublePrime.GammaPrime.random.GammaPrime.session.random.p.dot.N.session
Error in match.names(clabs, names(xi)) :
  names do not match previous names


#1b- if I define the time.bins for the gammas with the add.design.data, and then run one specific model instead of using the function for all possible parameter combinations, then I get a different error message:

Code: Select all
#convert inp file
rd.data=convert.inp("G:/PhD/MR Analysis/analysis 1989-2010/rmark RD/CH 1998-2010 all areas_RD.inp",use.comments=T)
#Process data specifying primary and secondary capture occasions
time.intervals=c(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0)
rd.process=process.data(rd.data,begin.time=1998,model="Robust",time.intervals=time.intervals)
#Create the design data
rd.ddl=make.design.data(rd.process)

rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaPrime",type="time",bins=c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gammaconstrain",replace=TRUE)
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaDoublePrime",type="time",bins=c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gamma2constrain",replace=TRUE)

 S.dot=list(formula=~1)
  S.time=list(formula=~time)
  p.dot=list(formula=~1+c,share=T)
  p.time.session=list(formula=~-1+session:time+c,share=TRUE)
  p.session=list(formula=~session+c,share=T)
  GammaDoublePrime.GammaPrime.random=list(formula=~1,share=T)
  GammaDoublePrime.GammaPrime.session.random=list(formula=~time,share=T)
  N.session=list(formula=~session)

model1=mark(rd.process,rd.ddl,model="Robust",          model.parameters=list(S=S.dot,GammaDoublePrime=GammaDoublePrime.GammaPrime.session.random,p=p.dot))

Error in match.names(clabs, names(xi)) :
  names do not match previous names


#1c- if I define the bins within the model, then it runs ok but the bins are not created, as I still get 12 different estimates for gamma'' and 11 for gamma' (there are 13 primary occasions)

Code: Select all
#(after converting inp file, setting time intervals, process.data, make.design.data, as before)
  S.dot=list(formula=~1)
  S.time=list(formula=~time)
  p.dot=list(formula=~1+c,share=T)
  p.time.session=list(formula=~-1+session:time+c,share=TRUE)
  p.session=list(formula=~session+c,share=T)
  GammaDoublePrime.GammaPrime.random=list(formula=~1,share=T)
  GammaDoublePrime.GammaPrime.session.random=list(formula=~time,share=T)
  model=mark(rd.process,rd.ddl,model="Robust",
           design.parameters=(list(GammaDoublePrime=list(time.bins=c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2010)),GammaPrime=list(time.bins=c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2010)))),
           right=FALSE,
           model.parameters=list(S=S.dot,GammaDoublePrime=GammaDoublePrime.GammaPrime.session.random,p=p.dot))


Any tips on what I am doing wrong will be great, I don't seem to see it even if it might be very obvious.

This is for the random movement models (haven't dealt with Markovian until I get this bins issue solved).

On the other hand, my no-movement models seem to work ok except that for the models where p is time dependant, some of the N estimates are not estimated and instead the number of captured individuals is reported. But it only happens for a couple of the years. See below the code for one of the models that does that, the results$real and the beta values.
Note: in all models, again, p=c, which I thought it would be enough to put a constrain in p to make N estimable. Also, in the results, p is estimated for the last occasion in those years that N is not estimated, so neither is the case where p=1 and so N=Mt+1

Code: Select all
#convert inp file
rd.data=convert.inp("G:/PhD/MR Analysis/analysis 1989-2010/rmark RD/CH 1998-2010 all areas_RD.inp",use.comments=T)
#Process data specifying primary and secondary capture occasions
time.intervals=c(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0)
rd.process=process.data(rd.data,begin.time=1998,model="Robust",time.intervals=time.intervals)
#Create the design data
rd.ddl=make.design.data(rd.process)
 S.dot=list(formula=~1)
 S.time=list(formula=~time)
 p.dot=list(formula=~1,share=TRUE)
 p.time.session=list(formula=~-1+session:time,share=TRUE)
 p.session=list(formula=~session,share=T)
 GammaDoublePrime.0=list(formula=~1,fixed=0)
 GammaPrime.0=list(formula=~1,fixed=0)
 N.session=list(formula=~session)

model6=mark(rd.process,rd.ddl,model="Robust",                     model.parameters=list(S=S.dot,p=p.time.session,GammaDoublePrime=GammaDoublePrime.0,GammaPrime=GammaPrime.0))


this is the output for that model (note that the N estimates for 2009 and 2010 are 89 and 97, which are the number of captured individuals for those two years):

Code: Select all
Output summary for Robust model
Name : S(~time)Gamma''(~1)Gamma'(~1)p(~-1 + session:time)c()N(~session)

Npar :  125  (unadjusted=123)
-2lnL:  4117.058
AICc :  4378.576  (unadjusted=4374.2034)
                                  estimate           se        lcl        ucl fixed                 note
S g1 c1998 c1 a0 o1 t1998        0.9058656 0.0601092000  0.7073524  0.9745628                           
S g1 c1998 c1 a1 o1 t1999        0.9483116 0.0410333000  0.7805159  0.9895456                           
S g1 c1998 c1 a2 o1 t2000        0.9768313 0.0256967000  0.8199624  0.9974444                           
S g1 c1998 c1 a3 o1 t2001        0.8984081 0.0349453000  0.8067809  0.9493142                           
S g1 c1998 c1 a4 o1 t2002        0.9352576 0.0283839000  0.8521586  0.9731214                           
S g1 c1998 c1 a5 o1 t2003        0.9774194 0.0172626000  0.9033321  0.9950374                           
S g1 c1998 c1 a6 o1 t2004        0.9253348 0.0283700000  0.8471372  0.9651745                           
S g1 c1998 c1 a7 o1 t2005        0.9510816 0.0242276000  0.8750971  0.9818023                           
S g1 c1998 c1 a8 o1 t2006        0.9348040 0.0260223000  0.8612923  0.9706824                           
S g1 c1998 c1 a9 o1 t2007        0.8924278 0.0331125000  0.8084145  0.9422326                           
S g1 c1998 c1 a10 o1 t2008       0.9602871 0.0224595000  0.8840386  0.9871296                           
S g1 c1998 c1 a11 o1 t2009       0.9782865 0.0153931000  0.9158726  0.9946654                           
p g1 s1998 t1                    0.4129289 0.0949053000  0.2461602  0.6023955                           
p g1 s1998 t2                    0.3811645 0.0927678000  0.2217580  0.5710740                           
p g1 s1998 t3                    0.4446914 0.0967441000  0.2709095  0.6331435                           
p g1 s1998 t4                    0.3811623 0.0927674000  0.2217566  0.5710713                           
p g1 s1999 t1                    0.0670149 0.0376608000  0.0215822  0.1895582                           
p g1 s1999 t2                    0.4914361 0.0821516000  0.3365925  0.6479405                           
p g1 s1999 t3                    0.2903939 0.0707825000  0.1726840  0.4451664                           
p g1 s1999 t4                    0.2680549 0.0687721000  0.1555749  0.4212855                           
p g1 s2000 t1                    0.2449047 0.0604149000  0.1460029  0.3809192                           
p g1 s2000 t2                    0.4144558 0.0710472000  0.2850840  0.5568113                           
p g1 s2000 t3                    0.1130335 0.0438646000  0.0512871  0.2310166                           
p g1 s2000 t4                    0.2825833 0.0635644000  0.1756320  0.4213726                           
p g1 s2001 t1                    0.4460589 0.0564343000  0.3397829  0.5575062                           
p g1 s2001 t2                    0.1401899 0.0392391000  0.0793095  0.2358333                           
p g1 s2001 t3                    0.5225237 0.0568216000  0.4118722  0.6310078                           
p g1 s2001 t4                    0.5225248 0.0568223000  0.4118718  0.6310103                           
p g1 s2001 t5                    0.6117352 0.0556268000  0.4988935  0.7137465                           
p g1 s2001 t6                    0.1911674 0.0444651000  0.1185656  0.2934264                           
p g1 s2001 t7                    0.1147013 0.0360069000  0.0607342  0.2061001                           
p g1 s2001 t8                    0.0892123 0.0322019000  0.0431045  0.1755900                           
p g1 s2002 t1                    0.1770094 0.0429559000  0.1076773  0.2771196                           
p g1 s2002 t2                    0.0758623 0.0297827000  0.0344702  0.1587846                           
p g1 s2002 t3                    0.2022964 0.0452182000  0.1277262  0.3051714                           
p g1 s2002 t4                    0.4678142 0.0563130000  0.3607173  0.5779612                           
p g1 s2002 t5                    0.4298803 0.0558433000  0.3254286  0.5409718                           
p g1 s2002 t6                    0.3160890 0.0523823000  0.2232657  0.4263223                           
p g1 s2002 t7                    0.4298806 0.0558429000  0.3254296  0.5409713                           
p g1 s2002 t8                    0.1643669 0.0417070000  0.0978584  0.2629044                           
p g1 s2002 t9                    0.2781574 0.0504670000  0.1905776  0.3867536                           
p g1 s2003 t1                    0.2262825 0.0457047000  0.1491751  0.3278865                           
p g1 s2003 t2                    0.2977390 0.0499676000  0.2097421  0.4037907                           
p g1 s2003 t3                    0.1667355 0.0407028000  0.1012738  0.2621674                           
p g1 s2003 t4                    0.4049241 0.0536836000  0.3054119  0.5129170                           
p g1 s2003 t5                    0.3930125 0.0534093000  0.2945293  0.5010384                           
p g1 s2003 t6                    0.3572856 0.0523864000  0.2622508  0.4650503                           
p g1 s2003 t7                    0.4763822 0.0546592000  0.3719108  0.5829620                           
p g1 s2003 t8                    0.2858288 0.0493678000  0.1994486  0.3913325                           
p g1 s2004 t1                    0.1305290 0.0351492000  0.0756259  0.2159779                           
p g1 s2004 t2                    0.0978965 0.0310026000  0.0517161  0.1775913                           
p g1 s2004 t3                    0.1522819 0.0374903000  0.0922867  0.2409277                           
p g1 s2004 t4                    0.2284243 0.0438194000  0.1538738  0.3252114                           
p g1 s2004 t5                    0.4786027 0.0522276000  0.3785147  0.5804386                           
p g1 s2004 t6                    0.7505335 0.0454923000  0.6514082  0.8288763                           
p g1 s2004 t7                    0.4024619 0.0512378000  0.3072912  0.5055944                           
p g1 s2004 t8                    0.2284246 0.0438193000  0.1538742  0.3252115                           
p g1 s2004 t9                    0.1196503 0.0338612000  0.0674952  0.2033196                           
p g1 s2005 t1                    0.1048317 0.0330705000  0.0554425  0.1893959                           
p g1 s2005 t2                    0.1514234 0.0387032000  0.0899829  0.2435862                           
p g1 s2005 t3                    0.1747191 0.0410025000  0.1081394  0.2698864                           
p g1 s2005 t4                    0.1980143 0.0430336000  0.1267638  0.2957494                           
p g1 s2005 t5                    0.5125054 0.0540802000  0.4075212  0.6163976                           
p g1 s2005 t6                    0.2911956 0.0490795000  0.2049485  0.3956745                           
p g1 s2005 t7                    0.3843765 0.0525774000  0.2877149  0.4911214                           
p g1 s2005 t8                    0.2446054 0.0464275000  0.1651942  0.3463526                           
p g1 s2005 t9                    0.1514225 0.0387032000  0.0899822  0.2435853                           
p g1 s2006 t1                    0.2836473 0.0471060000  0.2008760  0.3841303                           
p g1 s2006 t2                    0.1745531 0.0396576000  0.1097630  0.2661532                           
p g1 s2006 t3                    0.2509173 0.0453020000  0.1727689  0.3494806                           
p g1 s2006 t4                    0.2727372 0.0465402000  0.1914425  0.3726430                           
p g1 s2006 t5                    0.5672943 0.0518364000  0.4642922  0.6647903                           
p g1 s2006 t6                    0.5891141 0.0514830000  0.4858626  0.6850705                           
p g1 s2006 t7                    0.2181897 0.0431543000  0.1452825  0.3142328                           
p g1 s2006 t8                    0.6436640 0.0501383000  0.5406218  0.7349257                           
p g1 s2006 t9                    0.1963727 0.0415055000  0.1273474  0.2903624                           
p g1 s2007 t1                    0.2098499 0.0428033000  0.1380254  0.3057908                           
p g1 s2007 t2                    0.2540291 0.0457613000  0.1750066  0.3534466                           
p g1 s2007 t3                    0.1877626 0.0410489000  0.1200278  0.2814943                           
p g1 s2007 t4                    0.5964145 0.0516221000  0.4925508  0.6923001                           
p g1 s2007 t5                    0.6295486 0.0508219000  0.5257681  0.7226004                           
p g1 s2007 t6                    0.4859672 0.0525662000  0.3849501  0.5881439                           
p g1 s2007 t7                    0.4307458 0.0520721000  0.3329129  0.5343015                           
p g1 s2007 t8                    0.2650736 0.0463989000  0.1844346  0.3651829                           
p g1 s2007 t9                    0.3092541 0.0485900000  0.2227973  0.4114974                           
p g1 s2007 t10                   0.3423878 0.0498888000  0.2521925  0.4456185                           
p g1 s2008 t1                    0.1466135 0.0391147000  0.0851650  0.2407317                           
p g1 s2008 t2                    0.1954817 0.0438610000  0.1233149  0.2956398                           
p g1 s2008 t3                    0.2565703 0.0483159000  0.1735965  0.3618386                           
p g1 s2008 t4                    0.3298779 0.0520335000  0.2368389  0.4384670                           
p g1 s2008 t5                    0.3054421 0.0509672000  0.2154478  0.4132281                           
p g1 s2008 t6                    0.3054416 0.0509672000  0.2154473  0.4132277                           
p g1 s2008 t7                    0.3298789 0.0520335000  0.2368398  0.4384680                           
p g1 s2008 t8                    0.2443536 0.0475349000  0.1633462  0.3487869                           
p g1 s2009 t1                    0.1650513 0.0389354000  0.1020295  0.2559068                           
p g1 s2009 t2                    0.3411065 0.0497131000  0.2512608  0.4440269                           
p g1 s2009 t3                    0.3851211 0.0510247000  0.2910694  0.4886171                           
p g1 s2009 t4                    0.6161888 0.0509594000  0.5127662  0.7100712                           
p g1 s2009 t5                    0.7922423 0.0424523000  0.6969825  0.8634234                           
p g1 s2009 t6                    0.8142489 0.0406797000  0.7212549  0.8813233                           
p g1 s2009 t7                    0.4291319 0.0518933000  0.3316841  0.5324020                           
p g1 s2009 t8                    0.2640826 0.0462322000  0.1837536  0.3638733                           
p g1 s2009 t9                    0.2530781 0.0455964000  0.1743595  0.3521766                           
p g1 s2010 t1                    0.2268064 0.0425190000  0.1542495  0.3205573                           
p g1 s2010 t2                    0.3814491 0.0493191000  0.2904714  0.4815812                           
p g1 s2010 t3                    0.7216517 0.0455063000  0.6244878  0.8016594                           
p g1 s2010 t4                    0.5979396 0.0497835000  0.4977530  0.6905652                           
p g1 s2010 t5                    0.8350527 0.0376826000  0.7475627  0.8964216                           
p g1 s2010 t6                    0.3505212 0.0484452000  0.2623409  0.4502499                           
p g1 s2010 t7                    0.4226861 0.0501560000  0.3285807  0.5227590                           
p g1 s2010 t8                    0.6494885 0.0484450000  0.5497599  0.7376680                           
p g1 s2010 t9                    0.7422711 0.0444094000  0.6462996  0.8194757                           
N g1 s1998                      31.4826950 2.7562467000 28.8877700 41.6625110                           
N g1 s1999                      44.6145960 5.2008059000 38.2761970 60.3480950                           
N g1 s2000                      46.8067430 5.5557213000 39.6750490 62.9006620                           
N g1 s2001                      73.5150810 1.5588665000 72.2865040 80.0120120                           
N g1 s2002                      67.4268770 1.8935150000 65.6282070 74.3754640                           
N g1 s2003                      76.5135090 1.9153203000 74.6672860 83.4677890                           
N g1 s2004                      91.9887190 1.7394957000 90.4538790 98.7137810                           
N g1 s2005                      57.4634490 2.2365006000 55.0888790 65.0163580                           
N g1 s2006                      85.5683970 1.1152395000 85.0484230 91.6719380                           
N g1 s2007                      82.0169280 0.8089451000 82.0000730 85.9431000                           
N g1 s2008                      44.2260300 2.1684409000 41.9748300 51.6759870                           
N g1 s2009                      89.0000020 0.0010356000 89.0000000 89.0018080                           
N g1 s2010                      97.0000010 0.0004884771 97.0000000 97.0008690                           
Gamma'' g1 c1998 c1 a0 o1 t1998  0.0000000 0.0000000000  0.0000000  0.0000000 Fixed   


I don't really understand why the model is not able to estimate N for those two years specifically, and does ok for the others. Maybe it is something to do with the capture history structure for those two years? The interesting (or even more confusing) thing is that when I run the same model but p=c with the additional covariate c in the design data, then all N are estimated BUT all of them are also much higher and with also higher SE. Any thoughts on why this happens and whether I should actually add the +c to the design data of p,c?:

Code: Select all
 S.dot=list(formula=~1)
 S.time=list(formula=~time)
 p.dot=list(formula=~1+c,share=TRUE)
 p.time.session=list(formula=~-1+session:time+c,share=TRUE)
 p.session=list(formula=~session+c,share=T)
 GammaDoublePrime.0=list(formula=~1,fixed=0)
 GammaPrime.0=list(formula=~1,fixed=0)
 N.session=list(formula=~session)

model6c=mark(rd.process,rd.ddl,model="Robust",                     model.parameters=list(S=S.dot,p=p.time.session,GammaDoublePrime=GammaDoublePrime.0,GammaPrime=GammaPrime.0))


with the output:

Code: Select all
                                   estimate           se           lcl         ucl fixed                 note
S g1 c1998 c1 a0 o1 t1998         0.9245139 6.478470e-02  6.650399e-01   0.9869367                           
S g1 c1998 c1 a1 o1 t1999         0.9447570 5.116360e-02  7.145894e-01   0.9915121                           
S g1 c1998 c1 a2 o1 t2000         0.9941704 3.466630e-02  1.379300e-03   1.0000000                           
S g1 c1998 c1 a3 o1 t2001         0.8996391 4.045360e-02  7.883565e-01   0.9556972                           
S g1 c1998 c1 a4 o1 t2002         0.9281658 3.455540e-02  8.239052e-01   0.9727392                           
S g1 c1998 c1 a5 o1 t2003         0.9840623 2.256420e-02  7.863622e-01   0.9990354                           
S g1 c1998 c1 a6 o1 t2004         0.9252958 3.308860e-02  8.289706e-01   0.9693741                           
S g1 c1998 c1 a7 o1 t2005         0.9486041 2.979090e-02  8.478443e-01   0.9839058                           
S g1 c1998 c1 a8 o1 t2006         0.9415617 2.964720e-02  8.485786e-01   0.9788687                           
S g1 c1998 c1 a9 o1 t2007         0.8886062 3.742110e-02  7.917671e-01   0.9436171                           
S g1 c1998 c1 a10 o1 t2008        0.9531928 2.766970e-02  8.579355e-01   0.9856466                           
S g1 c1998 c1 a11 o1 t2009        0.9999999 2.137525e-05 2.981323e-295   1.0000000                           
p g1 s1998 t1                     0.1925207 6.958630e-02  9.021110e-02   0.3643883                           
p g1 s1998 t2                     0.1132863 4.159110e-02  5.370160e-02   0.2233775                           
p g1 s1998 t3                     0.1132042 3.922160e-02  5.603110e-02   0.2154034                           
p g1 s1998 t4                     0.0733135 2.557480e-02  3.644970e-02   0.1419668                           
p g1 s1999 t1                     0.0550546 3.170310e-02  1.734040e-02   0.1613280                           
p g1 s1999 t2                     0.3808693 8.309190e-02  2.356807e-01   0.5510187                           
p g1 s1999 t3                     0.1002314 3.210400e-02  5.253170e-02   0.1828829                           
p g1 s1999 t4                     0.0792919 2.617020e-02  4.090990e-02   0.1481228                           
p g1 s2000 t1                     0.2169767 5.692270e-02  1.256421e-01   0.3482608                           
p g1 s2000 t2                     0.2735472 6.274660e-02  1.686003e-01   0.4114877                           
p g1 s2000 t3                     0.0336688 1.463270e-02  1.422480e-02   0.0775989                           
p g1 s2000 t4                     0.0991872 2.946940e-02  5.453980e-02   0.1736703                           
p g1 s2001 t1                     0.3985541 5.566070e-02  2.959607e-01   0.5109036                           
p g1 s2001 t2                     0.0478759 1.561330e-02  2.505230e-02   0.0895821                           
p g1 s2001 t3                     0.2849383 5.085730e-02  1.963400e-01   0.3939201                           
p g1 s2001 t4                     0.2137210 4.154180e-02  1.434205e-01   0.3061641                           
p g1 s2001 t5                     0.2277914 4.328300e-02  1.540600e-01   0.3233230                           
p g1 s2001 t6                     0.0378783 1.083910e-02  2.150540e-02   0.0658773                           
p g1 s2001 t7                     0.0210926 7.489200e-03  1.047300e-02   0.0420233                           
p g1 s2001 t8                     0.0160197 6.362200e-03  7.326700e-03   0.0346665                           
p g1 s2002 t1                     0.1691609 4.152190e-02  1.024185e-01   0.2664840                           
p g1 s2002 t2                     0.0424928 1.792820e-02  1.836730e-02   0.0952328                           
p g1 s2002 t3                     0.1220763 3.221620e-02  7.161880e-02   0.2004087                           
p g1 s2002 t4                     0.3011751 5.222320e-02  2.094838e-01   0.4120791                           
p g1 s2002 t5                     0.2132409 4.246940e-02  1.416494e-01   0.3080309                           
p g1 s2002 t6                     0.1297336 3.005210e-02  8.128440e-02   0.2007505                           
p g1 s2002 t7                     0.1781867 3.687370e-02  1.168893e-01   0.2620889                           
p g1 s2002 t8                     0.0401579 1.223390e-02  2.196630e-02   0.0723015                           
p g1 s2002 t9                     0.0783393 1.940440e-02  4.779410e-02   0.1258263                           
p g1 s2003 t1                     0.2167544 4.443250e-02  1.421374e-01   0.3161089                           
p g1 s2003 t2                     0.1959967 4.073340e-02  1.280684e-01   0.2880520                           
p g1 s2003 t3                     0.0750577 2.179280e-02  4.201790e-02   0.1305375                           
p g1 s2003 t4                     0.2370103 4.451970e-02  1.608835e-01   0.3347870                           
p g1 s2003 t5                     0.1569620 3.274260e-02  1.028462e-01   0.2321833                           
p g1 s2003 t6                     0.1113555 2.448390e-02  7.162980e-02   0.1691000                           
p g1 s2003 t7                     0.1548691 3.102350e-02  1.032625e-01   0.2257732                           
p g1 s2003 t8                     0.0675800 1.611650e-02  4.205680e-02   0.1068649                           
p g1 s2004 t1                     0.1265806 3.426630e-02  7.316770e-02   0.2101443                           
p g1 s2004 t2                     0.0645408 2.207430e-02  3.259830e-02   0.1237783                           
p g1 s2004 t3                     0.0959249 2.670550e-02  5.484130e-02   0.1624942                           
p g1 s2004 t4                     0.1308916 3.067990e-02  8.153330e-02   0.2035095                           
p g1 s2004 t5                     0.3334664 5.070010e-02  2.423876e-01   0.4389405                           
p g1 s2004 t6                     0.5244210 6.540250e-02  3.974217e-01   0.6483384                           
p g1 s2004 t7                     0.1050102 2.141110e-02  6.983150e-02   0.1549583                           
p g1 s2004 t8                     0.0456465 1.133120e-02  2.792460e-02   0.0737618                           
p g1 s2004 t9                     0.0212338 6.865300e-03  1.122690e-02   0.0398010                           
p g1 s2005 t1                     0.1033161 3.265890e-02  5.458500e-02   0.1869494                           
p g1 s2005 t2                     0.1144812 3.192070e-02  6.519710e-02   0.1933160                           
p g1 s2005 t3                     0.1174555 3.132730e-02  6.855590e-02   0.1939707                           
p g1 s2005 t4                     0.1263760 3.208870e-02  7.564440e-02   0.2036358                           
p g1 s2005 t5                     0.3968359 5.565340e-02  2.943416e-01   0.5092632                           
p g1 s2005 t6                     0.1074524 2.498830e-02  6.737630e-02   0.1670953                           
p g1 s2005 t7                     0.1547025 3.224990e-02  1.014194e-01   0.2288498                           
p g1 s2005 t8                     0.0770925 1.928280e-02  4.680990e-02   0.1244088                           
p g1 s2005 t9                     0.0420959 1.278160e-02  2.306580e-02   0.0756113                           
p g1 s2006 t1                     0.2771301 4.648040e-02  1.956823e-01   0.3766052                           
p g1 s2006 t2                     0.0890653 2.403460e-02  5.187110e-02   0.1487456                           
p g1 s2006 t3                     0.1364092 3.104560e-02  8.611810e-02   0.2093416                           
p g1 s2006 t4                     0.1377738 3.066440e-02  8.787610e-02   0.2094969                           
p g1 s2006 t5                     0.4019672 5.536310e-02  2.997110e-01   0.5135277                           
p g1 s2006 t6                     0.3143302 5.111530e-02  2.236025e-01   0.4218680                           
p g1 s2006 t7                     0.0515182 1.306930e-02  3.115430e-02   0.0840383                           
p g1 s2006 t8                     0.2791067 4.797150e-02  1.952580e-01   0.3818758                           
p g1 s2006 t9                     0.0396322 1.045680e-02  2.351880e-02   0.0660387                           
p g1 s2007 t1                     0.2051649 4.211450e-02  1.346444e-01   0.2998236                           
p g1 s2007 t2                     0.1676136 3.635100e-02  1.078106e-01   0.2512478                           
p g1 s2007 t3                     0.0926473 2.444970e-02  5.458880e-02   0.1529471                           
p g1 s2007 t4                     0.4486031 5.723240e-02  3.407823e-01   0.5614816                           
p g1 s2007 t5                     0.3448012 5.468300e-02  2.466806e-01   0.4582111                           
p g1 s2007 t6                     0.1608036 3.096450e-02  1.089025e-01   0.2310270                           
p g1 s2007 t7                     0.1200776 2.413710e-02  8.021390e-02   0.1759623                           
p g1 s2007 t8                     0.0590705 1.399010e-02  3.691660e-02   0.0932322                           
p g1 s2007 t9                     0.0726028 1.627640e-02  4.647820e-02   0.1116915                           
p g1 s2007 t10                    0.0837295 1.812970e-02  5.437740e-02   0.1268010                           
p g1 s2008 t1                     0.1446608 3.870190e-02  8.392600e-02   0.2379317                           
p g1 s2008 t2                     0.1396539 3.554220e-02  8.332830e-02   0.2247194                           
p g1 s2008 t3                     0.1637145 3.759800e-02  1.025608e-01   0.2511284                           
p g1 s2008 t4                     0.2096323 4.271970e-02  1.379409e-01   0.3053843                           
p g1 s2008 t5                     0.1539597 3.459640e-02  9.757550e-02   0.2344604                           
p g1 s2008 t6                     0.1410484 3.217900e-02  8.889560e-02   0.2165265                           
p g1 s2008 t7                     0.1547263 3.414820e-02  9.887760e-02   0.2339306                           
p g1 s2008 t8                     0.0985398 2.494530e-02  5.930280e-02   0.1593401                           
p g1 s2009 t1                     0.1641626 3.879290e-02  1.014052e-01   0.2547484                           
p g1 s2009 t2                     0.2684675 4.628070e-02  1.878115e-01   0.3680643                           
p g1 s2009 t3                     0.2254653 4.193170e-02  1.538493e-01   0.3178937                           
p g1 s2009 t4                     0.4303055 5.831640e-02  3.215049e-01   0.5462809                           
p g1 s2009 t5                     0.5354995 7.026150e-02  3.985757e-01   0.6672732                           
p g1 s2009 t6                     0.4618667 7.164560e-02  3.278737e-01   0.6016052                           
p g1 s2009 t7                     0.1096952 2.210200e-02  7.327570e-02   0.1610699                           
p g1 s2009 t8                     0.0545636 1.291300e-02  3.412830e-02   0.0861438                           
p g1 s2009 t9                     0.0516663 1.241910e-02  3.208680e-02   0.0821788                           
p g1 s2010 t1                     0.2220411 4.179310e-02  1.508409e-01   0.3144058                           
p g1 s2010 t2                     0.2775705 4.505690e-02  1.983011e-01   0.3737544                           
p g1 s2010 t3                     0.5316125 6.005920e-02  4.143199e-01   0.6455128                           
p g1 s2010 t4                     0.2440417 4.188620e-02  1.714121e-01   0.3350033                           
p g1 s2010 t5                     0.4755193 6.997420e-02  3.434590e-01   0.6110943                           
p g1 s2010 t6                     0.0786831 1.637070e-02  5.200560e-02   0.1173515                           
p g1 s2010 t7                     0.1037782 2.035730e-02  7.011470e-02   0.1509800                           
p g1 s2010 t8                     0.2222427 3.870330e-02  1.555772e-01   0.3070861                           
p g1 s2010 t9                     0.3047765 5.092360e-02  2.148883e-01   0.4125093                           
c g1 s1998 t2                     0.4479246 1.008097e-01  2.673568e-01   0.6433549                           
c g1 s1998 t3                     0.4477223 9.467990e-02  2.768037e-01   0.6319559                           
c g1 s1998 t4                     0.3344055 8.184210e-02  1.963890e-01   0.5080907                           
c g1 s1999 t2                     0.7961955 5.784300e-02  6.601610e-01   0.8870900                           
c g1 s1999 t3                     0.4143255 8.533590e-02  2.620417e-01   0.5849576                           
c g1 s1999 t4                     0.3535517 8.067550e-02  2.149550e-01   0.5220819                           
c g1 s2000 t2                     0.7051293 6.627890e-02  5.614524e-01   0.8170713                           
c g1 s2000 t3                     0.1811774 6.610020e-02  8.457930e-02   0.3463579                           
c g1 s2000 t4                     0.4115056 7.872050e-02  2.699509e-01   0.5693948                           
c g1 s2001 t2                     0.2420378 6.195880e-02  1.414263e-01   0.3823500                           
c g1 s2001 t3                     0.7167603 5.032520e-02  6.088749e-01   0.8044449                           
c g1 s2001 t4                     0.6331846 5.580220e-02  5.187418e-01   0.7343497                           
c g1 s2001 t5                     0.6519722 5.357180e-02  5.411484e-01   0.7484707                           
c g1 s2001 t6                     0.2000120 4.605230e-02  1.245168e-01   0.3053173                           
c g1 s2001 t7                     0.1203659 3.756990e-02  6.389660e-02   0.2152644                           
c g1 s2001 t8                     0.0937026 3.367590e-02  4.536980e-02   0.1836210                           
c g1 s2002 t2                     0.2198646 7.559850e-02  1.061849e-01   0.4006891                           
c g1 s2002 t3                     0.4689475 7.527010e-02  3.281042e-01   0.6149179                           
c g1 s2002 t4                     0.7324004 4.914730e-02  6.260568e-01   0.8173258                           
c g1 s2002 t5                     0.6325203 5.830250e-02  5.128516e-01   0.7378204                           
c g1 s2002 t6                     0.4863102 6.535650e-02  3.618018e-01   0.6125412                           
c g1 s2002 t7                     0.5792907 6.002510e-02  4.593713e-01   0.6905302                           
c g1 s2002 t8                     0.2099204 5.134850e-02  1.265046e-01   0.3277042                           
c g1 s2002 t9                     0.3505587 5.920870e-02  2.448417e-01   0.4733121                           
c g1 s2003 t2                     0.6075531 6.247690e-02  4.808733e-01   0.7212400                           
c g1 s2003 t3                     0.3400816 6.990910e-02  2.186632e-01   0.4869062                           
c g1 s2003 t4                     0.6636054 5.520160e-02  5.485292e-01   0.7620725                           
c g1 s2003 t5                     0.5417862 5.996890e-02  4.241091e-01   0.6549791                           
c g1 s2003 t6                     0.4431406 5.884210e-02  3.327460e-01   0.5594525                           
c g1 s2003 t7                     0.5378356 5.639250e-02  4.272619e-01   0.6448085                           
c g1 s2003 t8                     0.3151984 5.289790e-02  2.216179e-01   0.4266358                           
c g1 s2004 t2                     0.3046617 7.793010e-02  1.756334e-01   0.4739793                           
c g1 s2004 t3                     0.4025616 7.459310e-02  2.684110e-01   0.5530726                           
c g1 s2004 t4                     0.4888631 6.765820e-02  3.600243e-01   0.6191988                           
c g1 s2004 t5                     0.7606043 4.242190e-02  6.680456e-01   0.8337765                           
c g1 s2004 t6                     0.8750433 2.877130e-02  8.069902e-01   0.9214375                           
c g1 s2004 t7                     0.4269731 5.274780e-02  3.281051e-01   0.5320423                           
c g1 s2004 t8                     0.2329794 4.447020e-02  1.571858e-01   0.3309681                           
c g1 s2004 t9                     0.1210893 3.421350e-02  6.835440e-02   0.2055332                           
c g1 s2005 t2                     0.4508544 7.917950e-02  3.049063e-01   0.6057790                           
c g1 s2005 t3                     0.4580473 7.585160e-02  3.171071e-01   0.6060376                           
c g1 s2005 t4                     0.4788016 7.320240e-02  3.407879e-01   0.6201290                           
c g1 s2005 t5                     0.8068822 3.734090e-02  7.231600e-01   0.8698421                           
c g1 s2005 t6                     0.4332782 6.249980e-02  3.170482e-01   0.5573450                           
c g1 s2005 t7                     0.5375192 5.989210e-02  4.202241e-01   0.6508034                           
c g1 s2005 t8                     0.3466088 5.971160e-02  2.403511e-01   0.4707326                           
c g1 s2005 t9                     0.2181885 5.288980e-02  1.319345e-01   0.3388223                           
c g1 s2006 t2                     0.3830653 6.980010e-02  2.581793e-01   0.5255621                           
c g1 s2006 t3                     0.5007759 6.591090e-02  3.743409e-01   0.6271118                           
c g1 s2006 t4                     0.5036598 6.422900e-02  3.801427e-01   0.6267318                           
c g1 s2006 t5                     0.8101936 3.610160e-02  7.293124e-01   0.8711764                           
c g1 s2006 t6                     0.7443290 4.459050e-02  6.477900e-01   0.8216907                           
c g1 s2006 t7                     0.2564727 4.912580e-02  1.723149e-01   0.3636730                           
c g1 s2006 t8                     0.7108769 4.723130e-02  6.104576e-01   0.7941389                           
c g1 s2006 t9                     0.2076529 4.348500e-02  1.350360e-01   0.3055268                           
c g1 s2007 t2                     0.5611692 6.504760e-02  4.324620e-01   0.6821414                           
c g1 s2007 t3                     0.3933654 6.907540e-02  2.688344e-01   0.5334920                           
c g1 s2007 t4                     0.8378378 3.219180e-02  7.645571e-01   0.8915456                           
c g1 s2007 t5                     0.7696920 4.238400e-02  6.765455e-01   0.8422685                           
c g1 s2007 t6                     0.5489137 5.421730e-02  4.420396e-01   0.6514578                           
c g1 s2007 t7                     0.4642730 5.385340e-02  3.618072e-01   0.5698466                           
c g1 s2007 t8                     0.2850410 4.901000e-02  1.992559e-01   0.3897811                           
c g1 s2007 t9                     0.3320706 5.103680e-02  2.405188e-01   0.4383571                           
c g1 s2007 t10                    0.3672166 5.215800e-02  2.720746e-01   0.4739660                           
c g1 s2008 t2                     0.5075936 7.504770e-02  3.639796e-01   0.6499652                           
c g1 s2008 t3                     0.5542105 6.856910e-02  4.191463e-01   0.6817170                           
c g1 s2008 t4                     0.6274752 6.097710e-02  5.025265e-01   0.7374381                           
c g1 s2008 t5                     0.5361039 6.574790e-02  4.076961e-01   0.6598965                           
c g1 s2008 t6                     0.5104821 6.569700e-02  3.838220e-01   0.6358104                           
c g1 s2008 t7                     0.5375643 6.426390e-02  4.118923e-01   0.6586378                           
c g1 s2008 t8                     0.4097469 6.688200e-02  2.876085e-01   0.5441358                           
c g1 s2009 t2                     0.6997551 5.106750e-02  5.913922e-01   0.7896040                           
c g1 s2009 t3                     0.6489547 5.495020e-02  5.353608e-01   0.7478571                           
c g1 s2009 t4                     0.8274896 3.442170e-02  7.493822e-01   0.8849901                           
c g1 s2009 t5                     0.8798257 2.964830e-02  8.086372e-01   0.9269248                           
c g1 s2009 t6                     0.8449741 3.670570e-02  7.588710e-01   0.9042121                           
c g1 s2009 t7                     0.4389772 5.251850e-02  3.400022e-01   0.5430572                           
c g1 s2009 t8                     0.2682076 4.680090e-02  1.867763e-01   0.3690310                           
c g1 s2009 t9                     0.2570501 4.616850e-02  1.772356e-01   0.3572029                           
c g1 s2010 t2                     0.7093025 4.768020e-02  6.079650e-01   0.7933489                           
c g1 s2010 t3                     0.8781645 2.621270e-02  8.168226e-01   0.9209524                           
c g1 s2010 t4                     0.6721437 4.807820e-02  5.720637e-01   0.7586912                           
c g1 s2010 t5                     0.8520212 3.437410e-02  7.713902e-01   0.9076193                           
c g1 s2010 t6                     0.3516416 4.849050e-02  2.633365e-01   0.4514127                           
c g1 s2010 t7                     0.4237523 5.013610e-02  3.296400e-01   0.5237413                           
c g1 s2010 t8                     0.6447175 4.823930e-02  5.456534e-01   0.7327607                           
c g1 s2010 t9                     0.7357295 4.432490e-02  6.403917e-01   0.8131658                           
N g1 s1998                       67.5252470 1.767698e+01  4.511584e+01 119.2748200                           
N g1 s1999                       65.4745270 1.260093e+01  4.878277e+01 101.0135400                           
N g1 s2000                       66.8457840 1.181133e+01  5.058210e+01  99.0608310                           
N g1 s2001                       93.0540640 6.981319e+00  8.317915e+01 111.6518100                           
N g1 s2002                       85.3574200 6.529615e+00  7.602433e+01 102.5918300                           
N g1 s2003                       99.8181350 7.538626e+00  8.873820e+01 119.2277800                           
N g1 s2004                      107.9478900 6.226203e+00  9.926980e+01 124.7501300                           
N g1 s2005                       71.1431110 5.779757e+00  6.301141e+01  86.6127020                           
N g1 s2006                       97.4253770 4.670173e+00  9.109372e+01 110.3359400                           
N g1 s2007                       93.5379010 4.456796e+00  8.755504e+01 105.9644100                           
N g1 s2008                       55.6100690 5.240179e+00  4.838815e+01  69.8914100                           
N g1 s2009                       93.5550740 2.720571e+00  9.054291e+01 102.4477700                           
N g1 s2010                      101.2318900 2.573649e+00  9.840933e+01 109.7073300                           
Gamma'' g1 c1998 c1 a0 o1 t1998   0.0000000 0.000000e+00  0.000000e+00   0.0000000 Fixed


any thoughts on any of the issues presented would be great... big thanks in advance, it came out being quite a long post... Also, I am happy to send the capture histories over if that helps at all.

cheers,
Monica Arso
PhD student-University of St Andrews
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm

Re: time.bins and non identifiable N in RD

Postby jlaake » Fri Jun 22, 2012 12:02 pm

Adding design data does not create a constraint. It simply creates another column (field) in the design data. The constraint is created by using the new field which you didn't use. Have you looked at the design data to make sure it is correct? The error message you are getting is an R error and is unexpected but I can't tell from what you sent which model is generating the error nor why.

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

Re: time.bins and non identifiable N in RD

Postby monicaarso » Fri Aug 31, 2012 11:29 am

Hi again,

apologies for not responding the last post. After dealing with fieldwork I am back onto the analysis, step by step.
First, thanks very much for the reply. It's true I wasn't using the new field (i.e. constrain in the gammas) in the models, do'h. I have tried now to use it properly, I have failed once more. The add.design data seems to define properly the bins when I look at it with summary(rd.ddl$GammaDoublePrime), but I don't think I am calling it properly when I define the parameters for the models, because the PIMS structure for the models with the constraint don't show the bins.
See below:

As a reminder, there are 13 primary occasions, from 1998 to 2010.
Code: Select all
library(RMark)

#convert inp file
rd.data=convert.inp("F:/PhD/MR Analysis/analysis 1989-2010/rmark RD/CH 1998-2010 all areas_RD.inp",use.comments=T)

#Process data specifying primary and secondary capture occasions
time.intervals=c(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0)
rd.process=process.data(rd.data,begin.time=1998,model="Robust",time.intervals=time.intervals)

#Create the design data
rd.ddl=make.design.data(rd.process)

#Add design data for the constrains in the gammas
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaPrime",type="time",bins=c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gammaconstrain",replace=TRUE)
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaDoublePrime",type="time",bins=c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),name="gammadoubleconstrain",replace=TRUE)

The bins seem to be defined properly looking at the design data:
Code: Select all
summary(rd.ddl$GammaPrime$gammaconstrain)
[1999,2000] (2000,2001] (2001,2002] (2002,2003] (2003,2004] (2004,2005] (2005,2006] (2006,2007] (2007,2008] (2008,2010]
          3           3           4           5           6           7           8           9          10          11
> summary(rd.ddl$GammaDoublePrime$gammadoubleconstrain)
[1998,1999] (1999,2000] (2000,2001] (2001,2002] (2002,2003] (2003,2004] (2004,2005] (2005,2006] (2006,2007] (2007,2008] (2008,2010]
          3           3           4           5           6           7           8           9          10          11          12


Then I define the parameters that will go into the models, and I define the models. Here, I've only posted three models with constant survival and capture probability: 1) random emigration with constant gammas, 2) random emigration with time dependance and gamma constrain, and 3) markovian emigration with gamma constrain.

Code: Select all
#Specify the parameters for the models
S.dot=list(formula=~1)
S.time=list(formula=~time)
p.dot=list(formula=~1+c,share=T)
p.time.session=list(formula=~-1+session:time+c,share=TRUE)
p.session=list(formula=~session+c,share=T)
#Random and constant, no constrain needed
GammaDoublePrime.GammaPrime.random.constant=list(formula=~1,share=T)
#Random and time dependant, with constrain ###model doesn't run!!
GammaDoublePrime.random.session.constrain=list(formula=~time:gammadoubleconstrain,share=TRUE)
#Markovian (time dependant), with constrain
GammaDoublePrime.markov.constrain=list(formula=~time:gammadoubleconstrain,share=FALSE)
GammaPrime.markov.constrain=list(formula=~time:gammaconstrain,share=FALSE)

#Models
randomconstant=mark(rd.process,rd.ddl,model="Robust",model.parameters=list(S=S.dot,p=p.dot,GammaDoublePrime=GammaDoublePrime.GammaPrime.random.constant))
randomtimecons=mark(rd.process,rd.ddl,model="Robust",model.parameters=list(S=S.dot,p=p.dot,GammaDoublePrime=GammaDoublePrime.random.session.constrain))
markovconstrain=mark(rd.process,rd.ddl,model="Robust",model.parameters=list(S=S.dot,p=p.dot,GammaDoublePrime=GammaDoublePrime.markov.constrain,GammaPrime=GammaPrime.markov.constrain))



The model "randomtimecons" which is random model with the constrain, simply doesn't run and gives the error
Error in match.names(clabs, names(xi)) :
names do not match previous names

But also I am not sure the way I define the Gammas on this model is the correct so that gamma' equals gamma" and at the same time the last two gammas are equal to each other to constrain them.

The markovian model with the constrain in the gammas, it runs, but when looking at the PIMS, no constrain has been done on the last two gamma' or gamma":

Code: Select all
PIMS(markovconstrain,"GammaDoublePrime",simplified=T)
group = Group 1
     1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
1998    2    3    4    5    6    7    8    9   10   11   12   13
1999         3    4    5    6    7    8    9   10   11   12   13
2000              4    5    6    7    8    9   10   11   12   13
2001                   5    6    7    8    9   10   11   12   13
2002                        6    7    8    9   10   11   12   13
2003                             7    8    9   10   11   12   13
2004                                  8    9   10   11   12   13
2005                                       9   10   11   12   13
2006                                           10   11   12   13
2007                                                11   12   13
2008                                                     12   13
2009                                                          13
> PIMS(markovconstrain,"GammaPrime",simplified=T)
group = Group 1
     1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
1998   14   15   16   17   18   19   20   21   22   23   24
1999        15   16   17   18   19   20   21   22   23   24
2000             16   17   18   19   20   21   22   23   24
2001                  17   18   19   20   21   22   23   24
2002                       18   19   20   21   22   23   24
2003                            19   20   21   22   23   24
2004                                 20   21   22   23   24
2005                                      21   22   23   24
2006                                           22   23   24
2007                                                23   24
2008                                                     24


I am obvioulsy not defining the parameters ok with the constrain. Any help will be much appreciated.

millino thanks in advance...
Monica
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm

Re: time.bins and non identifiable N in RD

Postby jlaake » Fri Aug 31, 2012 12:42 pm

I'd need to run your data/code to see where the error is but it could be due to your model formula. You are interacting time with gammaconstrain which are time intervals and that makes no sense. Get rid of the time: and see what happens.

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

Re: time.bins and non identifiable N in RD

Postby monicaarso » Sat Sep 01, 2012 2:54 pm

hi Jeff,

you were right, ~time:gammaconstrain didn't work or basically the constrain was being ignored! I changed it to ~gammaconstrain simply, and it runs. But I had to change the definition of the time bins to right=FALSE instead of right=TRUE, so that the bins are correctly placed, otherwise it was binning the first two years instead of the last two.

So now I after running the markovian emigration model with a constrain in both gammas, this is the PIMS structure I get:

Code: Select all
> PIMS(markovconstrain,"GammaDoublePrime",simplified=T)
group = Group 1
     1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
1998    2    3    4    5    6    7    8    9   10   11   12   12
1999         3    4    5    6    7    8    9   10   11   12   12
2000              4    5    6    7    8    9   10   11   12   12
2001                   5    6    7    8    9   10   11   12   12
2002                        6    7    8    9   10   11   12   12
2003                             7    8    9   10   11   12   12
2004                                  8    9   10   11   12   12
2005                                       9   10   11   12   12
2006                                           10   11   12   12
2007                                                11   12   12
2008                                                     12   12
2009                                                          12
> PIMS(markovconstrain,"GammaPrime",simplified=T)
group = Group 1
     1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
1998   13   14   15   16   17   18   19   20   21   22   22
1999        14   15   16   17   18   19   20   21   22   22
2000             15   16   17   18   19   20   21   22   22
2001                  16   17   18   19   20   21   22   22
2002                       17   18   19   20   21   22   22
2003                            18   19   20   21   22   22
2004                                 19   20   21   22   22
2005                                      20   21   22   22
2006                                           21   22   22
2007                                                22   22
2008                                                     22
>


The model I don't know how to define properly is the random emigration model with time-dependence and a constrain on the last two gammas. I tried to only define bins for GammaDoublePrime and run the model with the parameter specification for GammaDoublePrime as:
Code: Select all
S.dot=list(formula=~1)
p.dot=list(formula=~1+c,share=T)
GammaDoublePrime.random.timeconstrain=list(formula=~gammadoubleconstrain,share=TRUE)

randomtimecons=mark(rd.process,rd.ddl,model="Robust",model.parameters=list(S=S.dot,p=p.dot,GammaDoublePrime=GammaDoublePrime.random.timeconstrain))


but obviously there is an error as I should add design data also for GammaPrime:
Code: Select all
Error: for a shared  GammaDoublePrime&GammaPrime  model, their design data columns must match
. If you add design data to one it must also be added to the other.
Columns of GammaDoublePrime  :  GammaDoublePrime
Columns of GammaPrime :  par.index
 Columns of GammaPrime :  model.index
 Columns of GammaPrime :  group
 Columns of GammaPrime :  cohort
 Columns of GammaPrime :  age
 Columns of GammaPrime :  time
 Columns of GammaPrime :  occ.cohort
 Columns of GammaPrime :  Cohort
 Columns of GammaPrime :  Age
 Columns of GammaPrime :  Time


If I add design data for both gammas then I get a different error...
Code: Select all
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaPrime",type="time",bins=c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),right=FALSE,name="gammaconstrain",replace=TRUE)
rd.ddl=add.design.data(rd.process,rd.ddl,parameter="GammaDoublePrime",type="time",bins=c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2010),right=FALSE, name="gammadoubleconstrain",replace=TRUE)
S.dot=list(formula=~1)
p.dot=list(formula=~1+c,share=T)
GammaDoublePrime.random.timeconstrain=list(formula=~gammadoubleconstrain,share=TRUE)
GammaPrime.random.timeconstrain=list(formula=~gammaconstrain)

randomtimecons=mark(rd.process,rd.ddl,model="Robust",model.parameters=list(S=S.dot,p=p.dot,GammaDoublePrime=GammaDoublePrime.random.timeconstrain,GammaPrime=GammaPrime.random.timeconstrain))


Code: Select all
Error in match.names(clabs, names(xi)) :
 names do not match previous names


Is there another way to do this "share=T" function so that each gamma'=gamma'' for each interval but I can still put a constrain on the last two?

thanks thanks thanks,
Monica
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm

Re: time.bins and non identifiable N in RD

Postby jlaake » Sun Sep 02, 2012 10:28 am

Two things:

For shared parameters you only provide the formula for the dominant parameter and not the shared parameter. For example, you give p=list(formula=~1+c,share=TRUE) but you don't also give a formula for c. That is the case for all shared parameters.

When you define the design data across the shared parameters, the fields should have the exact same names and same definitions. It looked like you used different names and the intervals for binning you used were different. Start at 1998 for both even though the one starts at 1999.

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

Re: time.bins and non identifiable N in RD

Postby monicaarso » Mon Sep 03, 2012 5:06 am

Jeff,

thanks SO MUCH! it worked!!! now back to dealing with some other issues with the models.

cheers,
Monica
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm

Re: time.bins and non identifiable N in RD

Postby monicaarso » Wed Sep 12, 2012 6:55 am

Hi Jeff,

I am trying to plot the capture probabilities for my best model, but I am not managing to extract the se or the confidence interval, getting the following error:

Code: Select all
model=allrdmodels[[20]]
p.estimates=get.real(model,"p",se=TRUE)
Warning message: In get.real(model, "p", se = TRUE) :
Improper V-C matrix for beta estimates. Some variances non-positive.


I can get the estimates if se=FALSE.

any ideas?

thanks!
Monica
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm

Re: time.bins and non identifiable N in RD

Postby jlaake » Wed Sep 12, 2012 9:48 am

If you look in estimates you'll see that they are there. This is just a warning message that some of the variances are not well estimated probably because the estimate is at a boundary.

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

Re: time.bins and non identifiable N in RD

Postby monicaarso » Wed Sep 12, 2012 12:43 pm

uops, true.
thanks lots.

cheers,
Monica
monicaarso
 
Posts: 33
Joined: Wed Feb 22, 2012 2:58 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest

cron