Fixing real parameters - RMark users PLEASE READ
Posted: 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.
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
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)