% Generated by roxygen2: do not edit by hand % Please edit documentation in R/occ.mod.2sp.cd.R \name{occMod_SO_2SP_cd} \alias{occMod_SO_2SP_cd} \title{Fit two species, static occupancy (single season) model with correlated detectoins} \usage{ occMod_SO_2SP_cd(psi = call(), psi.cov = data$unitcov, theta = call(), theta.cov = cbind(data$unitcov, data$survcov), p = call(), p.cov = cbind(data$unitcov, data$survcov), th0pi = call(), th0pi.cov = data$unitcov, param = "nu", sp.contr = TRUE, modname = NULL, paoname = NULL, outfile, model = 3000, fixed = NULL, initvals = NULL, data, miscopts = "") } \arguments{ \item{psi}{The right-hand side of the formula for the model to fit for occupancy probability. The terms \code{SP} and \code{INT} can be used to define a species effect on occupancy and an occurrence-level interaction between species accordingly, without them being defined in \code{psi.cov}.} \item{psi.cov}{A data frame containing the unit-specific covariates to use for the occupancy component of the model.} \item{theta}{The right-hand side of the formula for the model to fit for "local-use" probability. The following terms are pre-defined covariates to allow constraints on the theta's (thA, thA\', thBA, thBA\', thBa, thBa\'). \itemize{ \item{\code{SP} - species effect on theta's (thA != thB), } \item{\code{PRIME} - "PRIME" effect (thA !=thA\', thB. !=thB.\') } \item{\code{BAa} - species interaction on theta (thBA != thBa, thBA\' != thBa\') } \item{\code{INTth} - interaction of \code{PRIME} and \code{BAa} (thBA != thBA\' and thBA != thBa)} } So, the most generl model (all theta\'s different) would be: theta(\code{~SP*PRIME+BAa+INTth)}} \item{theta.cov}{A data frame containing the survey-specific covariates to use for the theta component of the model.} \item{p}{The right-hand side of the formula for the model to fit for detection probability. The terms \code{SP}, \code{INT_o} and \code{INT_d} can be used to define a species effect on detection, a detection-level interaction where the occurrence of one species changes the detection probability of the other species and a second detection-level interaction where the detection of one species changes the detection probability of the other species in the same survey. These terms do not have to be defined as variables in \code{p.cov}.} \item{p.cov}{A data frame containing the survey-specific covariates to use for the detection component of the model.} \item{th0pi}{right-side of formula for model to fit for init proportion prev. unoccupied.} \item{th0pi.cov}{data frame containing the site-specific covariates to use for th0pi.} \item{param}{The parameterisation to be used, either "\code{psiBA}" or "\code{nu}", which relate to \code{type="so.2sp.1"} and \code{type="so.2sp.2"} in the function \code{\link{occMod}} respectively.} \item{sp.contr}{\code{TRUE} (default) or \code{FALSE}. Specifies the type of contrast used for the \code{SP} term. It it used as the \code{contrasts} input in the function \code{\link{contr.treatment}}.} \item{modname}{(optional) a string containing the model name} \item{paoname}{(optional) a string containing the filename for the temporary PRESENCE data file.} \item{outfile}{name for output file (use outfile='modname') for outfile named via model name} \item{model}{The PRESENCE model code. DO NOT CHANGE.} \item{fixed}{A single-column matrix containing values for real parameters to be fixed at. \code{rownnames(fixed)} should contain the index of the real parameters to be fixed.} \item{initvals}{Initial values for the beta parameters at which PRESENCE begins the optimisation. The default values in PRESENCE is 0.} \item{data}{The \code{pao} data object containing the detection data and other information.} \item{miscopts}{(see \code{\link{occMod}}) NOTE THAT THERE MAY BE SOME CHANGES TO HOW THIS MODEL IS IMPLEMENTED IN THE NEAR FUTURE.} } \value{ returns a list of class \code{occMod} and \code{so2spCd} \code{occMod$beta} contains the objects: \item{psi}{estimated logistic regression coefficients and std.err for prob. of occurrence.} \item{psi.VC}{var-covar matrix for logistic regression coefficients for prob. of occurrence.} \item{theta}{estimated logistic regression coefficients and std.err for prob. of local occurrence in each survey.} \item{theta.VC}{var-covar matrix for theta.} \item{p}{estimated logistic regression coefficients and standard errors for probability of detection.} \item{p.VC}{variance-covariance matrix for logistic regression coefficients for probability of detection.} \item{th0pi}{estimated logistic regression coefficients and std.err for prob. of local occurrence before 1st survey.} \item{th0pi.VC}{var-covar matrix for th0pi.} \item{VC}{the full variance-covariance matrix for all logistic regression coefficients.} \code{occMod$real} contains the objects: \item{psi}{estimated probabilities of occurrence for each sampling unit, along with standard errors and limits of 95\% confidence interval.} \item{theta}{estimated prob. of local occurrence in each survey w/ std.err and 95\% conf interval limits.} \item{p}{estimated probabilities of detection for each survey, along with standard errors and limits of 95\% confidence interval.} \item{th0pi}{estimated prob. of local occurrence before 1st survey w/ std err and 95\% conf. interval limits.} } \description{ This is not intended for direct use, but instead the \code{\link{occMod}} function should be used with \code{type="so.2sp.cd"}. NOTE THAT THERE MAY BE SOME CHANGES TO HOW THIS MODEL IS IMPLEMENTED IN THE NEAR FUTURE. } \examples{ \dontrun{ # load a csv data file filename<-system.file("extdata/twosp_exmpl.csv",package="RPresence") dethist<-read.csv(filename,as.is=T) nsites=nrow(dethist); nsrvys=ncol(dethist) # set number of sites,surveys from det. history data dethist=matrix(as.integer(unlist(dethist)),nrow=nsites) # replace missing values (-) with NA ## create input "pao" object, for use with occMod function data=createPao(dethist,unitcov=NULL,survcov=NULL,title="twosp corr.det. example") ## fit some models mod1<-occMod(model=list(psi~SP, # occupancy species-specific, no interaction, parameters: psiA, psiBA=psiBa theta~SP, # local occ. species-specific: parameters, thetaA0, thetaA1 (no corr. det. model) p~SP, # detection sp. specific: parms: pA, pB th0pi~1),data=data,type="so.2sp.cd",param="PsiBA") mod2=occMod(model=list(psi~SP+INT, # species and interaction effect (psiA != psiBA != psiBa) theta~SP*PRIME+BAa+INTth, # thA != thA' != thBA != thBA' != thBa != thBa' p~SP+INT_o+INT_d+INT_so, # pA != pB != rA != rBA !=rBa th0pi~1), # constant prop unocc before 1st segment data=data, type="so.2sp.cd", fixed=NULL) # tbl=createAicTable(list(mod1,mod2)); print(tbl$table) sim_2sp_corr_det_data <- function(sites=100,surveys=12,psiA=.8,psiBA=.3,psiBa=.7, thA=c(.4,.9),thBA=c(.3,.9),thBa=c(.3,.9), # 1st is theta, 2nd is theta\\' pA=.6,pB=.66,rA=.7,rBA=.4,rBa=.5, th0piA=0,th0piBA=0,th0piBa=0) { # simulates single-season 2-species correlated detections data psiB=c(psiBa,psiBA); th0piB=c(th0piBa,th0piBA); h=matrix(0,sites,surveys) occA=0+(runif(sites)