Amanda-
You are close. Currently you have defined year as a numeric variable which is fine because you only have 2 years so whether you treat it as numeric or factor will not affect the model fit but will make the design matrix (DM) differently. When year is numeric for the formula ~year you'll get a DM that looks like
- Code: Select all
Intercept year
1 1
1 2
If you code it as factor then for the formula ~year the DM will be
- Code: Select all
Intercept year2
1 0
1 1
If I understand correctly that you only have 2 years then use
- Code: Select all
multigroup.ddl$Phi$year=1
multigroup.ddl$Phi$year[multigroup.ddl$Phi$time==22.141]=2
multigroup.ddl$Phi$year=factor(multigroup.ddl$Phi$year)
multigroup.ddl$p$year=1
multigroup.ddl$p$year[multigroup.ddl$p$time%in%c(22.141,23.238)]=2
multigroup.ddl$p$year=factor(multigroup.ddl$p$year)
Run each line above and look to see what it is doing in the ddl, so you understand. You could also use ifelse function like
- Code: Select all
multigroup.ddl$p$year=ifelse(multigroup.ddl$p$time%in%c(22.141,23.238),2,1)
Then they will be factor variables and will be more like what you would code in MARK. The add.design.data function would create a factor variable directly with the cut function but you want the cut points to only specify 2 groups and you would need to use Time instead of time because Time is numeric and time is a factor variable. See ?cut in R.
Spend some time reading about numeric and factor variables with the R language and how these differ with regard to formula. In R, see ?factor. Note that I didn't test code so may have typos but hopefully not.
--jeff