Huggins model -- Factors as individual covariates

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

Huggins model -- Factors as individual covariates

Postby krh1985 » Fri Aug 09, 2019 5:35 pm

I'm trying to do a Huggins model. Here's a sample of my data:

> head(ch)
ch station year plot
1011 1 2002 1.N2
1101 1 2002 1.N2
1000 1 2002 1.N2
1101 1 2002 1.N2
1010 1 2002 1.N2
1001 1 2002 1.N2

All 3 grouping variables (station, year, plot) are being imported as factors.

Here's my code:


ch=import.chdata("tt_jc_inp.txt",header=TRUE)
woodrat.proc=process.data(ch,model="Huggins",groups="plot", time.intervals=c(1,1,1),nocc=4)
woodrat.ddl=make.design.data(woodrat.proc)
initial.analysis=function(){

p.dot=list(formula=~1)
p.plot=list(formula=~plot)
p.time=list(formula=~time)
c.time=list(formula=~time)
c.plot=list(formula=~plot)
c.dot=list(formula=~1)#

woodrat.cml=create.model.list("Huggins")
#use mark.wrapper with model list gvol.CML and the processed data and design data to fit each of the models in MARK
model.list=mark.wrapper(woodrat.cml,data=woodrat.proc,ddl=woodrat.ddl,output=F)
results=mark.wrapper(woodrat.cml,data=woodrat.proc,ddl=woodrat.ddl,adjust=T,invisible=F)
#return the list of model results as the value of the fnction
return(model.list)
}
#run the analysis. assign results to object gvol.results
woodrat.results=initial.analysis()
woodrat.results

When I run the model with a single variable as the group it runs perfectly, but when I try to designate more than 1 group it gives me this error:

Error in cohort + cumsum(time.intervals[i:(num - 1)]) :
non-numeric argument to binary operator

Any idea where I'm going wrong? Thanks for your help and quick replies. They are much appreciated! -Katie
krh1985
 
Posts: 6
Joined: Mon Apr 15, 2019 10:55 am

Re: Another RMark question: Factors as individual covariates

Postby jlaake » Fri Aug 09, 2019 5:58 pm

Instead of tagging onto prior post you should have started a new post because this has nothing to do with prior post. Also, when you have an error, show the code that caused the error. My guess is that you used incorrect syntax in specifying multiple factor variables for groups but since you didn't include the errant code there was no way for me to tell. The following code worked fine for me with the little snippet of data you sent.

Code: Select all
ch=import.chdata("tt_jc_inp.txt",header=TRUE)
woodrat.proc=process.data(ch,model="Huggins",groups=c("station","year","plot"),
time.intervals=c(1,1,1),nocc=4)
woodrat.ddl=make.design.data(woodrat.proc)

initial.analysis=function(){
  p.dot=list(formula=~1)
  p.plot=list(formula=~plot)
  p.time=list(formula=~time)
  c.time=list(formula=~time)
  c.plot=list(formula=~plot)
  c.dot=list(formula=~1)#

woodrat.cml=create.model.list("Huggins")
model.list=mark.wrapper(woodrat.cml,data=woodrat.proc,ddl=woodrat.ddl,output=F)
results=mark.wrapper(woodrat.cml,data=woodrat.proc,ddl=woodrat.ddl,adjust=T,invisible=F)
  return(model.list)
}
#run the analysis.  assign results to object gvol.results
woodrat.results=initial.analysis()
woodrat.results
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Another RMark question: Factors as individual covariates

Postby egc » Fri Aug 09, 2019 6:24 pm

jlaake wrote:Instead of tagging onto prior post you should have started a new post because this has nothing to do with prior post.


I split this into a separate topic thread, as per Jeff's suggestion.
egc
Site Admin
 
Posts: 201
Joined: Thu May 15, 2003 3:25 pm

Re: Huggins model -- Factors as individual covariates

Postby krh1985 » Sat Aug 10, 2019 7:46 am

Hi Drs. Cooch and Laake,
Thanks for your help, changing the code from 'groups="station", "year", "plot"' to 'groups=c("station","year","plot")' fixed the problem. Sorry for the confusion on where to post things. -Katie
krh1985
 
Posts: 6
Joined: Mon Apr 15, 2019 10:55 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 13 guests

cron