To set parameters to be equal, you can add a column to the design-data data-frame. If you examine the matrix created by "make.design.data", you'll see a list variable for each parameter, S, psi, and p. Each of those list variables contains a row for every possible classification for the parameter. For example, S can be estimated by group, strata, age, time or cohort. The formula for S will contain zero or more names of the columns in that matrix. If you have two groups, and your formula for S is "~group", then RMark will create a model where all possible S parameters which have group=1 to be equal and all possible S parameters which have group=2 to be something else. If your formula is “~group*stratum”, with 2 groups and 3 strata, then RMark will create a model with 6 survival parameters, one for each combination of group and strata and will map each possible classification (row of the design data) to one of those 6 values.
A model with state, group and time would have a formula of S~group*stratum*time and map those classifications to one of 2*3*10 possible S parameters (assuming 2 groups, 3 strata, 11 occasions). The trick to setting S’s equal for 2 groups after a particular occasion would be to create a new “group” column in the design data matrix for S. This column, let’s call it “grpX” will contain the same values as the “group” column for the rows where time <= 3 (assuming you want S to be equal for the groups after occasion 3). For all rows where time >= 3, set this grpX variable to equal to a third group value (3). This 3rd group would be the set of survival rates for both groups combined.
Here's some sample R code:
- Code: Select all
dd <- make.design.data(data=procdata, …)
# create new group variable, grpX, set equal to group
dd$S$grpX <- dd$S$group
# change grpX to 3 for all rows where time > 3
dd$S$grpX[dd$S$time > 3] <- 3
# make sure grpX is a factor variable
dd$S$grpX <- factor(dd$S$grpX, levels=c(1,2,3))
# create RMark formula for new group*stratum*time model
SgrpX <- list(formula=~grpX*stratum*time)
# run Mark function
modSgrpX <- mark(data=procdata, ddl=dd, model.parameters=list(S=SgrpX, psi=…)
Now, all rows in the design data with time>3 will have the same grpX value, so the two groups will have the same set of survival rates for each time and strata.
If I left something out, feel free to email me directly (
jhines@usgs.gov)