Hi Betsy,
For multi-season models, you need to specify eps,gam=0 for within-season survey intervals, and esp>0,gam>0 for between-season survey intervals. In the default scenario, GENPRES sets eps(1)=0, eps(2)=0.2, eps(3)=eps(4)=0, so it would be a 2-season dataset, with 2 surveys in the first season, and 3 surveys in the 2nd season.
As Darryl said, you can generate the data for the 2 groups in GENPRES, then create a MARK or PRESENCE input file from the GENPRES output file. Then, analyze with MARK or PRESENCE. If you're generating expected value data, this wouldn't be a bad way to go, but if you want to simulate a bunch of datasets, this would be tedious. In that case, I'd suggest writing a script in R (or whatever script language you know) to simulate the data, analyze with MARK or PRESENCE, then summarize the results. I happen to have one which was pretty close to doing what you want, so I modified it for you. Here's the R code:
- Code: Select all
#
# genpres2.R - simulate single-season data and analyze w/ PRESENCE
# 2 groups of data are simulated:
# group 1: psi=.77, p=.8 for all surveys
# group 2: psi=.66, p=.8 for surveys 1-2, p=.7 for surveys 3-4
#
#presence="h:/y/presence2/presence";
presence="c:/progra~1/presence/presence"; # location of PRESENCE program
seed=-32766+floor(64542*runif(1)); TAB='\t'; #sprintf("%c",9);
T=4; N1=500; psi1=.77; p1=c(.8,.8,.8,.8);
T=4; N2=500; psi2=.66; p2=c(.8,.8,.7,.7);
# build design matrix input file for PRESENCE
dm=file("genpres.dm","w");
cat(c("0 2 3 \n"),file=dm) ; # MATRIX 0 - 2 rows, 3 cols
cat(c("-,a1,a2, \n"),file=dm,append=T) # matrix header line
cat(c("psi,1,-101\n"),file=dm,append=T); # psi design matrix: 1=intercept, -101=1st site covariate
cat(c("1",T+1,"4\n"),file=dm,append=T); # MATRIX 1 - T rows, 5 cols
cat(c("-,b1,b2,b3,\n"),file=dm,append=T); # matrix header line
for (i in 1:2) cat(c("p(",i,"),1,0,0\n"),file=dm,append=T,sep=""); # p part of design matrix, surveys 1-2
for (i in 3:T) cat(c("p(",i,"),0,1,-101\n"),file=dm,append=T,sep=""); # p part of design matrix, surveys 3-4
cat(c("2 0 0,\n"),file=dm,append=T) # MATRIX 2 - unused
cat(c("3 0 0,\n"),file=dm,append=T) # MATRIX 3 - unused
cat(c("4 0 0,\n"),file=dm,append=T) # MATRIX 4 - unused
cat(c("5 0 0,\n"),file=dm,append=T) # MATRIX 5 - unused
close(dm)
# generate data for group 1
present1=(runif(N1)<psi1); det1=rep(0,N1*T); dim(det1)=c(N1,T); det2=det1;
for (i in 1:T) det1[,i]=(runif(N1)<p1[i]);
present2=(runif(N2)<psi2); # generate data for group 2
for (i in 1:T) det2[,i]=(runif(N2)<p2[i]);
# create PRESENCE input file: genpres.pao
# 1st line in input file contains N and T, separated by TAB char,
# where N=total number of sites, T=number of surveys
pao=file("genpres.pao","w")
cat(c(N1+N2,"\t",T,"\n",sep=""),file=pao,append=F,sep=""); # output nsites,nsurveys
# write detection histories to input file...
# the two groups of site-histories are concatenated, and the detections are
# multiplied by the random presence variable
write.table(rbind(present1*det1,present2*det2),file=pao,append=T,sep='\t',row.names=F,col.names=F); # output detection data
# write number of site covariates, followed by the name of the 1st (and only) site covariate...
cat("1\ngrp2\n",file=pao,append=T,sep="");
# write site covariate vector...
write.table(rbind(rep(0,N1),rep(1,N2)),file=pao,append=T,sep='\n',row.names=F,col.names=F); # output detection data
# write number of survey covariates (zero) and close input file...
cat("0\n",file=pao,append=T,sep="");
close(pao)
# run PRESENCE... args: i=inputfilename model=100 for single-season model
cmd=sprintf("%s i=genpres.pao model=100 name=psi_p QUIET",presence)
system(cmd)
# scan PRESENCE output file and save parameter estimates...
v=readLines("presence.out"); l=length(v); est="";
ii=grep("survey_",v); l=length(ii);
for (j in 1:l) {
a=v[ii[j]]; # a=jth line of output file
b=gsub(" +","@",a); # replace multiple blanks with a single @ char
c=unlist(strsplit(b,"@")); # split output line into fields
est=c(est,c[4],c[5]); # so we can save the 4th and 5th fields (the param estimate and std.err)
}
cat(c(">>",est,"\n"),sep="\n"); # print estimates