grouping time intervals

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

grouping time intervals

Postby agoldberg » Wed Sep 06, 2017 12:02 pm

I am working on a data set with 3 trapping intervals each year. I am trying to run my data so that year is not a factor but just interval is. For instance: I have spring, summer, and winter trapping intervals. I want all summer intervals regardless of year to be equal and so forth. I know how to build a DM for this and I know how to code it in Rmark for 2 types of intervals but I am unsure how to proceed for 3. Below is the code I have used when I just have summer and winter trapping intervals:
Code: Select all
multigroup.process=process.data(multigroup,model="CJS",time.intervals=c(1.144,10.2,.922,10.467,.822),begin.time=0,
                                groups=c("sex","trt"))


multigroup.ddl=make.design.data(multigroup.process)

multigroup.ddl$Phi$season=0
multigroup.ddl$Phi$season[multigroup.ddl$Phi$time==1.144]=1
multigroup.ddl$Phi$season[multigroup.ddl$Phi$time==12.266]=1

multigroup.ddl$p$season=0
multigroup.ddl$p$season[multigroup.ddl$p$time== 11.344]=1
multigroup.ddl$p$season[multigroup.ddl$p$time==22.733 ]=1


Thanks,
Amanda
agoldberg
 
Posts: 11
Joined: Sun Aug 23, 2015 9:10 pm

Re: grouping time intervals

Postby jlaake » Thu Sep 07, 2017 8:18 am

Amanda

You are using the approach of creating dummy variables which is fine. When you do that you create k-1 variables when the factor variabe has k levels. For k=2 you created 1 variable in your example. To extend to k=3 you just need to create another variable that is 0 for first 2 intervals and 1 when it is the third interval. This approach is equivalent to creating columns in the DM. In your formula you have to use both season variables and that becomes rather cumbersome with many levels.

A better approach is to create a season factor variable with 3 values, sping,summer,winter and then use the variable season in the formula and R will create the DM columns for you. See factor and as.factor in R help.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: Bing [Bot] and 15 guests