Page 1 of 1

Huggins model -- Factors as individual covariates

PostPosted: Fri Aug 09, 2019 5:35 pm
by krh1985
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

Re: Another RMark question: Factors as individual covariates

PostPosted: Fri Aug 09, 2019 5:58 pm
by jlaake
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

Re: Another RMark question: Factors as individual covariates

PostPosted: Fri Aug 09, 2019 6:24 pm
by egc
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.

Re: Huggins model -- Factors as individual covariates

PostPosted: Sat Aug 10, 2019 7:46 am
by krh1985
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