Files
RPresence/man/occMod_mm.Rd
Jens Laufer 4f637e83b9 initial
2019-07-12 15:19:27 +02:00

119 lines
6.3 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/occ.mod.mm.R
\name{occMod_mm}
\alias{occMod_mm}
\title{Fit multi-method (or multi-scale) static occupancy/single season model}
\usage{
occMod_mm(psi = call(), psi.cov = data$unitcov, theta = call(),
theta.cov = data$unitcov, p = call(), p.cov = data$survcov,
gamma = call(), gamma.cov = data$survcov, epsilon = call(),
epsilon.cov = data$survcov, modname = NULL, paoname = NULL, outfile,
model = 103, fixed = NULL, initvals = NULL, data, miscopts = "")
}
\arguments{
\item{psi}{the right-hand side of the formula for the model to fit for occupancy probability.}
\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 secondary-scale occupancy probability.}
\item{theta.cov}{a data frame containing the secondary-scale specific covariates to use for the secondary-scaleoccupancy component of the model.}
\item{p}{the right-hand side of the formula for the model to fit for detection probability.}
\item{p.cov}{a data frame containing the survey-specific covariates to use for the detection component of the model.}
\item{gamma}{the right-hand side of the formula for the model to fit for colonization.}
\item{gamma.cov}{a data frame containing the site-specific covariates to use for the colonization component of the model.}
\item{epsilon}{the right-hand side of the formula for the model to fit for extinction.}
\item{epsilon.cov}{a data frame containing the site-specific covariates to use for the extinction component of the model.}
\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}}}
}
\value{
list of class \code{"occMod"} and \code{"soMm"}.
\code{occMod$beta} contains the objects:
\item{psi}{estimated logistic regression coefficients and standard errors for probability of occurrence.}
\item{psi.VC}{variance-covariance matrix for logistic regression coefficients for probability of occurrence.}
\item{theta}{estimated logistic regression coefficients and standard errors for probability of occurrence at the secondary scale.}
\item{theta.VC}{variance-covariance matrix for logistic regression coefficients for probability of occurrence at the secondary scale.}
\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{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 probabilities of occurrence at the secondary scale for each sampling unit, along with standard errors and limits of 95\% confidence interval.}
\item{p}{estimated probabilities of detection for each survey, along with standard errors and limits of 95\% confidence interval.}
\item{psi_c}{estimated probabilities of occurrence given the detection history for each sampling unit, along with standard errors and limits of 95\% confidence interval. Will be \code{=1} for any unit where the species was detected at least once.}
}
\description{
This is not intended for direct use, but instead the \code{\link{occMod}} function should be used with \code{type="so.mm"}.
}
\examples{
#
# sim_so_mm.R - Single-season, multi-method example for RPresence
# where theta is modelled as a function of a survey covariate
#
rm(list=ls()); library(RPresence); setwd('~')
#
# simulate data...
#
N=1000; K=5; M=2 # N=number of sites, K=number of surveys, M=number of methods
psi=.75; # Prob of occupancy (constant for all sites)
X=matrix(round(rnorm(N*K),4),N,K) # Generate site and survey-specific covariate for local occupancy (theta)
b0=0.5; b1=-1; # b0=intercept, b1=effect of covariate X on theta
theta=plogis(b0+b1*X) # logit(local occupancy) = b0 + b1*X
p=c(.9,.8) # p[1]=detection prob for method1, p[2]=detection prob for method 2
v=hist(plogis(b0+b1*X),xlab='local occupancy/use') # plot range of true local occupancy...
occupied_sites=0+(runif(N)<psi) # site occupied if random number < Prob of occ
locally_occ_sites=NULL # site locally occ if random number < theta and occupied
for (i in 1:K) locally_occ_sites=cbind(locally_occ_sites,(0+(runif(N)<theta[,i]))*occupied_sites)
detected=NULL # simulate detection...
for (i in 1:K){ # for each survey...
for (m in 1:M) # for each method...
# detection=1 if rand number<p(method) and locally occupied in survey
detected=cbind(detected,(0+runif(N)<p[m])*locally_occ_sites[,i])
}
Xcov=NULL # For the multi-method model, we need to repeat each survey-specific covariate
# for each method. For example, we have 5 surveys and 2 methods, so we need
# 10 columns for the survey covariate (X1,X1,X2,X2,X3,X3,X4,X4,X5,X5)
for (i in 1:K){ # for each survey...
for (m in 1:M)
Xcov=cbind(Xcov,X[,i]) # save covariate (repeated for each method) as survey covariate
}
#
# generate Presence input object...
#
pao=createPao(data=detected, survcov=data.frame(X=as.numeric(Xcov)),nmethods=2)
#
# run multi-method model...
#
mmod1=occMod(model=list(psi~1,theta~X,p~DEVICE),cov.list=list(X),data=pao,type='so.mm',outfile='tmp.out1')
print(unique(mmod1$real$psi)) ## print real estimates of psi
print(mmod1$beta$theta) ## print beta estimates of theta
print(unique(mmod1$real$p)) ## print real estiamtes of p
}