Fixing real parameters - RMark users PLEASE READ

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

Fixing real parameters - RMark users PLEASE READ

Postby jlaake » Wed Dec 17, 2014 2:24 pm

I just had a problem posed regarding fixed parameters in which the user compared use of indices and deleting design data rows to fix some multistate transition parameters to 0. Deleting design data rows was a BAD idea on my part and has caused me a lot of grief coding. As I described in the following post

http://www.phidot.org/forum/viewtopic.php?f=21&t=2576&p=8172&hilit=fix+parameters#p8172

deleting design data rows will not work with all types of parameters and it should not be used. The next version will prevent you from using incomplete design data.

The post also described the better approach that was implemented in v2.1.6 of using the field fix in the design data. It is simpler to use than the original approach of using fixed in the model specification with indices and values. The model specification approach is still valid to fix parameters only in specific models. However most fixed parameters are fixed for all models such as non-valid transitions in a multi-state model. In that case the use of fix in the design data is the approach that should be used.

Please modify old R code to replace use of deleting design data with use of fix. Here is an example of how to do that using the dipper data.
Code: Select all
data(dipper)

# deleting design data approach to fix Phi=1 for time 2 (DON'T use this approach)
dp=process.data(dipper)
ddl=make.design.data(dp)
ddl$Phi=ddl$Phi[!ddl$Phi$time==2,]
ddl$Phi
summary(mark(dp,ddl,output=FALSE),show.fixed=TRUE)

#new approach using fix to set Phi=1 for time 2 (USE this approach)
ddl=make.design.data(dp)
ddl$Phi$fix=NA
ddl$Phi$fix[ddl$Phi$time==2]=1
ddl$Phi
summary(mark(dp,ddl,output=FALSE),show.fixed=TRUE)



In that case the results will be the same but for mlogit parameters deleting the design data will not work as you can see in the example below. It may have worked previously but I redesigned some code awhile back and this no longer works as is clear from the summary output.

Sorry for any inconvenience. regards --jeff

Code: Select all
data(mstrata)

# deleting design data approach to fix Psi A to B to 0 (DON'T use this approach)
dp=process.data(mstrata,model="Multistrata")
ddl=make.design.data(dp)
ddl$Psi=ddl$Psi[!(ddl$Psi$stratum=="A" & ddl$Psi$tostratum=="B"),]
ddl$Psi
summary(mark(dp,ddl,output=FALSE),show.fixed=TRUE)


#new approach using fix to set Phi=1 for time 2 (USE this approach)
ddl=make.design.data(dp)
ddl$Psi$fix=NA
ddl$Psi$fix[ddl$Psi$stratum=="A" & ddl$Psi$tostratum=="B"]=0
ddl$Psi
summary(mark(dp,ddl,output=FALSE),show.fixed=TRUE)

jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Fixing real parameters - RMark users PLEASE READ

Postby sergi_20 » Mon Dec 29, 2014 2:28 pm

Hi Jeff,

I applied your code to fix real parameters to my data, as I had unequal time intervals, and I needed equal time intervals (three months apart) fixing the p and c equal to 0 on some occasions. viewtopic.php?f=21&t=2885

Code: Select all
rd.ddl$p$fix=NA
rd.ddl$p$fix[rd.ddl$p$session==22]=0
rd.ddl$p$fix[rd.ddl$p$session==25]=0
rd.ddl$p$fix[rd.ddl$p$session==28]=0
rd.ddl$p$fix[rd.ddl$p$session==43]=0
rd.ddl$p
rd.ddl$c$fix=NA
rd.ddl$c$fix[rd.ddl$c$session==22]=0
rd.ddl$c$fix[rd.ddl$c$session==25]=0
rd.ddl$c$fix[rd.ddl$c$session==28]=0
rd.ddl$c$fix[rd.ddl$c$session==43]=0
rd.ddl$c


I got a column with 0 for the previous fix parameters and NA for the rest. But when I get the ouput from my best models, I only got that one of the is fixed:

Parameter Estimate Standard Error Lower Upper
-------------------------- -------------- -------------- -------------- --------------
89:p g1 s22 t1 0.0000000 0.0000000 0.0000000 0.0000000 Fixed

Should I get just this parameters or all of them on the output?

Thanks,
Sergi
sergi_20
 
Posts: 16
Joined: Wed Apr 03, 2013 1:01 pm

Re: Fixing real parameters - RMark users PLEASE READ

Postby jlaake » Mon Dec 29, 2014 2:48 pm

Not certain where that output came from but when RMark creates the input file for MARK it simplifies the PIMS which means that for any fixed real parameter with the same value, it will get the same index so you'll only have one of them. In the summary output from RMark, all of them will show as being fixed to the real value. You need to read the documentation about what RMark does in regards to simplification. It is essential to understand that and because of simplification the real parameter values listed in the MARK output are not particularly meaningful. Instead you should look at the values from summary. If you use the argument show.fixed=TRUE, it will show the fixed value. By default it shows a blank.

--jeff
jlaake
 
Posts: 1417
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 13 guests