diff --git a/RangeShiftR/DESCRIPTION b/RangeShiftR/DESCRIPTION index 8f93e06..ba007f0 100644 --- a/RangeShiftR/DESCRIPTION +++ b/RangeShiftR/DESCRIPTION @@ -19,6 +19,8 @@ Imports: Rcpp (>= 1.0.0), Rdpack (>= 0.7), methods, + raster +Suggests: rmarkdown, terra RdMacros: Rdpack diff --git a/RangeShiftR/NAMESPACE b/RangeShiftR/NAMESPACE index e294623..87853d6 100644 --- a/RangeShiftR/NAMESPACE +++ b/RangeShiftR/NAMESPACE @@ -28,4 +28,5 @@ export(readRange) export(validateRSparams) importFrom(Rcpp,sourceCpp) importFrom(Rdpack,reprompt) +importFrom(methods,new) useDynLib(RangeShiftR) diff --git a/RangeShiftR/R/RSsim.R b/RangeShiftR/R/RSsim.R index aa459fb..f38df8d 100644 --- a/RangeShiftR/R/RSsim.R +++ b/RangeShiftR/R/RSsim.R @@ -130,6 +130,6 @@ RSsim <- function(batchnum = 1L, if (!is.null(args$gene)) s <- s + gene if (!is.null(args$init)) s <- s + init # check validity - if(validObject(s)) return(s) + if(methods::validObject(s)) return(s) else return(NULL) } diff --git a/RangeShiftR/R/RangeShiftR.R b/RangeShiftR/R/RangeShiftR.R index 9423a1c..a919319 100644 --- a/RangeShiftR/R/RangeShiftR.R +++ b/RangeShiftR/R/RangeShiftR.R @@ -92,5 +92,5 @@ RangeShiftR_license <- function () #' @export RangeShiftR_citation <- function () { - citation(package = "RangeShiftR", lib.loc = NULL, auto = NULL) + utils::citation(package = "RangeShiftR", lib.loc = NULL, auto = NULL) } diff --git a/RangeShiftR/R/Rfunctions.R b/RangeShiftR/R/Rfunctions.R index e8d3e73..c28618c 100644 --- a/RangeShiftR/R/Rfunctions.R +++ b/RangeShiftR/R/Rfunctions.R @@ -32,13 +32,13 @@ #---------------------- #for Integer and Numerical so that 'Integer'-slots can also accept 'Numerical' input -setClassUnion("integer_OR_numeric", c("integer", "numeric")) +methods::setClassUnion("integer_OR_numeric", c("integer", "numeric")) #for Matrix and Numerical so that 'Matrix'-slots can also accept 'Numerical' input when 1x1-Matrix is expected -setClassUnion("matrix_OR_numeric", c("matrix", "numeric")) +methods::setClassUnion("matrix_OR_numeric", c("matrix", "numeric")) #for cost layer to accept habitat codes or raster map file -setClassUnion("numeric_OR_character", c("numeric", "character")) +methods::setClassUnion("numeric_OR_character", c("numeric", "character")) #-- define error and warning messages @@ -59,4 +59,4 @@ densdep <- function(x, A0 = 1.0, alpha = 1.0, beta = 0.0) { #' Validate a given RS parameter object #' #' @export -validateRSparams <- function(x){validObject(x)} +validateRSparams <- function(x){methods::validObject(x)} diff --git a/RangeShiftR/R/RunRS.R b/RangeShiftR/R/RunRS.R index e8f031d..6a469d6 100644 --- a/RangeShiftR/R/RunRS.R +++ b/RangeShiftR/R/RunRS.R @@ -43,7 +43,7 @@ RunRS <- function(RSparams, dirpath = getwd()){ stop("Parameter object must be of class RSparams") } else { - validObject(RSparams) + methods::validObject(RSparams) } } if (is.null(dirpath)) { diff --git a/RangeShiftR/R/addition.R b/RangeShiftR/R/addition.R index 84678de..bbf3729 100644 --- a/RangeShiftR/R/addition.R +++ b/RangeShiftR/R/addition.R @@ -31,13 +31,13 @@ setGeneric("+") setMethod("+", signature(e1 = "RSparams", e2 = "SimulationParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@simul <- e2 return(e1)} ) setMethod("+", signature(e1 = "RSparams", e2 = "LandParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) if (class(e2)[1] == "ImportedLandscape") { if (any(e2@PatchFile=="NULL")) { e1@control@patchmodel = FALSE @@ -76,7 +76,7 @@ setMethod("+", signature(e1 = "RSparams", e2 = "LandParams"), function(e1, e2) { ) setMethod("+", signature(e1 = "RSparams", e2 = "DemogParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@control@reproductn = e2@ReproductionType if (class(e2@StageStruct)[1] == "StagesParams") { e1@control@repseasons = e2@StageStruct@RepSeasons @@ -101,7 +101,7 @@ setMethod("+", signature(e1 = "RSparams", e2 = "DemogParams"), function(e1, e2) ) setMethod("+", signature(e1 = "DemogParams", e2 = "StagesParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@StageStruct <- e2 e1@Rmax <- -9L e1@bc <- -9L @@ -109,7 +109,7 @@ setMethod("+", signature(e1 = "DemogParams", e2 = "StagesParams"), function(e1, ) setMethod("+", signature(e1 = "RSparams", e2 = "DispersalParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) if (class(e2@Transfer)[1] == "DispersalKernel") { e1@control@transfer = 0 } @@ -131,34 +131,34 @@ setMethod("+", signature(e1 = "RSparams", e2 = "DispersalParams"), function(e1, ) setMethod("+", signature(e1 = "DispersalParams", e2 = "EmigrationParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@Emigration <- e2 - validObject(e1) + methods::validObject(e1) return(e1)} ) setMethod("+", signature(e1 = "DispersalParams", e2 = "TransferParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@Transfer <- e2 - validObject(e1) + methods::validObject(e1) return(e1)} ) setMethod("+", signature(e1 = "DispersalParams", e2 = "SettlementParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@Settlement <- e2 - validObject(e1) + methods::validObject(e1) return(e1)} ) setMethod("+", signature(e1 = "RSparams", e2 = "GeneticsParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@gene <- e2 return(e1)} ) setMethod("+", signature(e1 = "RSparams", e2 = "InitialisationParams"), function(e1, e2) { - validObject(e2) + methods::validObject(e2) e1@init <- e2 return(e1)} ) diff --git a/RangeShiftR/R/class_ControlParams.R b/RangeShiftR/R/class_ControlParams.R index 423dcc9..9b36145 100644 --- a/RangeShiftR/R/class_ControlParams.R +++ b/RangeShiftR/R/class_ControlParams.R @@ -25,7 +25,7 @@ # from RS 'CONTROL.txt' file -ControlParams <- setClass("ControlParams", slots = c( +ControlParams <- methods::setClass("ControlParams", slots = c( #nSimuls = "integer_OR_numeric", # Not yet used by R version, in C++ version its read from parameterfile #nLandscapes = "integer_OR_numeric", # Not yet used by R version, in C++ version its read from landfile batchnum = "integer_OR_numeric", # only variable to set from RSsim(), optional diff --git a/RangeShiftR/R/class_DemogParams.R b/RangeShiftR/R/class_DemogParams.R index 82f1e5c..2c71aed 100644 --- a/RangeShiftR/R/class_DemogParams.R +++ b/RangeShiftR/R/class_DemogParams.R @@ -57,39 +57,39 @@ #' demographic parameters. Individuals are characterized by their age and stage. Each stage has a certain fecundity, survival probability and probability of developing to the next stage. #' #' These parameters are provided through classical transition matrices \insertCite{caswell2001}{RangeShiftR}. -#' \ifelse{html}{\out{φi}}{\eqn{φ_i}} is the fecundity of stage \eqn{i} ; -#' \ifelse{html}{\out{σi}}{\eqn{σ_i}} is the survival probability of an individual in stage \eqn{i} ; -#' and \ifelse{html}{\out{γi-j}}{\eqn{γ_(i-j)}} is the probability of developing from stage \eqn{i} to stage \eqn{j}. +#' \ifelse{html}{\out{φi}}{\eqn{\phi_i}} is the fecundity of stage \eqn{i} ; +#' \ifelse{html}{\out{σi}}{\eqn{\sigma_i}} is the survival probability of an individual in stage \eqn{i} ; +#' and \ifelse{html}{\out{γi-j}}{\eqn{\gamma_(i-j)}} is the probability of developing from stage \eqn{i} to stage \eqn{j}. #' In this way, the transition matrix describes the effect of each individuals current stage (column) on all stages at the next timestep (rows). #' Since all offspring is born into the juvenile stage (stage 0), all fecundities are always located in the first row of the matrix. #' #' However, in \emph{RangeShiftR}, these parameters are not used deterministically as \emph{rates} (like it is typical for matrix models) but, instead, as \emph{probabilities} which are -#' applied stochastically at the individual level. Hence, each female at stage \eqn{i}, if it reproduces, produces a number of offspring given by \eqn{Poisson}(\ifelse{html}{\out{φi}}{\eqn{φ_i}}), -#' while Bernoulli trials \eqn{Bern}(\ifelse{html}{\out{σi}}{\eqn{σ_i}}) and \eqn{Bern}(\ifelse{html}{\out{γi,i+1}}{\eqn{γ_(i,i+1)}}) determine if an individual/female survives or not +#' applied stochastically at the individual level. Hence, each female at stage \eqn{i}, if it reproduces, produces a number of offspring given by \eqn{Poisson}(\ifelse{html}{\out{φi}}{\eqn{\phi_i}}), +#' while Bernoulli trials \eqn{Bern}(\ifelse{html}{\out{σi}}{\eqn{\sigma_i}}) and \eqn{Bern}(\ifelse{html}{\out{γi,i+1}}{\eqn{\gamma_(i,i+1)}}) determine if an individual/female survives or not #' and - if it survives - if it develops to the next stage or not. #' #' An example transition matrix for a 3-staged only-female or simple sexual (\code{ReproductionType={0,1}}) population model: -#' \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{φ_2}} \cr -#' \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{σ_1 (1 − γ_(1-2))}} \tab | \tab \eqn{0} \cr -#' \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{σ_1 γ_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{σ_2}} \cr} +#' \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{\phi_2}} \cr +#' \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{\sigma_1 (1 - \gamma_(1-2))}} \tab | \tab \eqn{0} \cr +#' \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{\sigma_1 \gamma_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{\sigma_2}} \cr} #' -#' In a female-only model (\code{ReproductionType=0}), \ifelse{html}{\out{φ}}{\eqn{φ}} represents the number of female offspring per female and reproductive event. \cr +#' In a female-only model (\code{ReproductionType=0}), \ifelse{html}{\out{φ}}{\eqn{\phi}} represents the number of female offspring per female and reproductive event. \cr #' Note that for an implicit (simple) sexual model (\code{ReproductionType=1}), the demographic parameters are not sex-specific. However, individuals are defined by their sex, which is acknowledged for example in the dispersal -#' process and transmission of alleles. The fecundities \ifelse{html}{\out{φ}}{\eqn{φ}} refer to the number of all offspring (males and females) per female and reproductive event. +#' process and transmission of alleles. The fecundities \ifelse{html}{\out{φ}}{\eqn{\phi}} refer to the number of all offspring (males and females) per female and reproductive event. #' #' In case of an explicit (complex) sexual model (\code{ReproductionType=2}), in contrast, each stage must be represented by two columns and rows to distinguish male and female demographic parameters. -#' Note, however, that in any case the juvenile stage has only one row; it contains the fecundities. Male fecundities should have one of two possible values: set \ifelse{html}{\out{φm}}{\eqn{φ_m}} \eqn{=1.0} for reproductive males or \ifelse{html}{\out{φm}}{\eqn{φ_m}} \eqn{=0.0} for non-reproductive males.\cr +#' Note, however, that in any case the juvenile stage has only one row; it contains the fecundities. Male fecundities should have one of two possible values: set \ifelse{html}{\out{φm}}{\eqn{\phi_m}} \eqn{=1.0} for reproductive males or \ifelse{html}{\out{φm}}{\eqn{\phi_m}} \eqn{=0.0} for non-reproductive males.\cr #' An example transition matrix for a 3-staged explicit sexual population model \insertCite{weeks1986,lindstrom1998}{RangeShiftR}: -#' \tabular{ccccccccccc}{\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{φ1m}}{\eqn{φ_1m}} \tab | \tab \ifelse{html}{\out{φ1f}}{\eqn{φ_1f}} \tab | \tab \ifelse{html}{\out{φ2m}}{\eqn{φ_2m}} \tab | \tab \ifelse{html}{\out{φ2f}}{\eqn{φ_2f}} \cr -#' \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m (1-γ1-2,m)}}{\eqn{σ_1m (1 − γ_(1-2,m))}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr -#' \eqn{0} \tab | \tab \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{σ_1f γ_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr -#' \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m γ1-2,m}}{\eqn{σ_1m γ_(1-2,m)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2m}}{\eqn{σ_2m}} \tab | \tab \eqn{0} \cr -#' \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{σ_1f γ_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2f}}{\eqn{σ_2f}} \cr}#' The mating system is explicitly modelled and a female’s probability of reproducing is determined as described in \code{\link[RangeShiftR]{Demography}} \insertCite{weeks1986,caswell2001}{RangeShiftR}. +#' \tabular{ccccccccccc}{\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{φ1m}}{\eqn{\phi_1m}} \tab | \tab \ifelse{html}{\out{φ1f}}{\eqn{\phi_1f}} \tab | \tab \ifelse{html}{\out{φ2m}}{\eqn{\phi_2m}} \tab | \tab \ifelse{html}{\out{φ2f}}{\eqn{\phi_2f}} \cr +#' \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m (1-γ1-2,m)}}{\eqn{\sigma_1m (1 - \gamma_(1-2,m))}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr +#' \eqn{0} \tab | \tab \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{\sigma_1f \gamma_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr +#' \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m γ1-2,m}}{\eqn{\sigma_1m \gamma_(1-2,m)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2m}}{\eqn{\sigma_2m}} \tab | \tab \eqn{0} \cr +#' \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{\sigma_1f \gamma_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2f}}{\eqn{\sigma_2f}} \cr}#' The mating system is explicitly modelled and a female’s probability of reproducing is determined as described in \code{\link[RangeShiftR]{Demography}} \insertCite{weeks1986,caswell2001}{RangeShiftR}. #' #' A common mistake in building a transition matrix is made when offspring produced at year \eqn{t} develop to the next stage in the same year \insertCite{@ @caswell2001 pg. 60-62}{RangeShiftR}. To avoid this problem without losing the offspring stage, and hence the chance for simulating post-natal dispersal, #' we require an additional explicit juvenile stage (stage 0). Juveniles have to develop to stage 1 in the same year they are born. Hence the minimum number of stages of a stage-structured model is always \eqn{2}. It is important to note that juvenile mortality can be accounted for in -#' two ways. Either, as in the examples above, it is included in adult fecundity \ifelse{html}{\out{φ}}{\eqn{φ}} (by appropriately reducing its value), and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{σ_0 γ_(0-1)}} is equal to \eqn{1.0}. This is how it is typically accounted for in matrix models. Or, alternatively, -#' φ is equal to the true maximum fecundity and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{σ_0 γ_(0-1)}} is less than \eqn{1.0}. +#' two ways. Either, as in the examples above, it is included in adult fecundity \ifelse{html}{\out{φ}}{\eqn{\phi}} (by appropriately reducing its value), and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{\sigma_0 \gamma_(0-1)}} is equal to \eqn{1.0}. This is how it is typically accounted for in matrix models. Or, alternatively, +#' \eqn{\phi} is equal to the true maximum fecundity and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{\sigma_0 \gamma_(0-1)}} is less than \eqn{1.0}. #' Only the first approach allows straightforward direct comparison with standard analytical matrix models. #' #' \emph{Minimum ages:} For every row in the transition matrix, a minimum age must be provided through a vector in argument \code{MinAge}. It specifies the age which an individual in stage \eqn{i-1} (with sex \eqn{m/f}, if applicable) must already have reached before it can develop into the next stage \eqn{(i)}. The vector must be in @@ -122,26 +122,26 @@ #' \emph{Density dependence} can act on each of the three demographic phases (i.e. reproduction, survival and development) and is controlled by \code{FecDensDep,DevDensDep,SurvDensDep}. #' It is implemented as an exponential decay \insertCite{neubert2000}{RangeShiftR}: #' -#' \ifelse{html}{\out{   φi(r,t) = φ0,i * e - b(r) N(t) }}{\deqn{φ_i(r,t)=φ_(0,i) * exp(- b(r) N(t) ) }} +#' \ifelse{html}{\out{ φi(r,t) = φ0,i * e - b(r) N(t) }}{\deqn{\phi_i(r,t)=\phi_(0,i) * exp(- b(r) N(t) ) }} #' -#' \ifelse{html}{\out{   σi(r,t) = σ0,i * e - Cσ b(r) N(t) }}{\deqn{σ_i(r,t)=σ_(0,i) * exp(- C_\sigma b(r) N(t) ) }} +#' \ifelse{html}{\out{ σi(r,t) = σ0,i * e - Cσ b(r) N(t) }}{\deqn{\sigma_i(r,t)=\sigma_(0,i) * exp(- C_\sigma b(r) N(t) ) }} #' -#' \ifelse{html}{\out{   γi(r,t) = γ0,i * e - Cγ b(r) N(t) }}{\deqn{γ_i(r,t)=γ_(0,i) * exp(- C_γ b(r) N(t) ) }} +#' \ifelse{html}{\out{ γi(r,t) = γ0,i * e - Cγ b(r) N(t) }}{\deqn{\gamma_i(r,t)=\gamma_(0,i) * exp(- C_\gamma b(r) N(t) ) }} #' #' where \eqn{b(r)} is the strength of density dependence in fecundity at site \eqn{r}, which is given by the argument \code{K_or_DensDep} in the landscape module. -#' Furthermore, \ifelse{html}{\out{Cσ}}{\eqn{C_\sigma}} and \ifelse{html}{\out{Cγ}}{\eqn{C_γ}} (\code{DevDensCoeff,SurvDensCoeff}) +#' Furthermore, \ifelse{html}{\out{Cσ}}{\eqn{C_\sigma}} and \ifelse{html}{\out{Cγ}}{\eqn{C_\gamma}} (\code{DevDensCoeff,SurvDensCoeff}) #' scale the strength of density dependence in survival and development relative to that in fecundity. #' #' Moreover, the strength of density-dependence can be uniform for all stages or stage-dependent. Even greater complexity can be incorporated with #' different stages contributing differently to density-dependence \insertCite{caswell2004}{RangeShiftR}: #' -#' \ifelse{html}{\out{  φi(r,t) = φ0,i * e - b(r) ΣjS ωφ,ij N(j,t)}}{\deqn{φ_i(r,t)=φ_(0,i) * exp(- b(r) \Sigma_j^S ω_{φ,ij} N_j(t) ) }} +#' \ifelse{html}{\out{ φi(r,t) = φ0,i * e - b(r) ΣjS ωφ,ij N(j,t)}}{\deqn{\phi_i(r,t)=\phi_(0,i) * exp(- b(r) \Sigma_j^S \omega_{\phi,ij} N_j(t) ) }} #' -#' \ifelse{html}{\out{  σi(r,t) = σ0,i * e - Cσ b(r) ΣjS ωσ,ij N(j,t) }}{\deqn{σ_i(r,t)=σ_(0,i) * exp(- C_\sigma b(r) \Sigma_j^S ω_{σ,ij} N_j(t) )}} +#' \ifelse{html}{\out{ σi(r,t) = σ0,i * e - Cσ b(r) ΣjS ωσ,ij N(j,t) }}{\deqn{\sigma_i(r,t)=\sigma_(0,i) * exp(- C_\sigma b(r) \Sigma_j^S \omega_{\sigma,ij} N_j(t) )}} #' -#' \ifelse{html}{\out{  γi(r,t) = γ0,i * e - Cγ b(r) ΣjS ωγ,ij N(j,t)}}{\deqn{γ_i(r,t)=γ_(0,i) * exp(- C_γ b(r) \Sigma_j^S ω_{γ,ij} N_j(t) )}} +#' \ifelse{html}{\out{ γi(r,t) = γ0,i * e - Cγ b(r) ΣjS ωγ,ij N(j,t)}}{\deqn{\gamma_i(r,t)=\gamma_(0,i) * exp(- C_\gamma b(r) \Sigma_j^S \omega_{\gamma,ij} N_j(t) )}} #' -#' where \ifelse{html}{\out{ωφ}}{\eqn{ω_φ}}, \ifelse{html}{\out{ωσ}}{\eqn{ω_σ}}, \ifelse{html}{\out{ωγ}}{\eqn{ω_γ}} are weight matrices given by \code{FecStageWtsMatrix, DevStageWtsMatrix, SurvStageWtsMatrix}. Their elements \ifelse{html}{\out{ωij}}{\eqn{ω_ij}} +#' where \ifelse{html}{\out{ωφ}}{\eqn{\omega_\phi}}, \ifelse{html}{\out{ωσ}}{\eqn{\omega_\sigma}}, \ifelse{html}{\out{ωγ}}{\eqn{\omega_\gamma}} are weight matrices given by \code{FecStageWtsMatrix, DevStageWtsMatrix, SurvStageWtsMatrix}. Their elements \ifelse{html}{\out{ωij}}{\eqn{\omega_ij}} #' represent the contributions of the abundance of stage \eqn{j} to the density dependence in the fecundity / survival / development of stage \eqn{i}, thus they are quadratic matrices of size \code{Stages}\eqn{^2}. Note that the row sums are not required to be normalized, therefore they can be used #' to scale the density-dependence for the different stages. In fact, any real value will be accepted for the single weights, so care should be taken when setting them. #' @examples # Stage-structure for simple sexual model @@ -159,7 +159,7 @@ #' @author Anne-Kathleen Malchow #' @name StageStructure #' @export StageStructure -StageStructure <- setClass("StagesParams", slots = c(Stages = "integer_OR_numeric", +StageStructure <- methods::setClass("StagesParams", slots = c(Stages = "integer_OR_numeric", TransMatrix = "matrix", MaxAge = "integer_OR_numeric", MinAge = "integer_OR_numeric", @@ -373,9 +373,9 @@ setMethod("initialize", "StagesParams", function(.Object,...) { if (!is.null(args$SurvStageWtsMatrix)) { .Object@SurvStageWts <- TRUE } - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (!.Object@FecDensDep) { if (.Object@FecStageWts) { @@ -489,12 +489,12 @@ setMethod("plotProbs", "StagesParams", function(x, stage = NULL, sex = NULL, xma this.sex = 0 } if (this.stage %in% stage && this.sex %in% sex) { - if(x@FecDensDep){ lines(xvals, fecs[line]*exp(-xvals), type = "l", lty = 1, col = line) } - else{ lines(xvals, rep(fecs[line], length(xvals)), type = "l", lty = 1, col = line) } - if(x@SurvDensDep){ lines(xvals, surv[line]*exp(-x@SurvDensCoeff*xvals), type = "l", lty = 2, col = line) } - else{ lines(xvals, rep(surv[line], length(xvals)), type = "l", lty = 2, col = line) } - if(x@DevDensDep){ lines(xvals, devs[line]*exp(-x@DevDensCoeff*xvals), type = "l", lty = 3, col = line) } - else{ lines(xvals, rep(devs[line], length(xvals)), type = "l", lty = 3, col = line) } + if(x@FecDensDep){ graphics::lines(xvals, fecs[line]*exp(-xvals), type = "l", lty = 1, col = line) } + else{ graphics::lines(xvals, rep(fecs[line], length(xvals)), type = "l", lty = 1, col = line) } + if(x@SurvDensDep){ graphics::lines(xvals, surv[line]*exp(-x@SurvDensCoeff*xvals), type = "l", lty = 2, col = line) } + else{ graphics::lines(xvals, rep(surv[line], length(xvals)), type = "l", lty = 2, col = line) } + if(x@DevDensDep){ graphics::lines(xvals, devs[line]*exp(-x@DevDensCoeff*xvals), type = "l", lty = 3, col = line) } + else{ graphics::lines(xvals, rep(devs[line], length(xvals)), type = "l", lty = 3, col = line) } if(SexDep) {leg.txt <- c(leg.txt, paste0("Stage ",this.stage, ifelse(this.sex," female"," male")))} else {leg.txt <- c(leg.txt, paste0("Stage ",this.stage))} leg.col <- c(leg.col, line) @@ -502,7 +502,7 @@ setMethod("plotProbs", "StagesParams", function(x, stage = NULL, sex = NULL, xma } if (length(leg.txt)>0) { leg.txt <- c("Fecundity","Survival prob.","Developmt. prob.",leg.txt) - legend("topright", leg.txt, col = c(rep(1,3),leg.col), lwd = 1.5, lty = c(1:3,rep(1,length(leg.col))) ) + graphics::legend("topright", leg.txt, col = c(rep(1,3),leg.col), lwd = 1.5, lty = c(1:3,rep(1,length(leg.col))) ) } }) @@ -512,7 +512,7 @@ setMethod("plotProbs", "StagesParams", function(x, stage = NULL, sex = NULL, xma # contains basic demographic parameters (originally in RS 'Rarameters'-file) and optionally the 'StageStruct' object # define this ClassUnion so that the 'stages' slot in the parameter master class 'RSparams' can be FALSE for option 'population with non-overlapping generations' -setClassUnion("StagesSlot", c("logical", "StagesParams")) +methods::setClassUnion("StagesSlot", c("logical", "StagesParams")) #' Set Demographic Parameters #' @@ -543,7 +543,7 @@ setClassUnion("StagesSlot", c("logical", "StagesParams")) #' \emph{Asexual / only-female models:} (\code{ReproductionType=0})\cr #' Recruitment is determined by a stochastic, individual-based formulation of the \insertCite{smith1973;textual}{RangeShiftR} population model, where the number of offspring produced by a single individual in the cell/patch \eqn{i} at time \eqn{t}, is drawn from the following distribution:\cr #' -#' \ifelse{html}{\out{  Njuv(i,t) = Poisson( R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t))bc ) ) } }{\deqn{N_juv(i,t) = Poisson( R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } +#' \ifelse{html}{\out{Njuv(i,t) = Poisson( R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t))bc ) ) } }{\deqn{N_juv(i,t) = Poisson( R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } #' #' Here, \eqn{R(i,t)} is the maximum growth rate \code{Rmax} (obtained at very low density only) and \eqn{K(i,t)} is the carrying capacity #' at patch \eqn{i} and time \eqn{t}. @@ -559,7 +559,7 @@ setClassUnion("StagesSlot", c("logical", "StagesParams")) #' This is the simplest form of mate limitation. Each female individual is assumed to mate, as long as there is at least one male in the population. As for the asexual case, the Maynard Smith and Slatkin model is used to determine the expected number of #' offspring produced by each female. To maintain equivalence between the asexual and sexual versions, the expected value of the Poisson distribution is multiplied by \eqn{2} (Lindström & Kokko 1998):\cr #' -#' \ifelse{html}{\out{  Njuv(i,t) = Poisson( 2 R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t) )bc ) ) } }{\deqn{N_juv(i,t) = Poisson( 2 R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } +#' \ifelse{html}{\out{Njuv(i,t) = Poisson( 2 R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t) )bc ) ) } }{\deqn{N_juv(i,t) = Poisson( 2 R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } #' #' \emph{Complex mating system:} (\code{ReproductionType=2})\cr #' More complex and flexible mating system. Mating is explicitly modelled through a mating function @@ -581,7 +581,7 @@ setClassUnion("StagesSlot", c("logical", "StagesParams")) #' @author Anne-Kathleen Malchow #' @name Demography #' @export Demography -Demography <- setClass("DemogParams", slots = c(Rmax = "integer_OR_numeric", +Demography <- methods::setClass("DemogParams", slots = c(Rmax = "integer_OR_numeric", bc = "numeric", StageStruct = "StagesSlot", ReproductionType = "integer_OR_numeric", @@ -626,7 +626,7 @@ setValidity("DemogParams", function(object) { } } } - validObject(object@StageStruct) + methods::validObject(object@StageStruct) if (class(object@StageStruct)[1]=="logical") { if (object@StageStruct) { # StageStruct=TRUE msg <- c(msg, "StageStruct must either be FALSE or an object of class \"StagesParams\" !") @@ -804,9 +804,9 @@ setValidity("DemogParams", function(object) { setMethod("initialize", "DemogParams", function(.Object,...) { this_func = "Demography(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (class(.Object@StageStruct)[1]=="StagesParams") { .Object@Rmax = -9L diff --git a/RangeShiftR/R/class_DispersalParams.R b/RangeShiftR/R/class_DispersalParams.R index 29e88a0..90951da 100644 --- a/RangeShiftR/R/class_DispersalParams.R +++ b/RangeShiftR/R/class_DispersalParams.R @@ -58,18 +58,18 @@ #' #' The emigration probability \eqn{d} can be density-dependent (set \code{DensDep=TRUE}), in which case it is given by the following function, introduced by \insertCite{kun2006evolution;textual}{RangeShiftR}: #' -#' \ifelse{html}{\out{   d(i,t) = D0 / ( 1 + e-αsub>E (N(i,t) / K(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-α_E (N(i,t)/K(i,t) - β_E) ] ) } } +#' \ifelse{html}{\out{ d(i,t) = D0 / ( 1 + e-αsub>E (N(i,t) / K(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-\alpha_E (N(i,t)/K(i,t) - \beta_E) ] ) } } #' #' In the case of stage-structured models this equation is modified to: #' -#' \ifelse{html}{\out{   d(i,t) = D0 / ( 1 + e-αsub>E (b(i,t) * N(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-α_E (b(i,t) N(i,t) - β_E) ] ) } } +#' \ifelse{html}{\out{ d(i,t) = D0 / ( 1 + e-αsub>E (b(i,t) * N(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-\alpha_E (b(i,t) N(i,t) - \beta_E) ] ) } } #' #' In the first case, \eqn{K(i,t)} is the carrying capacity of the cell/patch \eqn{i} at time \eqn{t} given by \code{K_or_DensDep}. #' In the latter case, \eqn{b(i,t)} represents the strength of density dependence and is given by the inverse of \code{K_or_DensDep}.\cr #' Further, \ifelse{html}{\out{D0}}{\eqn{D_0}} is the maximum emigration probability, #' \eqn{N(i,t)} is the number of individuals in the cell/patch \eqn{i} at time \eqn{t}, -#' \ifelse{html}{\out{βE}}{\eqn{β_S}} is the inflection point of the function and -#' \ifelse{html}{\out{αE}}{\eqn{α_S}} is the slope at the inflection point.\cr +#' \ifelse{html}{\out{βE}}{\eqn{\beta_S}} is the inflection point of the function and +#' \ifelse{html}{\out{αE}}{\eqn{\alpha_S}} is the slope at the inflection point.\cr #' #' Various functions have been proposed for density dependent emigration \insertCite{hovestadt2010information,poethke2011ability}{RangeShiftR}. #' This one was chosen here because it is a flexible function that @@ -78,8 +78,8 @@ #' Information acquisition is not explicitly modelled. #' #' The emigration probability can be allowed to vary between individuals (set \code{IndVar=TRUE}) and to evolve. In the this case, individuals exhibit either one trait -#' determining the density-independent \eqn{d} (when \code{DensDep=FALSE}), or the three traits \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α} and -#' \eqn{β} determining the density-dependent emigration probability (when \code{DensDep=TRUE}).\cr +#' determining the density-independent \eqn{d} (when \code{DensDep=FALSE}), or the three traits \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha} and +#' \eqn{\beta} determining the density-dependent emigration probability (when \code{DensDep=TRUE}).\cr #' For each trait the initial distribution in the population (as mean and standard variation) must be set in \code{EmigProb} (instead of only one constant value), #' as well as their scaling factors in \code{TraitScaleFactor} (see \code{\link[RangeShiftR]{Genetics}}). #' Also, if \code{IndVar=TRUE} is set for a stage-structured population, it is required to specify the stage which emigrates via \code{EmigStage}. @@ -91,7 +91,7 @@ #' #' The parameters that determine the emigration probabilities have to be provided via \code{EmigProb}, which generally takes a matrix, or - if only a single constant probability is #' used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. The format of the matrix is defined as follows: The number of columns depend on the options \code{DensDep} and \code{IndVar}. If \code{DensDep=FALSE}, the -#' density-independent probability \eqn{d} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α} and \eqn{β} (cp. equation above) must be specified. +#' density-independent probability \eqn{d} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha} and \eqn{\beta} (cp. equation above) must be specified. #' Additionally, if \code{IndVar=FALSE}, these parameters are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective mean and #' standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. #' @@ -103,20 +103,20 @@ #' F \tab F \tab T \tab F \tab stage, \eqn{d} \cr #' F \tab F \tab F \tab T \tab sex, \eqn{d} \cr #' F \tab F \tab T \tab T \tab stage, sex, \eqn{d} \cr -#' T \tab F \tab F \tab F \tab \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α}, \eqn{β} \cr +#' T \tab F \tab F \tab F \tab \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha}, \eqn{\beta} \cr #' F \tab T \tab F \tab F \tab mean\eqn{(d)}, sd\eqn{(d)} \cr -#' T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(α)}, sd\eqn{(α)}, mean\eqn{(β)}, sd\eqn{(β)} \cr -#' \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr -#' T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(α)}, sd\eqn{(α)}, mean\eqn{(β)}, sd\eqn{(β)} +#' T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(\alpha)}, sd\eqn{(\alpha)}, mean\eqn{(\beta)}, sd\eqn{(\beta)} \cr +#' \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr +#' T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(\alpha)}, sd\eqn{(\alpha)}, mean\eqn{(\beta)}, sd\eqn{(\beta)} #' } #' #' The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly one row for each stage/sex combination. For example, in the case of density-, stage- and sex-dependent emigration with no individual variability: -#' \tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1.0 \tab \out{ } 20 \tab \out{ } 0.2 \cr -#' \out{ } 0 \tab \out{ } 1 \tab \out{ } 1.0 \tab \out{ } 20 \tab \out{ } 0.1 \cr -#' \out{ } 1 \tab \out{ } 0 \tab \out{ } 0.7 \tab \out{ } 25 \tab \out{ } 0.5 \cr -#' \out{ } 1 \tab \out{ } 1 \tab \out{ } 0.8 \tab \out{ } 50 \tab \out{ } 0.5 \cr -#' \out{ } 2 \tab \out{ } 0 \tab \out{ } 0.4 \tab \out{ } 10 \tab \out{ } 1.0 \cr -#' \out{ } 2 \tab \out{ } 1 \tab \out{ } 0.5 \tab \out{ } 20 \tab \out{ } 1.0 +#' \tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1.0 \tab \out{} 20 \tab \out{} 0.2 \cr +#' \out{} 0 \tab \out{} 1 \tab \out{} 1.0 \tab \out{} 20 \tab \out{} 0.1 \cr +#' \out{} 1 \tab \out{} 0 \tab \out{} 0.7 \tab \out{} 25 \tab \out{} 0.5 \cr +#' \out{} 1 \tab \out{} 1 \tab \out{} 0.8 \tab \out{} 50 \tab \out{} 0.5 \cr +#' \out{} 2 \tab \out{} 0 \tab \out{} 0.4 \tab \out{} 10 \tab \out{} 1.0 \cr +#' \out{} 2 \tab \out{} 1 \tab \out{} 0.5 \tab \out{} 20 \tab \out{} 1.0 #' } #' #' In the special case that \code{DensDep=FALSE} and transfer is realised by \code{\link[RangeShiftR]{DispersalKernel}}, then the option \code{UseFullKern} may be switched on. It @@ -143,7 +143,7 @@ #' @author Anne-Kathleen Malchow #' @name Emigration #' @export Emigration -Emigration <- setClass("EmigrationParams", slots = c(DensDep = "logical", +Emigration <- methods::setClass("EmigrationParams", slots = c(DensDep = "logical", IndVar = "logical", StageDep = "logical", SexDep = "logical", @@ -250,10 +250,10 @@ setValidity("EmigrationParams", function(object) { } else { if (object@TraitScaleFactor[1] <= 0.0 || object@TraitScaleFactor[1] > 1.0 ) { - msg <- c(msg, "TraitScaleFactor μ(D0) must be in the half-open interval (0,1] !") + msg <- c(msg, "TraitScaleFactor mu(D0) must be in the half-open interval (0,1] !") } if (any(object@TraitScaleFactor[2:3] <= 0.0 )) { - msg <- c(msg, "TraitScaleFactor μ(α) and μ(β) must be strictly positive !") + msg <- c(msg, "TraitScaleFactor mu(\alpha) and mu(\beta) must be strictly positive !") } } } @@ -263,7 +263,7 @@ setValidity("EmigrationParams", function(object) { } else { if (object@TraitScaleFactor <= 0 || object@TraitScaleFactor > 1 ) { - msg <- c(msg, "TraitScaleFactor μ(D0) must be in the half-open interval (0,1] !") + msg <- c(msg, "TraitScaleFactor mu(D0) must be in the half-open interval (0,1] !") } } } @@ -282,9 +282,9 @@ setValidity("EmigrationParams", function(object) { setMethod("initialize", "EmigrationParams", function(.Object, ...) { this_func = "Emigration(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (!is.null(args$EmigProb)) { if (class(args$EmigProb)[1] =="numeric" && length(args$EmigProb)==1) { @@ -385,17 +385,17 @@ setMethod("plotProbs", "EmigrationParams", function(x, stage = NULL, sex = NULL, res[,6] <- densdep(xvals, A0 = emig[line,ind_D0]+emig[line,ind_D0+1], alpha = emig[line,ind_D0+2]-emig[line,ind_D0+3], beta = emig[line,ind_D0+4]+emig[line,ind_D0+5]) res[,7] <- densdep(xvals, A0 = emig[line,ind_D0]+emig[line,ind_D0+1], alpha = emig[line,ind_D0+2]+emig[line,ind_D0+3], beta = emig[line,ind_D0+4]-emig[line,ind_D0+5]) res[,8] <- densdep(xvals, A0 = emig[line,ind_D0]+emig[line,ind_D0+1], alpha = emig[line,ind_D0+2]+emig[line,ind_D0+3], beta = emig[line,ind_D0+4]+emig[line,ind_D0+5]) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } else {#constant - polygon(c(0,xmax,xmax,0), c(rep(emig[line,ind_D0]-emig[line,ind_D0+1],2),rep(emig[line,ind_D0]+emig[line,ind_D0+1],2)), border=NA, col='grey80') + graphics::polygon(c(0,xmax,xmax,0), c(rep(emig[line,ind_D0]-emig[line,ind_D0+1],2),rep(emig[line,ind_D0]+emig[line,ind_D0+1],2)), border=NA, col='grey80') } } if (x@DensDep) { - lines(xvals, densdep(xvals, A0 = emig[line,ind_D0], alpha = emig[line,ind_D0+IV], beta = emig[line,ind_D0+2*IV]), type = "l", lty = 1, col = line) + graphics::lines(xvals, densdep(xvals, A0 = emig[line,ind_D0], alpha = emig[line,ind_D0+IV], beta = emig[line,ind_D0+2*IV]), type = "l", lty = 1, col = line) } else {#constant - lines(x=c(0,xmax), y=rep(emig[line,ind_D0],2), type = "l", lty = 1, col = line) + graphics::lines(x=c(0,xmax), y=rep(emig[line,ind_D0],2), type = "l", lty = 1, col = line) } if (x@StageDep) { if (x@SexDep) {leg.txt <- c(leg.txt, paste0("Stage ",emig[line,1], ifelse(emig[line,2]," male"," female")))} else {leg.txt <- c(leg.txt, paste0("Stage ",emig[line,1]))} @@ -405,7 +405,7 @@ setMethod("plotProbs", "EmigrationParams", function(x, stage = NULL, sex = NULL, } } if (length(leg.txt)>0) { - legend("topleft", leg.txt, col = 1:nrow(emig), lwd = 1.5) + graphics::legend("topleft", leg.txt, col = 1:nrow(emig), lwd = 1.5) } }) @@ -439,7 +439,7 @@ setMethod("plotProbs", "EmigrationParams", function(x, stage = NULL, sex = NULL, #' \insertAllCited{} #' @author Anne-Kathleen Malchow #' @name Transfer -TransferParams <- setClass("TransferParams") +TransferParams <- methods::setClass("TransferParams") setMethod("show", "TransferParams", function(object){ if (class(object)[1] == "DispersalKernel") cat(" Dispersal Kernel\n") if (class(object)[1] == "StochMove") cat(" Stochastic Movement Simulator\n") @@ -491,10 +491,10 @@ setMethod("show", "TransferParams", function(object){ #' #' \emph{Negative exponential} \cr #' If the individual disperses, the distance and the movement direction are determined in continuous space. -#' The distance is drawn from a negative exponential distribution with a given mean \eqn{δ}, and the direction is selected randomly from a uniform -#' distribution between \eqn{0} and \eqn{2π} radians. +#' The distance is drawn from a negative exponential distribution with a given mean \eqn{\delta}, and the direction is selected randomly from a uniform +#' distribution between \eqn{0} and \eqn{2\pi} radians. #' -#' \ifelse{html}{\out{   p(d;δ) = δ-1 e- d / δ}}{\deqn{ p(d;δ) = 1/δ exp(-d/δ) } } +#' \ifelse{html}{\out{ p(d;δ) = δ-1 e- d / δ}}{\deqn{ p(d;\delta) = 1/\delta exp(-d/\delta) } } #' #' If the arrival point lies beyond the boundary of the landscape, distance and direction are re-drawn.\cr #' The individual is displaced from a random point (using continuous coordinates) inside the natal cell to the arrival cell where the model @@ -511,17 +511,17 @@ setMethod("show", "TransferParams", function(object){ #' #' \emph{Mixed kernel} \cr #' The distance an individual moves is sampled from a mixed kernel given by the combination of two negative exponentials -#' with different means \ifelse{html}{\out{δ1}}{\eqn{δ_1}} and \ifelse{html}{\out{δ2}}{\eqn{δ_2}}, +#' with different means \ifelse{html}{\out{δ1}}{\eqn{\delta_1}} and \ifelse{html}{\out{δ2}}{\eqn{\delta_2}}, #' occurring with probability \ifelse{html}{\out{pI}}{\eqn{p_I}} and \eqn{1-}\ifelse{html}{\out{pI}}{\eqn{p_I}} respectively \insertCite{hovestadt2011all}{RangeShiftR}. #' Otherwise, the conditions for the single kernel apply. #' -#' \ifelse{html}{\out{   p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1)}}{\deqn{ p(d; δ_1,δ_2) = p_I p(d;δ_1) + (1-p_I) p(d;δ_2)}} +#' \ifelse{html}{\out{ p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1)}}{\deqn{ p(d; \delta_1,\delta_2) = p_I p(d;\delta_1) + (1-p_I) p(d;\delta_2)}} #' #' For both types of kernel, inter-individual variability of the kernel traits is possible (set \code{IndVar=TRUE}). Individuals will -#' carry either one trait for \eqn{δ} or three traits for \ifelse{html}{\out{δ1}}{\eqn{δ_1}}, \ifelse{html}{\out{δ2}}{\eqn{δ_2}} and +#' carry either one trait for \eqn{\delta} or three traits for \ifelse{html}{\out{δ1}}{\eqn{\delta_1}}, \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} and #' \ifelse{html}{\out{pI}}{\eqn{p_I}}, which they inherit from their parents.\cr -#' Dispersal kernels can also be sex-dependent (set \code{SexDep=TRUE}). In the case of inter-individual variability, the number of traits is doubled to two trait (female \eqn{δ} -#' and male δ) or six traits (female and male \ifelse{html}{\out{δ1}}{\eqn{δ_1}}, \ifelse{html}{\out{δ2}}{\eqn{δ_2}} and \ifelse{html}{\out{pI}}{\eqn{p_I}}).\cr +#' Dispersal kernels can also be sex-dependent (set \code{SexDep=TRUE}). In the case of inter-individual variability, the number of traits is doubled to two trait (female \eqn{\delta} +#' and male delta) or six traits (female and male \ifelse{html}{\out{δ1}}{\eqn{\delta_1}}, \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} and \ifelse{html}{\out{pI}}{\eqn{p_I}}).\cr #' For each trait the initial distribution in the population (as mean and standard variation) must be set in \code{Distances} (instead of only one constant value), #' as well as their scaling factors in \code{TraitScaleFactor} (see \code{\link[RangeShiftR]{Genetics}}).\cr #' @@ -529,8 +529,8 @@ setMethod("show", "TransferParams", function(object){ #' #' All dispersal kernel parameters have to be provided via \code{Distances}, which generally takes a matrix, or - if only a single constant mean distance is #' used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. The format of the matrix is defined as follows: The number of columns depend on the options \code{IndVar} and \code{DoubleKernel}. -#' If \code{DoubleKernel=FALSE}, the mean dispersal distance \eqn{δ} must be specified (in meters). If \code{DoubleKernel=TRUE}, the mean dispersal distances -#' \ifelse{html}{\out{δ1}}{\eqn{δ_1}} and \ifelse{html}{\out{δ2}}{\eqn{δ_2}} (in meters), as well as the probability \ifelse{html}{\out{pI}}{\eqn{p_I}} of using Kernel-1 must be specified. +#' If \code{DoubleKernel=FALSE}, the mean dispersal distance \eqn{\delta} must be specified (in meters). If \code{DoubleKernel=TRUE}, the mean dispersal distances +#' \ifelse{html}{\out{δ1}}{\eqn{\delta_1}} and \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} (in meters), as well as the probability \ifelse{html}{\out{pI}}{\eqn{p_I}} of using Kernel-1 must be specified. #' Additionally, if \code{IndVar=FALSE}, these parameters are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective mean and #' standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. #' @@ -539,25 +539,25 @@ setMethod("show", "TransferParams", function(object){ #' table lists the required columns and their correct order for different settings: #' #' \tabular{ccccc}{IndVar \tab DoubleKernel \tab StageDep \tab SexDep \tab columns \cr -#' F \tab F \tab F \tab F \tab \eqn{δ} \cr -#' F \tab F \tab T \tab F \tab stage, \eqn{δ} \cr -#' F \tab F \tab F \tab T \tab sex, \eqn{δ} \cr -#' F \tab F \tab T \tab T \tab stage, sex, \eqn{δ} \cr -#' F \tab T \tab F \tab F \tab \ifelse{html}{\out{δ1, δ2, pI}}{\eqn{δ_1, δ_2, p_I}} \cr -#' T \tab F \tab F \tab F \tab mean\eqn{(δ)}, sd\eqn{(δ)} \cr -#' T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(δ_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(δ_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(δ_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(δ_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} \cr -#' \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr -#' T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(δ_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(δ_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(δ_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(δ_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} +#' F \tab F \tab F \tab F \tab \eqn{\delta} \cr +#' F \tab F \tab T \tab F \tab stage, \eqn{\delta} \cr +#' F \tab F \tab F \tab T \tab sex, \eqn{\delta} \cr +#' F \tab F \tab T \tab T \tab stage, sex, \eqn{\delta} \cr +#' F \tab T \tab F \tab F \tab \ifelse{html}{\out{δ1, δ2, pI}}{\eqn{\delta_1, \delta_2, p_I}} \cr +#' T \tab F \tab F \tab F \tab mean\eqn{(\delta)}, sd\eqn{(\delta)} \cr +#' T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(\delta_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(\delta_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(\delta_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(\delta_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} \cr +#' \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr +#' T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(\delta_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(\delta_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(\delta_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(\delta_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} #' } #' #' The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly #' one row for each stage/sex combination. For example, in the case of a mixed kernel with stage- and sex-dependent distances and no individual variability: -#' \tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1000 \tab \out{ } 4500 \tab \out{ } 0.92 \cr -#' \out{ } 0 \tab \out{ } 1 \tab \out{ } 1400 \tab \out{ } 6000 \tab \out{ } 0.95 \cr -#' \out{ } 1 \tab \out{ } 0 \tab \out{ } 700 \tab \out{ } 500 \tab \out{ } 0.50 \cr -#' \out{ } 1 \tab \out{ } 1 \tab \out{ } 500 \tab \out{ } 600 \tab \out{ } 0.55 \cr -#' \out{ } 2 \tab \out{ } 0 \tab \out{ } 100 \tab \out{ } 0 \tab \out{ } 1.0 \cr -#' \out{ } 2 \tab \out{ } 1 \tab \out{ } 100 \tab \out{ } 0 \tab \out{ } 1.0 +#' \tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1000 \tab \out{} 4500 \tab \out{} 0.92 \cr +#' \out{} 0 \tab \out{} 1 \tab \out{} 1400 \tab \out{} 6000 \tab \out{} 0.95 \cr +#' \out{} 1 \tab \out{} 0 \tab \out{} 700 \tab \out{} 500 \tab \out{} 0.50 \cr +#' \out{} 1 \tab \out{} 1 \tab \out{} 500 \tab \out{} 600 \tab \out{} 0.55 \cr +#' \out{} 2 \tab \out{} 0 \tab \out{} 100 \tab \out{} 0 \tab \out{} 1.0 \cr +#' \out{} 2 \tab \out{} 1 \tab \out{} 100 \tab \out{} 0 \tab \out{} 1.0 #' } #' #' In the case that the dispersal kernel is applied to the entire @@ -573,7 +573,7 @@ setMethod("show", "TransferParams", function(object){ #' A second source of dispersal mortality can be specified via the option \code{DistMort}: The probability of mortality is either a constant #' (\eqn{m=}\code{MortProb}) or a function of distance \eqn{d} (i.e. individuals that travel further are more likely to die): #' -#' \ifelse{html}{\out{   m(d) = 1 / ( 1 + e-a (d- b) ) } }{\deqn{ m(d) = 1 / ( 1 + exp[-α (d-b) ] ) } } +#' \ifelse{html}{\out{ m(d) = 1 / ( 1 + e-a (d- b) ) } }{\deqn{ m(d) = 1 / ( 1 + exp[-\alpha (d-b) ] ) } } #' #' with the inflection point \eqn{b=}\code{InflPoint} at which \eqn{m(d=b)=0.5} and the slope \eqn{a=}\code{Slope}.This option may be thought #' to represent the increased energetic, time or attritional costs that longer-distance dispersers will experience \insertCite{bonte2012costs}{RangeShiftR}. @@ -596,7 +596,7 @@ setMethod("show", "TransferParams", function(object){ #' @author Anne-Kathleen Malchow #' @name DispersalKernel #' @export DispersalKernel -DispersalKernel <- setClass("DispersalKernel", slots = c(IndVar = "logical", +DispersalKernel <- methods::setClass("DispersalKernel", slots = c(IndVar = "logical", DoubleKernel = "logical", StageDep = "logical", SexDep = "logical", @@ -702,10 +702,10 @@ setValidity("DispersalKernel", function(object) { } else { if (object@TraitScaleFactor[3] <= 0.0 || object@TraitScaleFactor[3] > 1.0 ) { - msg <- c(msg, "TraitScaleFactor μ(p) must be in the half-open interval (0,1] !") + msg <- c(msg, "TraitScaleFactor mu(p) must be in the half-open interval (0,1] !") } if (any(object@TraitScaleFactor[1:2] <= 0.0 )) { - msg <- c(msg, "TraitScaleFactor μ(δ1) and μ(δ2) must be strictly positive !") + msg <- c(msg, "TraitScaleFactor mu(delta1) and mu(delta2) must be strictly positive !") } } } @@ -715,7 +715,7 @@ setValidity("DispersalKernel", function(object) { } else { if (object@TraitScaleFactor <= 0.0) { - msg <- c(msg, "TraitScaleFactor μ(δ) must be strictly positive !") + msg <- c(msg, "TraitScaleFactor mu(delta) must be strictly positive !") } } } @@ -750,9 +750,9 @@ setValidity("DispersalKernel", function(object) { setMethod("initialize", "DispersalKernel", function(.Object, ...) { this_func = "DispersalKernel(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (class(args$Distances)[1]=="numeric" && length(args$Distances)==1) { .Object@Distances <- as.matrix(args$Distances) @@ -782,7 +782,7 @@ setMethod("initialize", "DispersalKernel", function(.Object, ...) { .Object} ) setMethod("show", "DispersalKernel", function(object){ - callNextMethod() + methods::callNextMethod() if (object@IndVar) { cat(" IndVar =", object@IndVar, "\n") } @@ -876,15 +876,15 @@ setMethod("plotProbs", "DispersalKernel", function(x, mortality = FALSE, combine if (!combinekernels){ if (x@IndVar) { res <- matrix(ncol = 3, nrow = length(xvals)) - res[,1] <- dexp(xvals, rate = 1/(dists[line,ind_kernel1])) - res[,2] <- dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) - res[,3] <- dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + res[,1] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1])) + res[,2] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + res[,3] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } - lines(xvals,dexp(xvals,rate = 1/dists[line,ind_kernel1]), type = "l", lty = 1, col = line) + graphics::lines(xvals,stats::dexp(xvals,rate = 1/dists[line,ind_kernel1]), type = "l", lty = 1, col = line) } } - else {lines(xvals, rep(0, length(xvals)), type = "l", lty = 1, col = line)} + else {graphics::lines(xvals, rep(0, length(xvals)), type = "l", lty = 1, col = line)} if (x@DoubleKernel){ if(dists[line,ind_kernel2]>0){ if (combinekernels){ @@ -892,31 +892,31 @@ setMethod("plotProbs", "DispersalKernel", function(x, mortality = FALSE, combine if (x@IndVar) { pI_sd <- c(pI+dists[line,ind_pI+1],pI-dists[line,ind_pI+1]) res <- matrix(ncol = 8, nrow = length(xvals)) - res[,1] <- pI_sd[1] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) - res[,2] <- pI_sd[2] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) - res[,3] <- pI_sd[1] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) - res[,4] <- pI_sd[2] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) - res[,5] <- pI_sd[1] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) - res[,6] <- pI_sd[2] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) - res[,7] <- pI_sd[1] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) - res[,8] <- pI_sd[2] * dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + res[,1] <- pI_sd[1] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) + res[,2] <- pI_sd[2] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) + res[,3] <- pI_sd[1] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) + res[,4] <- pI_sd[2] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) + res[,5] <- pI_sd[1] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) + res[,6] <- pI_sd[2] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]+dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) + res[,7] <- pI_sd[1] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[1]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) + res[,8] <- pI_sd[2] * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel1]-dists[line,ind_kernel1+1])) + (1-pI_sd[2]) * stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } - yvals <- pI * dexp(xvals, rate = 1/dists[line,ind_kernel1]) + (1-pI) * dexp(xvals, rate = 1/dists[line,ind_kernel2]) - lines(xvals, yvals , type = "l", lty = 1, col = line) + yvals <- pI * stats::dexp(xvals, rate = 1/dists[line,ind_kernel1]) + (1-pI) * stats::dexp(xvals, rate = 1/dists[line,ind_kernel2]) + graphics::lines(xvals, yvals , type = "l", lty = 1, col = line) } else { if (x@IndVar) { - res[,1] <- dexp(xvals, rate = 1/(dists[line,ind_kernel2])) - res[,2] <- dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) - res[,3] <- dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + res[,1] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2])) + res[,2] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]+dists[line,ind_kernel2+1])) + res[,3] <- stats::dexp(xvals, rate = 1/(dists[line,ind_kernel2]-dists[line,ind_kernel2+1])) + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } - lines(xvals,dexp(xvals,rate = 1/dists[line,ind_kernel2]), type = "l", lty = 2, col = line) + graphics::lines(xvals,stats::dexp(xvals,rate = 1/dists[line,ind_kernel2]), type = "l", lty = 2, col = line) } } else{ - lines(xvals, rep(0, length(xvals)), type = "l", lty = 2, col = line) + graphics::lines(xvals, rep(0, length(xvals)), type = "l", lty = 2, col = line) } } if (x@StageDep) { @@ -927,7 +927,7 @@ setMethod("plotProbs", "DispersalKernel", function(x, mortality = FALSE, combine } } if (length(leg.txt)>0) { - legend("topright", leg.txt, col = 1:nrow(dists), lwd = 1.5) + graphics::legend("topright", leg.txt, col = 1:nrow(dists), lwd = 1.5) } } }) @@ -1063,7 +1063,7 @@ setMethod("plotProbs", "DispersalKernel", function(x, mortality = FALSE, combine #' @author Anne-Kathleen Malchow #' @name SMS #' @export SMS -SMS <- setClass("StochMove", slots = c(PR = "integer_OR_numeric", +SMS <- methods::setClass("StochMove", slots = c(PR = "integer_OR_numeric", PRMethod = "integer_OR_numeric", # Perceptual range method: 1 = arithmetic mean; 2 = harmonic mean; 3 = weighted arithmtic mean MemSize = "integer_OR_numeric", GoalType = "integer_OR_numeric", # 0 (none) or 2 (dispersal bias) @@ -1311,9 +1311,9 @@ setValidity("StochMove", function(object) { setMethod("initialize", "StochMove", function(.Object,...) { this_func = "SMS(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (!.Object@GoalType) { # GoalType = 0 .Object@GoalBias = 1.0 @@ -1340,7 +1340,7 @@ setMethod("initialize", "StochMove", function(.Object,...) { .Object} ) setMethod("show", "StochMove", function(object){ - callNextMethod() + methods::callNextMethod() cat(" PR =", object@PR, ", MemSize =", object@MemSize, "\n") if (object@PRMethod == 1) cat(" Method: Arithmetic mean \n") if (object@PRMethod == 2) cat(" Method: Harmonic mean \n") @@ -1402,17 +1402,17 @@ setMethod("plotProbs", "StochMove", function(x, xmax = NULL, ymax = NULL){ res[,6] <- 1+densdep(xvals, A0 = (gb[1]+gb[2]-1), alpha = -(alp[1]-alp[2]), beta = (bet[1]+bet[2])) res[,7] <- 1+densdep(xvals, A0 = (gb[1]+gb[2]-1), alpha = -(alp[1]+alp[2]), beta = (bet[1]-bet[2])) res[,8] <- 1+densdep(xvals, A0 = (gb[1]+gb[2]-1), alpha = -(alp[1]+alp[2]), beta = (bet[1]+bet[2])) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } else {#constant - polygon(c(0,xmax,xmax,0), c(rep(gb[1]-gb[2],2),rep(gb[1]+gb[2],2)), border=NA, col='grey80') + graphics::polygon(c(0,xmax,xmax,0), c(rep(gb[1]-gb[2],2),rep(gb[1]+gb[2],2)), border=NA, col='grey80') } } # plot lines if (x@GoalType == 2) { - lines(xvals, 1+densdep(xvals, A0 = (gb[1]-1), alpha = -alp[1], beta = bet[1]), type = "b", lty = 1, col = "blue") + graphics::lines(xvals, 1+densdep(xvals, A0 = (gb[1]-1), alpha = -alp[1], beta = bet[1]), type = "b", lty = 1, col = "blue") }else { # constant - lines(x=c(0,xmax), y=rep(gb[1],2), type = "b", lty = 1, col = "blue") + graphics::lines(x=c(0,xmax), y=rep(gb[1],2), type = "b", lty = 1, col = "blue") } }) @@ -1430,7 +1430,7 @@ setMethod("plotProbs", "StochMove", function(x, xmax = NULL, ymax = NULL){ #' StepMort = 0.0) #' @param StepLength Step length given in meters, defaults to \eqn{1}.\cr If \code{IndVar=TRUE}, expects a vector of length three #' specifying (Mean, SD, TraitScaleFactor) of \code{StepLength}. -#' @param Rho Correlation parameter \eqn{ρ}, defaults to \eqn{0.5}. Must be in the open interval \eqn{(0,1)}.\cr If \code{IndVar=TRUE}, +#' @param Rho Correlation parameter \eqn{\rho}, defaults to \eqn{0.5}. Must be in the open interval \eqn{(0,1)}.\cr If \code{IndVar=TRUE}, #' expects a vector of length three specifying (Mean, SD, TraitScaleFactor) of \code{Rho}. #' @param IndVar Individual variability in CorrRW traits (i.e. \code{StepLength} and \code{Rho})? Defaults to \code{FALSE}. #' @param StraightenPath Straighten path after decision not to settle in a patch? Defaults to \code{TRUE}, see Details below. @@ -1480,7 +1480,7 @@ setMethod("plotProbs", "StochMove", function(x, xmax = NULL, ymax = NULL){ #' @author Anne-Kathleen Malchow #' @name CorrRW #' @export CorrRW -CorrRW <- setClass("CorrRW", slots = c(IndVar = "logical", +CorrRW <- methods::setClass("CorrRW", slots = c(IndVar = "logical", StepLength = "numeric", Rho = "numeric", StraightenPath = "logical", @@ -1585,14 +1585,14 @@ setValidity("CorrRW", function(object) { # setMethod("initialize", "CorrRW", function(.Object,...) { # this_func = "CorrRW(): " # args <- list(...) -# .Object <- callNextMethod() +# .Object <- methods::callNextMethod() # if ( length(args) == 0 ) { -# validObject(.Object) +# methods::validObject(.Object) # } # .Object} # ) setMethod("show", "CorrRW", function(object){ - callNextMethod() + methods::callNextMethod() if (object@IndVar) { cat(" StepLength =", object@StepLength[1], "\u00B1" , object@StepLength[2], ", scale \u03bc =", object@StepLength[3], "\n") cat(" Rho =", object@Rho[1], "\u00B1" , object@Rho[2], ", scale \u03bc =", object@Rho[3], "\n") @@ -1648,8 +1648,8 @@ setMethod("show", "CorrRW", function(object){ #' In any case, dispersing individuals are not allowed to settle in their natal cell or patch.\cr #' \emph{RangeShiftR} incorporates some basic settlement rules that can be stage- or sex-specific or both (set \code{StageDep}, \code{SexDep}). #' Inter-individual variability (\code{IndVar}) is implemented only for movement processes and then for the three traits -#' determining density-dependent settlement (\ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, -#' \ifelse{html}{\out{βS}}{\eqn{β_S}}; see below). In this case, settlement may not be stage-dependent.\cr +#' determining density-dependent settlement (\ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, +#' \ifelse{html}{\out{βS}}{\eqn{\beta_S}}; see below). In this case, settlement may not be stage-dependent.\cr #' #' \emph{Settlement with dispersal kernels}\cr #' When using a \code{\link[RangeShiftR]{DispersalKernel}}, individuals are displaced directly from the starting location to the arrival location. The suitability @@ -1679,7 +1679,7 @@ setMethod("show", "CorrRW", function(object){ #' \eqn{2} = randomly choose a suitable neighbouring cell or die,\cr #' \eqn{3} = randomly choose a suitable neighbouring cell or wait (stage-structured models only).\cr #' -#' Simple example for sex-dependence only: Females choose a neighbouring cell or wait, males wait: \tabular{cc}{\out{ } 0 \tab \out{ } 3 \cr \out{ } 1 \tab \out{ } 0 } +#' Simple example for sex-dependence only: Females choose a neighbouring cell or wait, males wait: \tabular{cc}{\out{} 0 \tab \out{} 3 \cr \out{} 1 \tab \out{} 0 } #' #' \emph{Settlement with movement processes}\cr #' If individuals are dispersing by one of the two movement processes implemented (\code{\link[RangeShiftR]{SMS}} or @@ -1692,18 +1692,18 @@ setMethod("show", "CorrRW", function(object){ #' Furthermore, the settlement decision can be density-dependent (set \code{DensDep=TRUE}). In this case, the individual has a probability \ifelse{html}{\out{pS}}{\eqn{p_S}} #' of settling in the cell or patch \eqn{i}, given by: #' -#' \ifelse{html}{\out{   pS(i,t) = S0 / ( 1 + eS (N(i,t) / K(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-α_S (N(i,t)/K(i,t) - β_S) ] ) } } +#' \ifelse{html}{\out{ pS(i,t) = S0 / ( 1 + eS (N(i,t) / K(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-\alpha_S (N(i,t)/K(i,t) - \beta_S) ] ) } } #' #' In the case of stage-structured models the above equation is modified to: #' -#' \ifelse{html}{\out{   pS(i,t) = S0 / ( 1 + eS (b(i,t) * N(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-α_S (b(i,t) N(i,t) - β_S) ] ) } } +#' \ifelse{html}{\out{ pS(i,t) = S0 / ( 1 + eS (b(i,t) * N(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-\alpha_S (b(i,t) N(i,t) - \beta_S) ] ) } } #' #' In the first case, \eqn{K(i,t)} is the carrying capacity of the cell/patch \eqn{i} at time \eqn{t} given by \code{K_or_DensDep}. #' In the latter case, \eqn{b(i,t)} represents the strength of density dependence that is given by the inverse of \code{K_or_DensDep}.\cr #' Further, \ifelse{html}{\out{S0}}{\eqn{S_0}} is the maximum settlement probability, #' \eqn{N(i,t)} is the number of individuals in the cell/patch \eqn{i} at time \eqn{t}, -#' \ifelse{html}{\out{βS}}{\eqn{β_S}} is the inflection point of the function and -#' \ifelse{html}{\out{αS}}{\eqn{α_S}} is the slope at the inflection point.\cr +#' \ifelse{html}{\out{βS}}{\eqn{\beta_S}} is the inflection point of the function and +#' \ifelse{html}{\out{αS}}{\eqn{\alpha_S}} is the slope at the inflection point.\cr #' #' Inter-individual variability \code{IndVar=TRUE} and thus evolution is implemented only for the three traits determining density-dependent settlement #' (\code{DensDep=TRUE}), and if so, it may not be stage-dependent (\code{StageDep=FALSE}). @@ -1714,7 +1714,7 @@ setMethod("show", "CorrRW", function(object){ #' used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. #' The format of the matrix is defined as follows: The number of columns depend on the options \code{DensDep} and \code{IndVar}. If \code{DensDep=FALSE}, the #' density-independent probability \ifelse{html}{\out{pS}}{\eqn{p_S}} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{S0}}{\eqn{S_0}}, -#' \ifelse{html}{\out{αS}}{\eqn{α_S}} and \ifelse{html}{\out{βS}}{\eqn{β_S}} (cf. equation above) must be specified. +#' \ifelse{html}{\out{αS}}{\eqn{\alpha_S}} and \ifelse{html}{\out{βS}}{\eqn{\beta_S}} (cf. equation above) must be specified. #' Additionally, if \code{IndVar=FALSE}, these traits are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective initial mean and #' standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. Additionally, the \code{TraitScaleFactor} of #' these traits have to be set. @@ -1729,21 +1729,21 @@ setMethod("show", "CorrRW", function(object){ #' F \tab F \tab T \tab F \tab stage \cr #' F \tab F \tab F \tab T \tab sex \cr #' F \tab F \tab T \tab T \tab stage, sex \cr -#' T \tab F \tab F \tab F \tab \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, \ifelse{html}{\out{βS}}{\eqn{β_S}} \cr -#' \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr -#' T \tab F \tab T \tab T \tab stage, sex, \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, \ifelse{html}{\out{βS}}{\eqn{β_S}} \cr -#' T \tab T \tab F \tab F \tab mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{β_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{β_S})} \cr -#' T \tab T \tab F \tab T \tab sex, mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{β_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{β_S})} +#' T \tab F \tab F \tab F \tab \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, \ifelse{html}{\out{βS}}{\eqn{\beta_S}} \cr +#' \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr +#' T \tab F \tab T \tab T \tab stage, sex, \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, \ifelse{html}{\out{βS}}{\eqn{\beta_S}} \cr +#' T \tab T \tab F \tab F \tab mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})} \cr +#' T \tab T \tab F \tab T \tab sex, mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})} #' } #' #' The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly one row for each stage/sex combination. #' For example, in the case of density-, stage- and sex-dependent settlement with no individual variability: -#' \tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1.0 \tab \out{ } 0.2 \tab \out{ } 4.0 \cr -#' \out{ } 0 \tab \out{ } 1 \tab \out{ } 1.0 \tab \out{ } 0.1 \tab \out{ } 6.0 \cr -#' \out{ } 1 \tab \out{ } 0 \tab \out{ } 0.7 \tab \out{ } 0.5 \tab \out{ } 2.0 \cr -#' \out{ } 1 \tab \out{ } 1 \tab \out{ } 0.5 \tab \out{ } 0.5 \tab \out{ } 2.0 \cr -#' \out{ } 2 \tab \out{ } 0 \tab \out{ } 0.05 \tab \out{ } 1.0 \tab \out{ } 1.0 \cr -#' \out{ } 2 \tab \out{ } 1 \tab \out{ } 0.05 \tab \out{ } 1.0 \tab \out{ } 1.0 +#' \tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1.0 \tab \out{} 0.2 \tab \out{} 4.0 \cr +#' \out{} 0 \tab \out{} 1 \tab \out{} 1.0 \tab \out{} 0.1 \tab \out{} 6.0 \cr +#' \out{} 1 \tab \out{} 0 \tab \out{} 0.7 \tab \out{} 0.5 \tab \out{} 2.0 \cr +#' \out{} 1 \tab \out{} 1 \tab \out{} 0.5 \tab \out{} 0.5 \tab \out{} 2.0 \cr +#' \out{} 2 \tab \out{} 0 \tab \out{} 0.05 \tab \out{} 1.0 \tab \out{} 1.0 \cr +#' \out{} 2 \tab \out{} 1 \tab \out{} 0.05 \tab \out{} 1.0 \tab \out{} 1.0 #' } #' #' To avoid having individuals moving perpetually because they cannot find suitable conditions to settle, the model requires a maximum number @@ -1772,7 +1772,7 @@ setMethod("show", "CorrRW", function(object){ #' @author Anne-Kathleen Malchow #' @name Settlement #' @export Settlement -Settlement <- setClass("SettlementParams", slots = c(StageDep = "logical", +Settlement <- methods::setClass("SettlementParams", slots = c(StageDep = "logical", SexDep = "logical", Settle = "matrix_OR_numeric", # Settlement conditions for all sexes/stages. Settlement rule if the arrival cell/patch is unsuitable: 0 = die, 1 = wait, 2 = randomly choose a suitable cell/patch or die, 3 = randomly choose a suitable cell/patch or wait FindMate = "logical", @@ -1846,10 +1846,10 @@ setValidity("SettlementParams", function(object) { } else { if (object@TraitScaleFactor[1] <= 0.0 || object@TraitScaleFactor[1] > 1.0 ) { - msg <- c(msg, "TraitScaleFactor μ(S_0) must be in the half-open interval (0,1] !") + msg <- c(msg, "TraitScaleFactor mu(S_0) must be in the half-open interval (0,1] !") } if (any(object@TraitScaleFactor[2:3] <= 0.0 )) { - msg <- c(msg, "TraitScaleFactor μ(α_s) and μ(β_s) must be strictly positive !") + msg <- c(msg, "TraitScaleFactor mu(\alpha_s) and mu(\beta_s) must be strictly positive !") } } } @@ -1859,7 +1859,7 @@ setValidity("SettlementParams", function(object) { } else { if (object@TraitScaleFactor <= 0 || object@TraitScaleFactor > 1 ) { - msg <- c(msg, "TraitScaleFactor μ(S_0) must be in the half-open interval (0,1] !") + msg <- c(msg, "TraitScaleFactor mu(S_0) must be in the half-open interval (0,1] !") } } } @@ -1915,9 +1915,9 @@ setValidity("SettlementParams", function(object) { setMethod("initialize", "SettlementParams", function(.Object,...) { this_func = "Settlement(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (!is.null(args$Settle)) { if (class(args$Settle)[1]=="numeric" && length(args$Settle)==1) { @@ -2000,9 +2000,9 @@ setMethod("plotProbs", "SettlementParams", function(x, stage = NULL, sex = NULL, res[,6] <- densdep(xvals, A0 = sett[line,ind_D0]+sett[line,ind_D0+1], alpha = sett[line,ind_D0+2]-sett[line,ind_D0+3], beta = sett[line,ind_D0+4]+sett[line,ind_D0+5]) res[,7] <- densdep(xvals, A0 = sett[line,ind_D0]+sett[line,ind_D0+1], alpha = sett[line,ind_D0+2]+sett[line,ind_D0+3], beta = sett[line,ind_D0+4]-sett[line,ind_D0+5]) res[,8] <- densdep(xvals, A0 = sett[line,ind_D0]+sett[line,ind_D0+1], alpha = sett[line,ind_D0+2]+sett[line,ind_D0+3], beta = sett[line,ind_D0+4]+sett[line,ind_D0+5]) - polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') + graphics::polygon(c(xvals,rev(xvals)), c(apply(res, 1, min), rev(apply(res, 1, max))), border=NA, col='grey80') } - lines(xvals, densdep(xvals, A0 = sett[line,ind_D0], alpha = sett[line,ind_D0+IV], beta = sett[line,ind_D0+2*IV]), type = "l", lty = 1, col = line) + graphics::lines(xvals, densdep(xvals, A0 = sett[line,ind_D0], alpha = sett[line,ind_D0+IV], beta = sett[line,ind_D0+2*IV]), type = "l", lty = 1, col = line) if (x@StageDep) { if (x@SexDep) {leg.txt <- c(leg.txt, paste0("Stage ",sett[line,1], ifelse(sett[line,2]," male"," female")))} else {leg.txt <- c(leg.txt, paste0("Stage ",sett[line,1]))} @@ -2012,7 +2012,7 @@ setMethod("plotProbs", "SettlementParams", function(x, stage = NULL, sex = NULL, } } if (length(leg.txt)>0) { - legend("topright", leg.txt, col = 1:nrow(sett), lwd = 1.5) + graphics::legend("topright", leg.txt, col = 1:nrow(sett), lwd = 1.5) } } else{ print("Plotting is only implemented for density-dependent settlement (in a movement process).\n") } @@ -2074,7 +2074,7 @@ setMethod("plotProbs", "SettlementParams", function(x, stage = NULL, sex = NULL, #' @author Anne-Kathleen Malchow #' @name Dispersal #' @export Dispersal -Dispersal <- setClass("DispersalParams", slots = c(Emigration = "EmigrationParams", +Dispersal <- methods::setClass("DispersalParams", slots = c(Emigration = "EmigrationParams", Transfer = "TransferParams", Settlement = "SettlementParams") , prototype = list(Emigration = Emigration(), @@ -2085,14 +2085,14 @@ Dispersal <- setClass("DispersalParams", slots = c(Emigration = "EmigrationParam setValidity("DispersalParams", function(object) { msg <- NULL - validObject(object@Emigration) + methods::validObject(object@Emigration) if (object@Emigration@UseFullKern) { if (!class(object@Transfer)[1] == "DispersalKernel") { msg <- c(msg, "Dispersal(): The emigration option \"UseFullKern\" can only be used if a dispersal kernel is used as transfer method!") } } - validObject(object@Transfer) - validObject(object@Settlement) + methods::validObject(object@Transfer) + methods::validObject(object@Settlement) if (class(object@Transfer)[1] == "DispersalKernel") { if (object@Settlement@DensDep) { msg <- c(msg, "Dispersal(): Settlement can only be density-dependent (DensDep = TRUE) if a movement process is used as transfer method!") @@ -2107,9 +2107,9 @@ setValidity("DispersalParams", function(object) { setMethod("initialize", "DispersalParams", function(.Object,...) { this_func = "Dispersal(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } .Object} ) diff --git a/RangeShiftR/R/class_GeneticsParams.R b/RangeShiftR/R/class_GeneticsParams.R index de519f4..9fa855a 100644 --- a/RangeShiftR/R/class_GeneticsParams.R +++ b/RangeShiftR/R/class_GeneticsParams.R @@ -190,7 +190,7 @@ #' @author Anne-Kathleen Malchow #' @name Genetics #' @export Genetics -Genetics <- setClass("GeneticsParams", slots = c(Architecture = "integer_OR_numeric", +Genetics <- methods::setClass("GeneticsParams", slots = c(Architecture = "integer_OR_numeric", NLoci = "integer_OR_numeric", ArchFile = "character", ProbMutn = "numeric", @@ -268,7 +268,7 @@ setValidity('GeneticsParams', function(object){ setMethod('initialize', 'GeneticsParams', function(.Object, ...) { this_func = "Genetics(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if(.Object@Architecture == 0) { if (!is.null(args$ArchFile)) { warning(this_func, "ArchFile", warn_msg_ignored, "since Architecture = 0 (one chromosome per trait).", call. = FALSE) diff --git a/RangeShiftR/R/class_InitialisationParams.R b/RangeShiftR/R/class_InitialisationParams.R index 6fccbf7..bf60612 100644 --- a/RangeShiftR/R/class_InitialisationParams.R +++ b/RangeShiftR/R/class_InitialisationParams.R @@ -157,7 +157,7 @@ #' @author Anne-Kathleen Malchow #' @name Initialise #' @export Initialise -Initialise <- setClass("InitialisationParams", slots = c(InitType = "integer_OR_numeric", +Initialise <- methods::setClass("InitialisationParams", slots = c(InitType = "integer_OR_numeric", FreeType = "integer_OR_numeric", SpType = "integer_OR_numeric", NrCells = "integer_OR_numeric", @@ -415,7 +415,7 @@ setValidity('InitialisationParams', function(object){ setMethod('initialize', 'InitialisationParams', function(.Object, ...) { this_func = "Initialise(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if (.Object@InitType != 0) { .Object@FreeType = -9L if (!is.null(args$FreeType)) { diff --git a/RangeShiftR/R/class_LandParams.R b/RangeShiftR/R/class_LandParams.R index 1c73d10..030cb0c 100644 --- a/RangeShiftR/R/class_LandParams.R +++ b/RangeShiftR/R/class_LandParams.R @@ -26,7 +26,7 @@ # from RS 'Land' file # can take one of two forms: 'ArtificialLandscape' or 'ImportedLandscape' -LandParams <- setClass("LandParams", slots = c(LandNum = "integer_OR_numeric") +LandParams <- methods::setClass("LandParams", slots = c(LandNum = "integer_OR_numeric") , prototype = list(LandNum = 1L) ) # landscape number must be unique @@ -44,7 +44,7 @@ setValidity("LandParams", function(object) { if (is.null(msg)) TRUE else msg} ) setMethod("initialize", "LandParams", function(.Object, ...) { - .Object <- callNextMethod() + .Object <- methods::callNextMethod() .Object} ) @@ -100,7 +100,8 @@ setMethod("initialize", "LandParams", function(.Object, ...) { #' @author Anne-Kathleen Malchow #' @name ArtificialLandscape #' @export ArtificialLandscape -ArtificialLandscape <- setClass("ArtificialLandscape", slots = c(propSuit = "numeric", +#' @importFrom methods new +ArtificialLandscape <- methods::setClass("ArtificialLandscape", slots = c(propSuit = "numeric", K_or_DensDep = "integer_OR_numeric", Resolution = "integer_OR_numeric", dimX = "integer_OR_numeric", @@ -122,7 +123,7 @@ ArtificialLandscape <- setClass("ArtificialLandscape", slots = c(propSuit = "num #maxPct, , contains = "LandParams") -setValidity("ArtificialLandscape", function(object) { +methods::setValidity("ArtificialLandscape", function(object) { msg <- NULL if (anyNA(object@propSuit) || length(object@propSuit)!=1) { msg <- c(msg, "Proportion of suitable habitat must be set and of length 1!") @@ -233,12 +234,12 @@ setValidity("ArtificialLandscape", function(object) { } if (is.null(msg)) TRUE else msg} ) -setMethod("initialize", "ArtificialLandscape", function(.Object,...) { +methods::setMethod("initialize", "ArtificialLandscape", function(.Object,...) { this_func = "ArtificialLandscape(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (!.Object@fractal) { .Object@hurst = -9L @@ -258,7 +259,7 @@ setMethod("initialize", "ArtificialLandscape", function(.Object,...) { } .Object} ) -setMethod("show", "ArtificialLandscape", function(object){ +methods::setMethod("show", "ArtificialLandscape", function(object){ cat(" Artificial landscape: ") #cat(" Artificial landscape #", object@LandNum, ": ") if(object@fractal) { @@ -531,9 +532,9 @@ setValidity("ImportedLandscape", function(object) { setMethod("initialize", "ImportedLandscape", function(.Object, ...) { this_func = "ImportedLandscape(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if (.Object@HabPercent) { .Object@Nhabitats = 1L diff --git a/RangeShiftR/R/class_RSparams.R b/RangeShiftR/R/class_RSparams.R index b417103..1df83e6 100644 --- a/RangeShiftR/R/class_RSparams.R +++ b/RangeShiftR/R/class_RSparams.R @@ -30,7 +30,7 @@ #' @include class_DispersalParams.R #' @include class_GeneticsParams.R #' @include class_InitialisationParams.R -RSparams <- setClass("RSparams", slots = c(control = "ControlParams", +RSparams <- methods::setClass("RSparams", slots = c(control = "ControlParams", simul = "SimulationParams", land = "LandParams", demog = "DemogParams", @@ -41,9 +41,9 @@ RSparams <- setClass("RSparams", slots = c(control = "ControlParams", setValidity("RSparams", function(object) { msg <- NULL #CONTROL - validObject(object@control) + methods::validObject(object@control) #SIMULATION - validObject(object@simul) + methods::validObject(object@simul) if (object@control@patchmodel) { if (object@simul@Gradient) { msg <- c(msg, "Environmental gradients are not implemented for patch-based models!") @@ -82,7 +82,7 @@ setValidity("RSparams", function(object) { } } #LAND - validObject(object@land) + methods::validObject(object@land) if (any(object@control@landtype==c(0,2))){ if (any(object@land@DynamicLandYears>object@simul@Years)) { warning("ImportedLandscape(): Dynamic landscape contains years that exceed the simulated years, so that some land changes will not apply.", call. = FALSE) @@ -99,9 +99,9 @@ setValidity("RSparams", function(object) { } } #DEMOGRAPHY - validObject(object@demog) + methods::validObject(object@demog) #DISPERSAL - validObject(object@dispersal) + methods::validObject(object@dispersal) ## Emigration: check dimensions and values of EmigProb and EmigStage: # check StageDep and SexDep dim_ok = TRUE @@ -211,19 +211,19 @@ setValidity("RSparams", function(object) { } else { if(any(object@dispersal@Emigration@EmigProb[,(offset+2)] > object@dispersal@Emigration@TraitScaleFactor[1])) { - msg <- c(msg, paste0("Column ", (offset+2), " of emigration traits matrix (EmigProb) must contain sd(D0), with values less than or equal to TraitScaleFactor μ(D0)!")) + msg <- c(msg, paste0("Column ", (offset+2), " of emigration traits matrix (EmigProb) must contain sd(D0), with values less than or equal to TraitScaleFactor mu(D0)!")) } } if (object@dispersal@Emigration@DensDep) { if(any(object@dispersal@Emigration@EmigProb[,c((offset+4),(offset+6))]<=0 )){ - msg <- c(msg, paste0("Columns ", (offset+4), " and ", (offset+6), " of emigration traits matrix (EmigProb) must contain sd(α) and sd(β), with strictly positive values!")) + msg <- c(msg, paste0("Columns ", (offset+4), " and ", (offset+6), " of emigration traits matrix (EmigProb) must contain sd(alpha) and sd(beta), with strictly positive values!")) } else { if(any(object@dispersal@Emigration@EmigProb[,(offset+4)] > object@dispersal@Emigration@TraitScaleFactor[2])) { - msg <- c(msg, paste0("Column ", (offset+4), " of emigration traits matrix (EmigProb) must contain sd(α), with values less than or equal to TraitScaleFactor μ(α)!")) + msg <- c(msg, paste0("Column ", (offset+4), " of emigration traits matrix (EmigProb) must contain sd(alpha), with values less than or equal to TraitScaleFactor mu(alpha)!")) } if(any(object@dispersal@Emigration@EmigProb[,(offset+6)] > object@dispersal@Emigration@TraitScaleFactor[3])) { - msg <- c(msg, paste0("Column ", (offset+6), " of emigration traits matrix (EmigProb) must contain sd(β), with values less than or equal to TraitScaleFactor μ(β)!")) + msg <- c(msg, paste0("Column ", (offset+6), " of emigration traits matrix (EmigProb) must contain sd(beta), with values less than or equal to TraitScaleFactor mu(beta)!")) } } } @@ -348,25 +348,25 @@ setValidity("RSparams", function(object) { if (object@dispersal@Transfer@IndVar) { if (object@dispersal@Transfer@DoubleKernel) { if(any(object@dispersal@Transfer@Distances[,(offset+1)]= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) + msg <- c(msg, paste0("Column ", (offset+1), " of dispersal kernel traits (Distances) matrix must contain the mean of the mean distance of Kernel 1, mean(delta1), with values >= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) } if(any(object@dispersal@Transfer@Distances[,(offset+2)]<=0.0)){ - msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance of Kernel 1, sd(δ1), with strictly positive values!")) + msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance of Kernel 1, sd(delta1), with strictly positive values!")) } else { if(any(object@dispersal@Transfer@Distances[,(offset+2)] > object@dispersal@Transfer@TraitScaleFactor[1])) { - msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain sd(δ1), with values less than or equal to TraitScaleFactor μ(δ1)!")) + msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain sd(delta1), with values less than or equal to TraitScaleFactor mu(delta1)!")) } } if(any(object@dispersal@Transfer@Distances[,(offset+3)]= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) + msg <- c(msg, paste0("Column ", (offset+3), " of dispersal kernel traits (Distances) matrix must contain the mean of the mean distance of Kernel 2, mean(delta2), with values >= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) } if(any(object@dispersal@Transfer@Distances[,(offset+4)]<=0.0)){ - msg <- c(msg, paste0("Column ", (offset+4), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance of Kernel 2, sd(δ2), with strictly positive values!")) + msg <- c(msg, paste0("Column ", (offset+4), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance of Kernel 2, sd(delta2), with strictly positive values!")) } else { if(any(object@dispersal@Transfer@Distances[,(offset+4)] > object@dispersal@Transfer@TraitScaleFactor[2])) { - msg <- c(msg, paste0("Column ", (offset+4), " of dispersal kernel traits (Distances) matrix must contain sd(δ2), with values less than or equal to TraitScaleFactor μ(δ2)!")) + msg <- c(msg, paste0("Column ", (offset+4), " of dispersal kernel traits (Distances) matrix must contain sd(delta2), with values less than or equal to TraitScaleFactor mu(delta2)!")) } } if(any(object@dispersal@Transfer@Distances[,(offset+5)]<=0.0 | object@dispersal@Transfer@Distances[,(offset+5)]>=1.0)){ @@ -377,20 +377,20 @@ setValidity("RSparams", function(object) { } else { if(any(object@dispersal@Transfer@Distances[,(offset+6)] > object@dispersal@Transfer@TraitScaleFactor[3])) { - msg <- c(msg, paste0("Column ", (offset+6), " of dispersal kernel traits (Distances) matrix must contain sd(p), with values less than or equal to TraitScaleFactor μ(p)!")) + msg <- c(msg, paste0("Column ", (offset+6), " of dispersal kernel traits (Distances) matrix must contain sd(p), with values less than or equal to TraitScaleFactor mu(p)!")) } } } else { # !DoubleKernel if(any(object@dispersal@Transfer@Distances[,(offset+1)]= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) + msg <- c(msg, paste0("Column ", (offset+1), " of dispersal kernel traits (Distances) matrix must contain the mean of the mean distance, mean(delta), with values >= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) } if(any(object@dispersal@Transfer@Distances[,(offset+2)]<=0.0)){ - msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance, sd(δ), with strictly positive values!")) + msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain the std. dev. of the mean distance, sd(delta), with strictly positive values!")) } else { if(any(object@dispersal@Transfer@Distances[,(offset+2)] > object@dispersal@Transfer@TraitScaleFactor[1])) { - msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain sd(δ), with values less than or equal to TraitScaleFactor μ(δ)!")) + msg <- c(msg, paste0("Column ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain sd(delta), with values less than or equal to TraitScaleFactor mu(delta)!")) } } } @@ -398,7 +398,7 @@ setValidity("RSparams", function(object) { else { # !IndVar if (object@dispersal@Transfer@DoubleKernel) { if(any(object@dispersal@Transfer@Distances[,(offset+1):(offset+2)]= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) + msg <- c(msg, paste0("Columns ", (offset+1), " and ", (offset+2), " of dispersal kernel traits (Distances) matrix must contain the two mean distance delta1 and delta2, with values >= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) } if(any(object@dispersal@Transfer@Distances[,(offset+3)]<=0 | object@dispersal@Transfer@Distances[,(offset+3)]>=1)) { msg <- c(msg, paste0("Column ", (offset+3), " of dispersal kernel traits (Distances) matrix must contain the probability p of using kernel 1, with values in the open interval (0,1) !")) @@ -406,7 +406,7 @@ setValidity("RSparams", function(object) { } else{ if(any(object@dispersal@Transfer@Distances[,(offset+1)]= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) + msg <- c(msg, paste0("Column ", (offset+1), " of dispersal kernel traits (Distances) matrix must contain the mean distance delta, with values >= ", (resol), " (=landscape resolution (unless UseFullKernel=TRUE)) !")) } } } @@ -617,18 +617,18 @@ setValidity("RSparams", function(object) { } else { if(any(object@dispersal@Settlement@Settle[,(offset+2)] > object@dispersal@Settlement@TraitScaleFactor[1])) { - msg <- c(msg, paste0("Column ", (offset+2), " of settlement traits matrix (Settle) must contain sd(S0), with values less than or equal to TraitScaleFactor μ(S0)!")) + msg <- c(msg, paste0("Column ", (offset+2), " of settlement traits matrix (Settle) must contain sd(S0), with values less than or equal to TraitScaleFactor mu(S0)!")) } } if(any(object@dispersal@Settlement@Settle[,c((offset+4),(offset+6))]<=0 )){ - msg <- c(msg, paste0("Columns ", (offset+4), " and ", (offset+6), " of settlement traits matrix (Settle) must contain sd(α_s) and sd(β_s), with strictly positive values!")) + msg <- c(msg, paste0("Columns ", (offset+4), " and ", (offset+6), " of settlement traits matrix (Settle) must contain sd(alpha_s) and sd(beta_s), with strictly positive values!")) } else { if(any(object@dispersal@Settlement@Settle[,(offset+4)] > object@dispersal@Settlement@TraitScaleFactor[2])) { - msg <- c(msg, paste0("Column ", (offset+4), " of settlement traits matrix (Settle) must contain sd(α_s), with values less than or equal to TraitScaleFactor μ(α_s)!")) + msg <- c(msg, paste0("Column ", (offset+4), " of settlement traits matrix (Settle) must contain sd(alpha_s), with values less than or equal to TraitScaleFactor mu(alpha_s)!")) } if(any(object@dispersal@Settlement@Settle[,(offset+6)] > object@dispersal@Settlement@TraitScaleFactor[3])) { - msg <- c(msg, paste0("Column ", (offset+6), " of settlement traits matrix (Settle) must contain sd(β_s), with values less than or equal to TraitScaleFactor μ(β_s)!")) + msg <- c(msg, paste0("Column ", (offset+6), " of settlement traits matrix (Settle) must contain sd(beta_s), with values less than or equal to TraitScaleFactor mu(beta_s)!")) } } } @@ -675,13 +675,13 @@ setValidity("RSparams", function(object) { } #GENETICS - validObject(object@gene) + methods::validObject(object@gene) if(any(object@dispersal@Emigration@IndVar,object@dispersal@Transfer@IndVar,object@dispersal@Settlement@IndVar)) anyIndVar <- TRUE else anyIndVar <- FALSE # if( ...(object@gene) & !anyIndVar) # TODO: check if genetics module is set but no variable traits -> give warning in this case #INITIALISATION - validObject(object@init) + methods::validObject(object@init) if (object@control@landtype == 9) { # artificial land if (object@init@InitType) { msg <- c(msg, 'Initialise(): InitType must be set to 0 (Free initialisation) for an artificial landscape!') diff --git a/RangeShiftR/R/class_SimulationParams.R b/RangeShiftR/R/class_SimulationParams.R index 06c73a6..03023bb 100644 --- a/RangeShiftR/R/class_SimulationParams.R +++ b/RangeShiftR/R/class_SimulationParams.R @@ -149,7 +149,7 @@ #' The local heterogeneity is determined by a random number drawn from a uniform distribution between \eqn{-1} and \eqn{1} for each cell #' and \code{f}, the local scaling factor that determines the magnitude of this stochastic local variation relative to the extremal value. #' -#' The gradient in fecundity φ applies to the fecundity of each stage. Negative local values in \eqn{z(x,y)} are set to \eqn{0}. +#' The gradient in fecundity \eqn{\phi} applies to the fecundity of each stage. Negative local values in \eqn{z(x,y)} are set to \eqn{0}. #' #' It is also possible to simulate the shifting of the gradient by setting the option \code{Shifting}. Here the position \eqn{y} of the species’ #' optimum is shifted northwards (increasing \eqn{y}) at a given rate \code{ShiftRate} (in units of rows per year), @@ -166,18 +166,18 @@ #' \emph{Environmental Stochasticity}\cr #' It is possible to model environmental stochasticity via the option \code{EnvStoch} acting at a global or local scale #' and can be applied to \code{K_or_DensDep}, the demographic density dependence (\code{EnvStoch=1}), or to growth rate / fecundity (\code{EnvStoch=0}). -#' It is implemented using a first order autoregressive process to generate time series of the noise value \eqn{ε} +#' It is implemented using a first order autoregressive process to generate time series of the noise value \eqn{\epsilon} #' \insertCite{ruokolainen2009}{RangeShiftR}: #' -#' \deqn{ε(t+1) = κ ε(t) + \omega(t) \sqrt(1-\kappa^2)} +#' \deqn{\epsilon(t+1) = \kappa \epsilon(t) + \omega(t) \sqrt(1-\kappa^2)} #' -#' where κ is the autocorrelation coefficient (\code{ac}) and ω is a random normal variable drawn from \eqn{N(0,σ)}. -#' Changing σ (\code{std}) changes the magnitude of the fluctuations. The spatial scale of the variation can either be global (a single time series +#' where \eqn{\kappa} is the autocorrelation coefficient (\code{ac}) and \eqn{\omega} is a random normal variable drawn from \eqn{N(0,\sigma)}. +#' Changing \eqn{\sigma} (\code{std}) changes the magnitude of the fluctuations. The spatial scale of the variation can either be global (a single time series #' for the entire landscape) or local (each cell fluctuates independently), and is always applied on a yearly basis. #' Different degrees of spatial autocorrelation are not implemented in the current version. #' #' The noise affects the species' selected parameter \eqn{Z} as follows: -#' \deqn{Z(x,y,t) = Z(x,y,0) + Z ε(t)} +#' \deqn{Z(x,y,t) = Z(x,y,0) + Z \epsilon(t)} #' where \eqn{x} and \eqn{y} are the cell coordinates and \eqn{Z} is the original parameter value in absence of stochasticity and gradients. #' In the presence of an environmental gradient, \eqn{Z(x,y,0)} is the gradient value at the cell location, otherwise its equal to \eqn{Z}. #' The resulting values \eqn{Z(x,y,t)} are limited to the maximum and minimum values \code{minR,maxR} or \code{minK,maxK}, respectively. @@ -187,7 +187,7 @@ #' All the output files will be named with a standard name reporting the simulation ID number and #' the type of output. The file name will start with the batch number, and also indicate the number #' of the landscape to which the output refers. Additionally, for each simulation all the set parameters -#' will be automatically written to a text file named \"Sim0_Parameters.txt\" in the case of simulation\eqn{#=0}. +#' will be automatically written to a text file named \"Sim0_Parameters.txt\" in the case of simulation\eqn{=0}. #' #' - \emph{Species range} (\code{Sim0_Range.txt}) \cr #' contains the following general information regarding the species’ range:\cr @@ -308,7 +308,7 @@ #' \insertAllCited{} #' @name Simulation #' @export Simulation -Simulation <- setClass("SimulationParams", slots = c(Simulation = "integer_OR_numeric", +Simulation <- methods::setClass("SimulationParams", slots = c(Simulation = "integer_OR_numeric", Replicates = "integer_OR_numeric", Years = "integer_OR_numeric", Absorbing = "logical", @@ -852,9 +852,9 @@ setValidity('SimulationParams', function(object){ setMethod("initialize", "SimulationParams", function(.Object, ...) { this_func = "Simulation(): " args <- list(...) - .Object <- callNextMethod() + .Object <- methods::callNextMethod() if ( length(args) == 0 ) { - validObject(.Object) + methods::validObject(.Object) } if(.Object@Gradient == 0){ .Object@GradSteep = -9L diff --git a/RangeShiftR/R/output_handling.R b/RangeShiftR/R/output_handling.R index fc42dfb..e87bffe 100644 --- a/RangeShiftR/R/output_handling.R +++ b/RangeShiftR/R/output_handling.R @@ -43,7 +43,7 @@ setGeneric("readRange", function(s,dirpath) standardGeneric("readRange") ) setMethod("readRange", c(s="RSparams", dirpath="character"), function(s,dirpath) { path <- paste0(dirpath, "Outputs/Batch", s@control@batchnum, "_Sim", s@simul@Simulation, "_Land", s@land@LandNum, "_Range.txt") if(file.exists(path)){ - return(read.table(path, h = T, sep = "\t")) + return(utils::read.table(path, h = T, sep = "\t")) }else { warning("The 'range' output file for this simulation does not exist.", call. = FALSE) } @@ -64,7 +64,7 @@ setGeneric("readPop", function(s,dirpath,...) standardGeneric("readPop") ) setMethod("readPop", c(s="RSparams", dirpath="character"), function(s,dirpath,center=TRUE) { path <- paste0(dirpath, "Outputs/Batch", s@control@batchnum, "_Sim", s@simul@Simulation, "_Land", s@land@LandNum, "_Pop.txt") if(file.exists(path)){ - pop_table <- read.table(path, h = T, sep = "\t") + pop_table <- utils::read.table(path, h = T, sep = "\t") if (sum(grepl('x',names(pop_table))) & center){ pop_table$x <- (pop_table$x+0.5)*s@land@Resolution pop_table$y <- (pop_table$y+0.5)*s@land@Resolution @@ -136,7 +136,7 @@ setMethod("ColonisationStats", "data.frame", function(x, y = NULL, years = numer digitsY <- ifelse(maxY < 1, 0, floor(log10(maxY)) + 1) x$PatchID <- (x$x*(10^digitsY)) + (x$y) #+ (maxY+1-x$y) } - + NInd <- NULL # not used, necessary to pass CRAN check x <- subset(x, NInd>0, select = c("Rep","PatchID","Year","NInd") ) reps <- sort(unique(x$Rep)) n=length(reps) @@ -285,13 +285,13 @@ setMethod("ColonisationStats", "data.frame", function(x, y = NULL, years = numer patch_outstack <- c(patch_outstack, patch_occ_prob) terra::values(patch_outstack[[j]])[value_ix] <- occ_prob[,j+2] } - crs(patch_outstack) <- NA + terra::crs(patch_outstack) <- NA #} else{ # raster::values(patch_occ_prob)[value_ix] <- occ_prob[,1] # patch_outstack <- patch_occ_prob #} terra::values(patch_col_time)[value_ix] <- ifelse(is.na(col_time_mean[]),-9,col_time_mean[]) - crs(patch_col_time) <- NA + terra::crs(patch_col_time) <- NA return(list(occ_prob=occ_prob, col_time=col_time, map_occ_prob=patch_outstack, map_col_time=patch_col_time)) @@ -305,6 +305,7 @@ setMethod("ColonisationStats", "data.frame", function(x, y = NULL, years = numer setMethod("ColonisationStats", "RSparams", function(x, y = getwd(), years = numeric(0), maps = FALSE) { res <- NULL + dirpath <- NULL # unused but required for R check if(class(x@land)=="ImportedLandscape" || class(maps)=="logical") { if(x@simul@OutIntPop>0){ if(!is.null(y) & class(y)=="character" ){ @@ -351,7 +352,7 @@ setMethod("ColonisationStats", "RSparams", function(x, y = getwd(), years = nume if ( class(patch_curr) == "try-error" ) warning("ColonisationStats(): Couldn't read patch raster file nr ", current , " for this simulation.", call. = FALSE) else patch_r <- c(patch_r , patch_curr) - if(class(pop_df) == "data.frame" & nlyr(patch_r)==(length(years)+1) ) res <- ColonisationStats(pop_df,patch_r,years) + if(class(pop_df) == "data.frame" & terra::nlyr(patch_r)==(length(years)+1) ) res <- ColonisationStats(pop_df,patch_r,years) } }else{ # for cell-based model, read only main habitat maps to use as raster template @@ -398,10 +399,10 @@ setGeneric("plotAbundance", function(s,...) standardGeneric("plotAbundance") ) setMethod("plotAbundance", "data.frame", function(s, sd = FALSE, replicates = TRUE, ylim=NULL, ...) { # Calculate means - rep_means <- aggregate(NInds~Year, data = s, FUN = "mean") + rep_means <- stats::aggregate(NInds~Year, data = s, FUN = "mean") # Calculate standard deviation if (sd) { - rep_sd <- aggregate(NInds~Year, data = s, FUN = "sd") + rep_sd <- stats::aggregate(NInds~Year, data = s, FUN = "sd") rep_sd[is.na(rep_sd)] <- 0 } # Set y-limits @@ -420,16 +421,16 @@ setMethod("plotAbundance", "data.frame", function(s, sd = FALSE, replicates = TR plot(NULL, type = "n", ylab = "Abundance", xlab = "Year", xlim=c(0, max(s$Year)), ylim=ylim, ...) # Plot standard deviation if (sd) { - polygon(c(rep_sd$Year,rev(rep_sd$Year)), c(rep_means$NInds+rep_sd$NInds, rev(pmax(0,rep_means$NInds-rep_sd$NInds))), border=NA, col='grey80') + graphics::polygon(c(rep_sd$Year,rev(rep_sd$Year)), c(rep_means$NInds+rep_sd$NInds, rev(pmax(0,rep_means$NInds-rep_sd$NInds))), border=NA, col='grey80') } # Plot replicates if (replicates) { for (i in 0:max(s$Rep)) { - lines(s$Year[s$Rep==i], s$NInds[s$Rep==i], type = "l", lwd = 0.5) + graphics::lines(s$Year[s$Rep==i], s$NInds[s$Rep==i], type = "l", lwd = 0.5) } } # Plot abundance - lines(rep_means$Year, rep_means$NInds, type = "l", lwd = 3, col = "red") + graphics::lines(rep_means$Year, rep_means$NInds, type = "l", lwd = 3, col = "red") }) setMethod("plotAbundance", "RSparams", function(s, dirpath, ...) { if (class(dirpath)=="character"){ @@ -458,10 +459,10 @@ setGeneric("plotOccupancy", function(s,...) standardGeneric("plotOccupancy") ) setMethod("plotOccupancy", "data.frame", function(s, sd = FALSE, replicates = TRUE, ylim=NULL, ...) { names(s)[grep('NOccup',names(s))] <- 'NOccup' # Calculate means - rep_means <- aggregate(NOccup~Year, data = s, FUN = "mean") + rep_means <- stats::aggregate(NOccup~Year, data = s, FUN = "mean") # Calculate standard deviation if (sd) { - rep_sd <- aggregate(NOccup~Year, data = s, FUN = "sd") + rep_sd <- stats::aggregate(NOccup~Year, data = s, FUN = "sd") rep_sd[is.na(rep_sd)] <- 0 } # Set y-limits @@ -480,16 +481,16 @@ setMethod("plotOccupancy", "data.frame", function(s, sd = FALSE, replicates = TR plot(NULL, type = "n", ylab = "Occupancy", xlab = "Year", xlim=c(0, max(s$Year)), ylim=ylim, ...) # Plot standard deviation if (sd) { - polygon(c(rep_sd$Year,rev(rep_sd$Year)), c(rep_means$NOccup+rep_sd$NOccup, rev(pmax(0,rep_means$NOccup-rep_sd$NOccup))), border=NA, col='grey80') + graphics::polygon(c(rep_sd$Year,rev(rep_sd$Year)), c(rep_means$NOccup+rep_sd$NOccup, rev(pmax(0,rep_means$NOccup-rep_sd$NOccup))), border=NA, col='grey80') } # plot replicates if (replicates) { for (i in 0:max(s$Rep)) { - lines(s$Year[s$Rep==i], s$NOccup[s$Rep==i], type = "l", lwd = 0.5) + graphics::lines(s$Year[s$Rep==i], s$NOccup[s$Rep==i], type = "l", lwd = 0.5) } } # Plot occupancy - lines(rep_means$Year, rep_means$NOccup, type = "l", lwd = 3, col = "blue") + graphics::lines(rep_means$Year, rep_means$NOccup, type = "l", lwd = 3, col = "blue") }) setMethod("plotOccupancy", "RSparams", function(s, dirpath, ...) { if (class(dirpath)=="character"){ @@ -527,6 +528,7 @@ setMethod("SMSpathLengths", c(s="RSparams", dirpath="character"), function(s,dir return(NULL) } + Year <- NULL # unused but required for R check maxLength = s@dispersal@Settlement@MaxSteps if(maxLength<1) maxLength = as.integer(log(.015)/log(1-s@dispersal@Transfer@StepMort)) + 1 year_blocks = s@land@DynamicLandYears @@ -537,7 +539,7 @@ setMethod("SMSpathLengths", c(s="RSparams", dirpath="character"), function(s,dir null_tb <- rep(0,maxLength) names(null_tb) <- sapply(1:maxLength, FUN=paste0) for(i in 0:(s@simul@Replicates-1)){ - steps <- try(read.table(paste0(dirpath, + steps <- try(utils::read.table(paste0(dirpath, "Outputs/Batch",s@control@batchnum, "_Sim",s@simul@Simulation, "_Land",s@land@LandNum, @@ -551,10 +553,10 @@ setMethod("SMSpathLengths", c(s="RSparams", dirpath="character"), function(s,dir steps_y <- sapply(seq(nr_maps), FUN = function(y){ tb <- null_tb lo <- year_blocks[y] - if (y==nr_maps) tb_n <- table(aggregate(Step~IndID, data=subset(steps, Year >= lo), FUN = max)$Step) + if (y==nr_maps) tb_n <- table(stats::aggregate(Step~IndID, data=subset(steps, Year >= lo), FUN = max)$Step) else { up <- year_blocks[y+1] - tb_n <- table(aggregate(Step~IndID, data=subset(steps, Year >= lo & Year < up), FUN = max)$Step) + tb_n <- table(stats::aggregate(Step~IndID, data=subset(steps, Year >= lo & Year < up), FUN = max)$Step) } ix <- names(tb) %in% names(tb_n) tb[ix] <- tb_n[1:sum(ix)] @@ -855,9 +857,9 @@ setMethod("getLocalisedEquilPop", "DemogParams", function(demog, DensDep_values, xlabs <- print(DensDep_values, digits = 2) # which stages to plot? if(is.null(stages_out)) stages_out = seq((!juv.stage),demog@StageStruct@Stages-1) - colors <- hcl.colors(length(stages_out), palette = "Harmonic") + colors <- grDevices::hcl.colors(length(stages_out), palette = "Harmonic") if(demog@ReproductionType <2){ - barplot(res[as.character(stages_out),], names.arg = xlabs, beside = F, col = colors, + graphics::barplot(res[as.character(stages_out),], names.arg = xlabs, beside = F, col = colors, main = "Localised equilibrium densities", xlab = "1/b", ylab = "Population density") } if(demog@ReproductionType==2){ @@ -868,13 +870,13 @@ setMethod("getLocalisedEquilPop", "DemogParams", function(demog, DensDep_values, fem <- seq.int(2,length(stages_out)*2,2) res_2 <- cbind(res_2[mal,1:length(DensDep_values)],res_2[fem,1:length(DensDep_values)]) res_2 <- cbind(res_2[,c(sapply(1:length(DensDep_values), function(i){c(0,1)*length(DensDep_values)+i}))]) - barplot(res_2, space=c(0.3,0.1), names.arg = c(rbind(xlabs,NA)), beside = F, col = rep(colors, 2), + graphics::barplot(res_2, space=c(0.3,0.1), names.arg = c(rbind(xlabs,NA)), beside = F, col = rep(colors, 2), main = "Localised equilibrium densities", xlab = "1/b", ylab = "Population density") - text(seq(0.5,length(DensDep_values)*2,2)*1.2, colSums(res_2[,seq(1,length(DensDep_values)*2,2)])*1.1, "m", cex=1, col="black") - text(seq(1.5,length(DensDep_values)*2,2)*1.2, colSums(res_2[,seq(2,length(DensDep_values)*2,2)])*1.1, "f", cex=1, col="black") + graphics::text(seq(0.5,length(DensDep_values)*2,2)*1.2, colSums(res_2[,seq(1,length(DensDep_values)*2,2)])*1.1, "m", cex=1, col="black") + graphics::text(seq(1.5,length(DensDep_values)*2,2)*1.2, colSums(res_2[,seq(2,length(DensDep_values)*2,2)])*1.1, "f", cex=1, col="black") } } - legend("topleft", legend = rev(sapply(stages_out, function(s){paste("Stage",s)})), col = rev(colors), pch = 16) + graphics::legend("topleft", legend = rev(sapply(stages_out, function(s){paste("Stage",s)})), col = rev(colors), pch = 16) } # return equilibrium population densities return(res) diff --git a/RangeShiftR/R/plotProbs.R b/RangeShiftR/R/plotProbs.R index bcd6b00..0c6bebe 100644 --- a/RangeShiftR/R/plotProbs.R +++ b/RangeShiftR/R/plotProbs.R @@ -49,21 +49,21 @@ #' If a mixed kernel was defined (i.e. \code{DoubleKernel=TRUE}), plot the resulting dispersal probability by... #' \itemize{ #' \item \code{combinekernels=FALSE} - ...plotting both kernels separately (default) -#' \item \code{combinekernels= TRUE} - ...combining both kernels, i.e. \ifelse{html}{ \out{p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1) } }{\deqn{ p(d; δ_1,δ_2) = p_I p(d;δ_1) + (1-p_I) p(d;δ_2)} } +#' \item \code{combinekernels= TRUE} - ...combining both kernels, i.e. \ifelse{html}{ \out{p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1) } }{\deqn{ p(d; \delta_1,\delta_2) = p_I p(d;\delta_1) + (1-p_I) p(d;\delta_2)} } #' } #' \item \code{\link[RangeShiftR]{StageStructure}}: plot fecundity as well as survival and development probabilities. #' #' Survival and development are calculated based on the transition matrix. Consider e.g. a 3 stage matrix with a transition matrix of #' -#' \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{φ_2}} \cr -#' \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{σ_1 (1 − γ_(1-2))}} \tab | \tab \eqn{0} \cr -#' \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{σ_1 γ_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{σ_2}} \cr} +#' \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{\phi_2}} \cr +#' \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{\sigma_1 (1 - \gamma_(1-2))}} \tab | \tab \eqn{0} \cr +#' \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{\sigma_1 \gamma_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{\sigma_2}} \cr} #' #' The survival probability is calculated as the sum of the probability to stay in the same stage and the probability to reach the next stage. -#' E.g. for stage 1: \ifelse{html}{\out{σ1 = sum( σ1 (1-γ1-2), σ1 γ1-2}}{\eqn{σ_1 = sum(σ_1 (1 − γ_(1-2)), σ_1 γ_(1-2))}} +#' E.g. for stage 1: \ifelse{html}{\out{σ1 = sum( σ1 (1-γ1-2), σ1 γ1-2}}{\eqn{\sigma_1 = sum(\sigma_1 (1 - \gamma_(1-2)), \sigma_1 \gamma_(1-2))}} #' #' The development probability of stage 1 to stage 2 is the ratio of the probability to reach stage 2 and the previously calculated survival probability. -#' E.g. for stage 1: \ifelse{html}{\out{γ1-2 = σ1 γ1-2 / σ1}}{\eqn{γ_(1-2) = σ_1 / (σ_1 γ_(1-2) )}} +#' E.g. for stage 1: \ifelse{html}{\out{γ1-2 = σ1 γ1-2 / σ1}}{\eqn{\gamma_(1-2) = \sigma_1 / (\sigma_1 \gamma_(1-2) )}} #' } #' @export setGeneric("plotProbs", function(x, ...) standardGeneric("plotProbs") ) diff --git a/RangeShiftR/man/CorrRW.Rd b/RangeShiftR/man/CorrRW.Rd index 4c057c8..869e739 100644 --- a/RangeShiftR/man/CorrRW.Rd +++ b/RangeShiftR/man/CorrRW.Rd @@ -14,7 +14,7 @@ CorrRW(StepLength = 1, Rho = 0.5, \item{StepLength}{Step length given in meters, defaults to \eqn{1}.\cr If \code{IndVar=TRUE}, expects a vector of length three specifying (Mean, SD, TraitScaleFactor) of \code{StepLength}.} -\item{Rho}{Correlation parameter \eqn{ρ}, defaults to \eqn{0.5}. Must be in the open interval \eqn{(0,1)}.\cr If \code{IndVar=TRUE}, +\item{Rho}{Correlation parameter \eqn{\rho}, defaults to \eqn{0.5}. Must be in the open interval \eqn{(0,1)}.\cr If \code{IndVar=TRUE}, expects a vector of length three specifying (Mean, SD, TraitScaleFactor) of \code{Rho}.} \item{IndVar}{Individual variability in CorrRW traits (i.e. \code{StepLength} and \code{Rho})? Defaults to \code{FALSE}.} diff --git a/RangeShiftR/man/Demography.Rd b/RangeShiftR/man/Demography.Rd index dcd69d7..c460c55 100644 --- a/RangeShiftR/man/Demography.Rd +++ b/RangeShiftR/man/Demography.Rd @@ -45,7 +45,7 @@ and for species for which it is considered crucial to model both sexes explicitl \emph{Asexual / only-female models:} (\code{ReproductionType=0})\cr Recruitment is determined by a stochastic, individual-based formulation of the \insertCite{smith1973;textual}{RangeShiftR} population model, where the number of offspring produced by a single individual in the cell/patch \eqn{i} at time \eqn{t}, is drawn from the following distribution:\cr -\ifelse{html}{\out{  Njuv(i,t) = Poisson( R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t))bc ) ) } }{\deqn{N_juv(i,t) = Poisson( R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } +\ifelse{html}{\out{Njuv(i,t) = Poisson( R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t))bc ) ) } }{\deqn{N_juv(i,t) = Poisson( R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } Here, \eqn{R(i,t)} is the maximum growth rate \code{Rmax} (obtained at very low density only) and \eqn{K(i,t)} is the carrying capacity at patch \eqn{i} and time \eqn{t}. @@ -61,7 +61,7 @@ In this type of models, individuals are explicitly characterized by their sex. T This is the simplest form of mate limitation. Each female individual is assumed to mate, as long as there is at least one male in the population. As for the asexual case, the Maynard Smith and Slatkin model is used to determine the expected number of offspring produced by each female. To maintain equivalence between the asexual and sexual versions, the expected value of the Poisson distribution is multiplied by \eqn{2} (Lindström & Kokko 1998):\cr -\ifelse{html}{\out{  Njuv(i,t) = Poisson( 2 R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t) )bc ) ) } }{\deqn{N_juv(i,t) = Poisson( 2 R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } +\ifelse{html}{\out{Njuv(i,t) = Poisson( 2 R(i,t) / (1+|R(i,t) - 1| * (N(i,t) / K(i,t) )bc ) ) } }{\deqn{N_juv(i,t) = Poisson( 2 R(i,t) / (1 + |R(i,t) - 1|*( N(i,t) / K(i,t) )^bc ) ) } } \emph{Complex mating system:} (\code{ReproductionType=2})\cr More complex and flexible mating system. Mating is explicitly modelled through a mating function diff --git a/RangeShiftR/man/DispersalKernel.Rd b/RangeShiftR/man/DispersalKernel.Rd index f7b7cd4..5f8ee72 100644 --- a/RangeShiftR/man/DispersalKernel.Rd +++ b/RangeShiftR/man/DispersalKernel.Rd @@ -59,10 +59,10 @@ valuable method for discerning between common short-distance and rare long-dista \emph{Negative exponential} \cr If the individual disperses, the distance and the movement direction are determined in continuous space. -The distance is drawn from a negative exponential distribution with a given mean \eqn{δ}, and the direction is selected randomly from a uniform -distribution between \eqn{0} and \eqn{2π} radians. +The distance is drawn from a negative exponential distribution with a given mean \eqn{\delta}, and the direction is selected randomly from a uniform +distribution between \eqn{0} and \eqn{2\pi} radians. -\ifelse{html}{\out{   p(d;δ) = δ-1 e- d / δ}}{\deqn{ p(d;δ) = 1/δ exp(-d/δ) } } +\ifelse{html}{\out{ p(d;δ) = δ-1 e- d / δ}}{\deqn{ p(d;\delta) = 1/\delta exp(-d/\delta) } } If the arrival point lies beyond the boundary of the landscape, distance and direction are re-drawn.\cr The individual is displaced from a random point (using continuous coordinates) inside the natal cell to the arrival cell where the model @@ -79,17 +79,17 @@ not they emigrate. \emph{Mixed kernel} \cr The distance an individual moves is sampled from a mixed kernel given by the combination of two negative exponentials -with different means \ifelse{html}{\out{δ1}}{\eqn{δ_1}} and \ifelse{html}{\out{δ2}}{\eqn{δ_2}}, +with different means \ifelse{html}{\out{δ1}}{\eqn{\delta_1}} and \ifelse{html}{\out{δ2}}{\eqn{\delta_2}}, occurring with probability \ifelse{html}{\out{pI}}{\eqn{p_I}} and \eqn{1-}\ifelse{html}{\out{pI}}{\eqn{p_I}} respectively \insertCite{hovestadt2011all}{RangeShiftR}. Otherwise, the conditions for the single kernel apply. -\ifelse{html}{\out{   p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1)}}{\deqn{ p(d; δ_1,δ_2) = p_I p(d;δ_1) + (1-p_I) p(d;δ_2)}} +\ifelse{html}{\out{ p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1)}}{\deqn{ p(d; \delta_1,\delta_2) = p_I p(d;\delta_1) + (1-p_I) p(d;\delta_2)}} For both types of kernel, inter-individual variability of the kernel traits is possible (set \code{IndVar=TRUE}). Individuals will -carry either one trait for \eqn{δ} or three traits for \ifelse{html}{\out{δ1}}{\eqn{δ_1}}, \ifelse{html}{\out{δ2}}{\eqn{δ_2}} and +carry either one trait for \eqn{\delta} or three traits for \ifelse{html}{\out{δ1}}{\eqn{\delta_1}}, \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} and \ifelse{html}{\out{pI}}{\eqn{p_I}}, which they inherit from their parents.\cr -Dispersal kernels can also be sex-dependent (set \code{SexDep=TRUE}). In the case of inter-individual variability, the number of traits is doubled to two trait (female \eqn{δ} -and male δ) or six traits (female and male \ifelse{html}{\out{δ1}}{\eqn{δ_1}}, \ifelse{html}{\out{δ2}}{\eqn{δ_2}} and \ifelse{html}{\out{pI}}{\eqn{p_I}}).\cr +Dispersal kernels can also be sex-dependent (set \code{SexDep=TRUE}). In the case of inter-individual variability, the number of traits is doubled to two trait (female \eqn{\delta} +and male delta) or six traits (female and male \ifelse{html}{\out{δ1}}{\eqn{\delta_1}}, \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} and \ifelse{html}{\out{pI}}{\eqn{p_I}}).\cr For each trait the initial distribution in the population (as mean and standard variation) must be set in \code{Distances} (instead of only one constant value), as well as their scaling factors in \code{TraitScaleFactor} (see \code{\link[RangeShiftR]{Genetics}}).\cr @@ -97,8 +97,8 @@ Further, dispersal kernels can be stage-specific (set \code{StageDep=TRUE}). For All dispersal kernel parameters have to be provided via \code{Distances}, which generally takes a matrix, or - if only a single constant mean distance is used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. The format of the matrix is defined as follows: The number of columns depend on the options \code{IndVar} and \code{DoubleKernel}. -If \code{DoubleKernel=FALSE}, the mean dispersal distance \eqn{δ} must be specified (in meters). If \code{DoubleKernel=TRUE}, the mean dispersal distances -\ifelse{html}{\out{δ1}}{\eqn{δ_1}} and \ifelse{html}{\out{δ2}}{\eqn{δ_2}} (in meters), as well as the probability \ifelse{html}{\out{pI}}{\eqn{p_I}} of using Kernel-1 must be specified. +If \code{DoubleKernel=FALSE}, the mean dispersal distance \eqn{\delta} must be specified (in meters). If \code{DoubleKernel=TRUE}, the mean dispersal distances +\ifelse{html}{\out{δ1}}{\eqn{\delta_1}} and \ifelse{html}{\out{δ2}}{\eqn{\delta_2}} (in meters), as well as the probability \ifelse{html}{\out{pI}}{\eqn{p_I}} of using Kernel-1 must be specified. Additionally, if \code{IndVar=FALSE}, these parameters are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective mean and standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. @@ -107,25 +107,25 @@ If \code{SexDep=TRUE}, state the corresponding stage in the next (i.e. first/sec table lists the required columns and their correct order for different settings: \tabular{ccccc}{IndVar \tab DoubleKernel \tab StageDep \tab SexDep \tab columns \cr - F \tab F \tab F \tab F \tab \eqn{δ} \cr - F \tab F \tab T \tab F \tab stage, \eqn{δ} \cr - F \tab F \tab F \tab T \tab sex, \eqn{δ} \cr - F \tab F \tab T \tab T \tab stage, sex, \eqn{δ} \cr - F \tab T \tab F \tab F \tab \ifelse{html}{\out{δ1, δ2, pI}}{\eqn{δ_1, δ_2, p_I}} \cr - T \tab F \tab F \tab F \tab mean\eqn{(δ)}, sd\eqn{(δ)} \cr - T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(δ_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(δ_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(δ_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(δ_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} \cr - \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr - T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(δ_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(δ_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(δ_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(δ_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} + F \tab F \tab F \tab F \tab \eqn{\delta} \cr + F \tab F \tab T \tab F \tab stage, \eqn{\delta} \cr + F \tab F \tab F \tab T \tab sex, \eqn{\delta} \cr + F \tab F \tab T \tab T \tab stage, sex, \eqn{\delta} \cr + F \tab T \tab F \tab F \tab \ifelse{html}{\out{δ1, δ2, pI}}{\eqn{\delta_1, \delta_2, p_I}} \cr + T \tab F \tab F \tab F \tab mean\eqn{(\delta)}, sd\eqn{(\delta)} \cr + T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(\delta_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(\delta_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(\delta_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(\delta_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} \cr + \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr + T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(δ1)}}{mean\eqn{(\delta_1)}}, \ifelse{html}{\out{sd(δ1)}}{sd\eqn{(\delta_1)}}, \ifelse{html}{\out{mean(δ2)}}{mean\eqn{(\delta_2)}}, \ifelse{html}{\out{sd(δ2)}}{sd\eqn{(\delta_2)}}, mean\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}}, sd\ifelse{html}{\out{(pI)}}{\eqn{(p_I)}} } The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly one row for each stage/sex combination. For example, in the case of a mixed kernel with stage- and sex-dependent distances and no individual variability: -\tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1000 \tab \out{ } 4500 \tab \out{ } 0.92 \cr - \out{ } 0 \tab \out{ } 1 \tab \out{ } 1400 \tab \out{ } 6000 \tab \out{ } 0.95 \cr - \out{ } 1 \tab \out{ } 0 \tab \out{ } 700 \tab \out{ } 500 \tab \out{ } 0.50 \cr - \out{ } 1 \tab \out{ } 1 \tab \out{ } 500 \tab \out{ } 600 \tab \out{ } 0.55 \cr - \out{ } 2 \tab \out{ } 0 \tab \out{ } 100 \tab \out{ } 0 \tab \out{ } 1.0 \cr - \out{ } 2 \tab \out{ } 1 \tab \out{ } 100 \tab \out{ } 0 \tab \out{ } 1.0 +\tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1000 \tab \out{} 4500 \tab \out{} 0.92 \cr + \out{} 0 \tab \out{} 1 \tab \out{} 1400 \tab \out{} 6000 \tab \out{} 0.95 \cr + \out{} 1 \tab \out{} 0 \tab \out{} 700 \tab \out{} 500 \tab \out{} 0.50 \cr + \out{} 1 \tab \out{} 1 \tab \out{} 500 \tab \out{} 600 \tab \out{} 0.55 \cr + \out{} 2 \tab \out{} 0 \tab \out{} 100 \tab \out{} 0 \tab \out{} 1.0 \cr + \out{} 2 \tab \out{} 1 \tab \out{} 100 \tab \out{} 0 \tab \out{} 1.0 } In the case that the dispersal kernel is applied to the entire @@ -141,7 +141,7 @@ proportion of suitable habitat in the landscape and will increase as the availab A second source of dispersal mortality can be specified via the option \code{DistMort}: The probability of mortality is either a constant (\eqn{m=}\code{MortProb}) or a function of distance \eqn{d} (i.e. individuals that travel further are more likely to die): -\ifelse{html}{\out{   m(d) = 1 / ( 1 + e-a (d- b) ) } }{\deqn{ m(d) = 1 / ( 1 + exp[-α (d-b) ] ) } } +\ifelse{html}{\out{ m(d) = 1 / ( 1 + e-a (d- b) ) } }{\deqn{ m(d) = 1 / ( 1 + exp[-\alpha (d-b) ] ) } } with the inflection point \eqn{b=}\code{InflPoint} at which \eqn{m(d=b)=0.5} and the slope \eqn{a=}\code{Slope}.This option may be thought to represent the increased energetic, time or attritional costs that longer-distance dispersers will experience \insertCite{bonte2012costs}{RangeShiftR}. diff --git a/RangeShiftR/man/Emigration.Rd b/RangeShiftR/man/Emigration.Rd index b66dae9..7eed664 100644 --- a/RangeShiftR/man/Emigration.Rd +++ b/RangeShiftR/man/Emigration.Rd @@ -48,18 +48,18 @@ rate can be larger than \eqn{d}, if a stage with \eqn{d>0} lasts for more than o The emigration probability \eqn{d} can be density-dependent (set \code{DensDep=TRUE}), in which case it is given by the following function, introduced by \insertCite{kun2006evolution;textual}{RangeShiftR}: -\ifelse{html}{\out{   d(i,t) = D0 / ( 1 + e-αsub>E (N(i,t) / K(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-α_E (N(i,t)/K(i,t) - β_E) ] ) } } +\ifelse{html}{\out{ d(i,t) = D0 / ( 1 + e-αsub>E (N(i,t) / K(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-\alpha_E (N(i,t)/K(i,t) - \beta_E) ] ) } } In the case of stage-structured models this equation is modified to: -\ifelse{html}{\out{   d(i,t) = D0 / ( 1 + e-αsub>E (b(i,t) * N(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-α_E (b(i,t) N(i,t) - β_E) ] ) } } +\ifelse{html}{\out{ d(i,t) = D0 / ( 1 + e-αsub>E (b(i,t) * N(i,t) - βsub>E) ) } }{\deqn{ d(i,t) = D_0 / ( 1 + exp[-\alpha_E (b(i,t) N(i,t) - \beta_E) ] ) } } In the first case, \eqn{K(i,t)} is the carrying capacity of the cell/patch \eqn{i} at time \eqn{t} given by \code{K_or_DensDep}. In the latter case, \eqn{b(i,t)} represents the strength of density dependence and is given by the inverse of \code{K_or_DensDep}.\cr Further, \ifelse{html}{\out{D0}}{\eqn{D_0}} is the maximum emigration probability, \eqn{N(i,t)} is the number of individuals in the cell/patch \eqn{i} at time \eqn{t}, -\ifelse{html}{\out{βE}}{\eqn{β_S}} is the inflection point of the function and -\ifelse{html}{\out{αE}}{\eqn{α_S}} is the slope at the inflection point.\cr +\ifelse{html}{\out{βE}}{\eqn{\beta_S}} is the inflection point of the function and +\ifelse{html}{\out{αE}}{\eqn{\alpha_S}} is the slope at the inflection point.\cr Various functions have been proposed for density dependent emigration \insertCite{hovestadt2010information,poethke2011ability}{RangeShiftR}. This one was chosen here because it is a flexible function that @@ -68,8 +68,8 @@ emigration, we assume individuals to have full knowledge of the population densi Information acquisition is not explicitly modelled. The emigration probability can be allowed to vary between individuals (set \code{IndVar=TRUE}) and to evolve. In the this case, individuals exhibit either one trait -determining the density-independent \eqn{d} (when \code{DensDep=FALSE}), or the three traits \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α} and -\eqn{β} determining the density-dependent emigration probability (when \code{DensDep=TRUE}).\cr +determining the density-independent \eqn{d} (when \code{DensDep=FALSE}), or the three traits \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha} and +\eqn{\beta} determining the density-dependent emigration probability (when \code{DensDep=TRUE}).\cr For each trait the initial distribution in the population (as mean and standard variation) must be set in \code{EmigProb} (instead of only one constant value), as well as their scaling factors in \code{TraitScaleFactor} (see \code{\link[RangeShiftR]{Genetics}}). Also, if \code{IndVar=TRUE} is set for a stage-structured population, it is required to specify the stage which emigrates via \code{EmigStage}. @@ -81,7 +81,7 @@ However, the current version does not accommodate inter-individual variation in The parameters that determine the emigration probabilities have to be provided via \code{EmigProb}, which generally takes a matrix, or - if only a single constant probability is used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. The format of the matrix is defined as follows: The number of columns depend on the options \code{DensDep} and \code{IndVar}. If \code{DensDep=FALSE}, the -density-independent probability \eqn{d} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α} and \eqn{β} (cp. equation above) must be specified. +density-independent probability \eqn{d} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha} and \eqn{\beta} (cp. equation above) must be specified. Additionally, if \code{IndVar=FALSE}, these parameters are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective mean and standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. @@ -93,20 +93,20 @@ If \code{SexDep=TRUE}, state the corresponding stage in the next (i.e. first/sec F \tab F \tab T \tab F \tab stage, \eqn{d} \cr F \tab F \tab F \tab T \tab sex, \eqn{d} \cr F \tab F \tab T \tab T \tab stage, sex, \eqn{d} \cr - T \tab F \tab F \tab F \tab \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{α}, \eqn{β} \cr + T \tab F \tab F \tab F \tab \ifelse{html}{\out{D0}}{\eqn{D_0}}, \eqn{\alpha}, \eqn{\beta} \cr F \tab T \tab F \tab F \tab mean\eqn{(d)}, sd\eqn{(d)} \cr - T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(α)}, sd\eqn{(α)}, mean\eqn{(β)}, sd\eqn{(β)} \cr - \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr - T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(α)}, sd\eqn{(α)}, mean\eqn{(β)}, sd\eqn{(β)} + T \tab T \tab F \tab F \tab \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(\alpha)}, sd\eqn{(\alpha)}, mean\eqn{(\beta)}, sd\eqn{(\beta)} \cr + \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr + T \tab T \tab F \tab T \tab sex, \ifelse{html}{\out{mean(D0)}}{mean\eqn{(D_0)}}, \ifelse{html}{\out{sd(D0)}}{sd\eqn{(D_0)}}, mean\eqn{(\alpha)}, sd\eqn{(\alpha)}, mean\eqn{(\beta)}, sd\eqn{(\beta)} } The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly one row for each stage/sex combination. For example, in the case of density-, stage- and sex-dependent emigration with no individual variability: -\tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1.0 \tab \out{ } 20 \tab \out{ } 0.2 \cr - \out{ } 0 \tab \out{ } 1 \tab \out{ } 1.0 \tab \out{ } 20 \tab \out{ } 0.1 \cr - \out{ } 1 \tab \out{ } 0 \tab \out{ } 0.7 \tab \out{ } 25 \tab \out{ } 0.5 \cr - \out{ } 1 \tab \out{ } 1 \tab \out{ } 0.8 \tab \out{ } 50 \tab \out{ } 0.5 \cr - \out{ } 2 \tab \out{ } 0 \tab \out{ } 0.4 \tab \out{ } 10 \tab \out{ } 1.0 \cr - \out{ } 2 \tab \out{ } 1 \tab \out{ } 0.5 \tab \out{ } 20 \tab \out{ } 1.0 +\tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1.0 \tab \out{} 20 \tab \out{} 0.2 \cr + \out{} 0 \tab \out{} 1 \tab \out{} 1.0 \tab \out{} 20 \tab \out{} 0.1 \cr + \out{} 1 \tab \out{} 0 \tab \out{} 0.7 \tab \out{} 25 \tab \out{} 0.5 \cr + \out{} 1 \tab \out{} 1 \tab \out{} 0.8 \tab \out{} 50 \tab \out{} 0.5 \cr + \out{} 2 \tab \out{} 0 \tab \out{} 0.4 \tab \out{} 10 \tab \out{} 1.0 \cr + \out{} 2 \tab \out{} 1 \tab \out{} 0.5 \tab \out{} 20 \tab \out{} 1.0 } In the special case that \code{DensDep=FALSE} and transfer is realised by \code{\link[RangeShiftR]{DispersalKernel}}, then the option \code{UseFullKern} may be switched on. It diff --git a/RangeShiftR/man/Settlement.Rd b/RangeShiftR/man/Settlement.Rd index 474811b..ff64309 100644 --- a/RangeShiftR/man/Settlement.Rd +++ b/RangeShiftR/man/Settlement.Rd @@ -57,8 +57,8 @@ The type of implemented settlement rules depends on the movement model utilized In any case, dispersing individuals are not allowed to settle in their natal cell or patch.\cr \emph{RangeShiftR} incorporates some basic settlement rules that can be stage- or sex-specific or both (set \code{StageDep}, \code{SexDep}). Inter-individual variability (\code{IndVar}) is implemented only for movement processes and then for the three traits -determining density-dependent settlement (\ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, -\ifelse{html}{\out{βS}}{\eqn{β_S}}; see below). In this case, settlement may not be stage-dependent.\cr +determining density-dependent settlement (\ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, +\ifelse{html}{\out{βS}}{\eqn{\beta_S}}; see below). In this case, settlement may not be stage-dependent.\cr \emph{Settlement with dispersal kernels}\cr When using a \code{\link[RangeShiftR]{DispersalKernel}}, individuals are displaced directly from the starting location to the arrival location. The suitability @@ -88,7 +88,7 @@ Settlement condition codes: If the individuals current step ends in unsuitable h \eqn{2} = randomly choose a suitable neighbouring cell or die,\cr \eqn{3} = randomly choose a suitable neighbouring cell or wait (stage-structured models only).\cr -Simple example for sex-dependence only: Females choose a neighbouring cell or wait, males wait: \tabular{cc}{\out{ } 0 \tab \out{ } 3 \cr \out{ } 1 \tab \out{ } 0 } +Simple example for sex-dependence only: Females choose a neighbouring cell or wait, males wait: \tabular{cc}{\out{} 0 \tab \out{} 3 \cr \out{} 1 \tab \out{} 0 } \emph{Settlement with movement processes}\cr If individuals are dispersing by one of the two movement processes implemented (\code{\link[RangeShiftR]{SMS}} or @@ -101,18 +101,18 @@ it gets converted to \eqn{S_0=1.0}, i.e. 'always settle when habitat is suitable Furthermore, the settlement decision can be density-dependent (set \code{DensDep=TRUE}). In this case, the individual has a probability \ifelse{html}{\out{pS}}{\eqn{p_S}} of settling in the cell or patch \eqn{i}, given by: -\ifelse{html}{\out{   pS(i,t) = S0 / ( 1 + eS (N(i,t) / K(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-α_S (N(i,t)/K(i,t) - β_S) ] ) } } +\ifelse{html}{\out{ pS(i,t) = S0 / ( 1 + eS (N(i,t) / K(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-\alpha_S (N(i,t)/K(i,t) - \beta_S) ] ) } } In the case of stage-structured models the above equation is modified to: -\ifelse{html}{\out{   pS(i,t) = S0 / ( 1 + eS (b(i,t) * N(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-α_S (b(i,t) N(i,t) - β_S) ] ) } } +\ifelse{html}{\out{ pS(i,t) = S0 / ( 1 + eS (b(i,t) * N(i,t) - βS) ) } }{\deqn{ p_S(i,t) = S_0 / ( 1 + exp[-\alpha_S (b(i,t) N(i,t) - \beta_S) ] ) } } In the first case, \eqn{K(i,t)} is the carrying capacity of the cell/patch \eqn{i} at time \eqn{t} given by \code{K_or_DensDep}. In the latter case, \eqn{b(i,t)} represents the strength of density dependence that is given by the inverse of \code{K_or_DensDep}.\cr Further, \ifelse{html}{\out{S0}}{\eqn{S_0}} is the maximum settlement probability, \eqn{N(i,t)} is the number of individuals in the cell/patch \eqn{i} at time \eqn{t}, -\ifelse{html}{\out{βS}}{\eqn{β_S}} is the inflection point of the function and -\ifelse{html}{\out{αS}}{\eqn{α_S}} is the slope at the inflection point.\cr +\ifelse{html}{\out{βS}}{\eqn{\beta_S}} is the inflection point of the function and +\ifelse{html}{\out{αS}}{\eqn{\alpha_S}} is the slope at the inflection point.\cr Inter-individual variability \code{IndVar=TRUE} and thus evolution is implemented only for the three traits determining density-dependent settlement (\code{DensDep=TRUE}), and if so, it may not be stage-dependent (\code{StageDep=FALSE}). @@ -123,7 +123,7 @@ The parameters that determine the settlement probabilities have to be provided v used (i.e. \code{DensDep, IndVar, StageDep, SexDep = FALSE}) - a single numeric. The format of the matrix is defined as follows: The number of columns depend on the options \code{DensDep} and \code{IndVar}. If \code{DensDep=FALSE}, the density-independent probability \ifelse{html}{\out{pS}}{\eqn{p_S}} must be specified. If \code{DensDep=TRUE}, the functional parameters \ifelse{html}{\out{S0}}{\eqn{S_0}}, -\ifelse{html}{\out{αS}}{\eqn{α_S}} and \ifelse{html}{\out{βS}}{\eqn{β_S}} (cf. equation above) must be specified. +\ifelse{html}{\out{αS}}{\eqn{\alpha_S}} and \ifelse{html}{\out{βS}}{\eqn{\beta_S}} (cf. equation above) must be specified. Additionally, if \code{IndVar=FALSE}, these traits are fixed, but if \code{IndVar=TRUE} each of them is replaced by two parameters: their respective initial mean and standard deviation. They are used to normally distribute the traits values among the individuals of the initial population. Additionally, the \code{TraitScaleFactor} of these traits have to be set. @@ -137,21 +137,21 @@ The following table lists the required columns and their correct order for diffe F \tab F \tab T \tab F \tab stage \cr F \tab F \tab F \tab T \tab sex \cr F \tab F \tab T \tab T \tab stage, sex \cr - T \tab F \tab F \tab F \tab \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, \ifelse{html}{\out{βS}}{\eqn{β_S}} \cr - \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \tab \out{⋮} \cr - T \tab F \tab T \tab T \tab stage, sex, \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{α_S}}, \ifelse{html}{\out{βS}}{\eqn{β_S}} \cr - T \tab T \tab F \tab F \tab mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{β_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{β_S})} \cr - T \tab T \tab F \tab T \tab sex, mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{α_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{β_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{β_S})} + T \tab F \tab F \tab F \tab \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, \ifelse{html}{\out{βS}}{\eqn{\beta_S}} \cr + \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \tab \out{:} \cr + T \tab F \tab T \tab T \tab stage, sex, \ifelse{html}{\out{S0}}{\eqn{S_0}}, \ifelse{html}{\out{αS}}{\eqn{\alpha_S}}, \ifelse{html}{\out{βS}}{\eqn{\beta_S}} \cr + T \tab T \tab F \tab F \tab mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})} \cr + T \tab T \tab F \tab T \tab sex, mean\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, sd\ifelse{html}{\out{(S0)}}{\eqn{(S_0)}}, mean\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, sd\ifelse{html}{\out{(αS)}}{(\eqn{\alpha_S})}, mean\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})}, sd\ifelse{html}{\out{(βS)}}{(\eqn{\beta_S})} } The column headings need not be included, only the numeric matrix is required. The rows require no particular order, but there must be exactly one row for each stage/sex combination. For example, in the case of density-, stage- and sex-dependent settlement with no individual variability: -\tabular{ccccc}{ \out{ } 0 \tab \out{ } 0 \tab \out{ } 1.0 \tab \out{ } 0.2 \tab \out{ } 4.0 \cr - \out{ } 0 \tab \out{ } 1 \tab \out{ } 1.0 \tab \out{ } 0.1 \tab \out{ } 6.0 \cr - \out{ } 1 \tab \out{ } 0 \tab \out{ } 0.7 \tab \out{ } 0.5 \tab \out{ } 2.0 \cr - \out{ } 1 \tab \out{ } 1 \tab \out{ } 0.5 \tab \out{ } 0.5 \tab \out{ } 2.0 \cr - \out{ } 2 \tab \out{ } 0 \tab \out{ } 0.05 \tab \out{ } 1.0 \tab \out{ } 1.0 \cr - \out{ } 2 \tab \out{ } 1 \tab \out{ } 0.05 \tab \out{ } 1.0 \tab \out{ } 1.0 +\tabular{ccccc}{ \out{} 0 \tab \out{} 0 \tab \out{} 1.0 \tab \out{} 0.2 \tab \out{} 4.0 \cr + \out{} 0 \tab \out{} 1 \tab \out{} 1.0 \tab \out{} 0.1 \tab \out{} 6.0 \cr + \out{} 1 \tab \out{} 0 \tab \out{} 0.7 \tab \out{} 0.5 \tab \out{} 2.0 \cr + \out{} 1 \tab \out{} 1 \tab \out{} 0.5 \tab \out{} 0.5 \tab \out{} 2.0 \cr + \out{} 2 \tab \out{} 0 \tab \out{} 0.05 \tab \out{} 1.0 \tab \out{} 1.0 \cr + \out{} 2 \tab \out{} 1 \tab \out{} 0.05 \tab \out{} 1.0 \tab \out{} 1.0 } To avoid having individuals moving perpetually because they cannot find suitable conditions to settle, the model requires a maximum number diff --git a/RangeShiftR/man/Simulation.Rd b/RangeShiftR/man/Simulation.Rd index fe2fd82..5c127e2 100644 --- a/RangeShiftR/man/Simulation.Rd +++ b/RangeShiftR/man/Simulation.Rd @@ -146,7 +146,7 @@ and \eqn{G} (\code{GradSteep}), the gradient steepness in units of fraction of t The local heterogeneity is determined by a random number drawn from a uniform distribution between \eqn{-1} and \eqn{1} for each cell and \code{f}, the local scaling factor that determines the magnitude of this stochastic local variation relative to the extremal value. -The gradient in fecundity φ applies to the fecundity of each stage. Negative local values in \eqn{z(x,y)} are set to \eqn{0}. +The gradient in fecundity \eqn{\phi} applies to the fecundity of each stage. Negative local values in \eqn{z(x,y)} are set to \eqn{0}. It is also possible to simulate the shifting of the gradient by setting the option \code{Shifting}. Here the position \eqn{y} of the species’ optimum is shifted northwards (increasing \eqn{y}) at a given rate \code{ShiftRate} (in units of rows per year), @@ -163,18 +163,18 @@ This does not affect any demographic parameters but simply kills off the local p \emph{Environmental Stochasticity}\cr It is possible to model environmental stochasticity via the option \code{EnvStoch} acting at a global or local scale and can be applied to \code{K_or_DensDep}, the demographic density dependence (\code{EnvStoch=1}), or to growth rate / fecundity (\code{EnvStoch=0}). -It is implemented using a first order autoregressive process to generate time series of the noise value \eqn{ε} +It is implemented using a first order autoregressive process to generate time series of the noise value \eqn{\epsilon} \insertCite{ruokolainen2009}{RangeShiftR}: -\deqn{ε(t+1) = κ ε(t) + \omega(t) \sqrt(1-\kappa^2)} +\deqn{\epsilon(t+1) = \kappa \epsilon(t) + \omega(t) \sqrt(1-\kappa^2)} -where κ is the autocorrelation coefficient (\code{ac}) and ω is a random normal variable drawn from \eqn{N(0,σ)}. -Changing σ (\code{std}) changes the magnitude of the fluctuations. The spatial scale of the variation can either be global (a single time series +where \eqn{\kappa} is the autocorrelation coefficient (\code{ac}) and \eqn{\omega} is a random normal variable drawn from \eqn{N(0,\sigma)}. +Changing \eqn{\sigma} (\code{std}) changes the magnitude of the fluctuations. The spatial scale of the variation can either be global (a single time series for the entire landscape) or local (each cell fluctuates independently), and is always applied on a yearly basis. Different degrees of spatial autocorrelation are not implemented in the current version. The noise affects the species' selected parameter \eqn{Z} as follows: -\deqn{Z(x,y,t) = Z(x,y,0) + Z ε(t)} +\deqn{Z(x,y,t) = Z(x,y,0) + Z \epsilon(t)} where \eqn{x} and \eqn{y} are the cell coordinates and \eqn{Z} is the original parameter value in absence of stochasticity and gradients. In the presence of an environmental gradient, \eqn{Z(x,y,0)} is the gradient value at the cell location, otherwise its equal to \eqn{Z}. The resulting values \eqn{Z(x,y,t)} are limited to the maximum and minimum values \code{minR,maxR} or \code{minK,maxK}, respectively. @@ -184,7 +184,7 @@ Seven different types of outputs can be produced, plus one more for patch-based All the output files will be named with a standard name reporting the simulation ID number and the type of output. The file name will start with the batch number, and also indicate the number of the landscape to which the output refers. Additionally, for each simulation all the set parameters -will be automatically written to a text file named \"Sim0_Parameters.txt\" in the case of simulation\eqn{#=0}. +will be automatically written to a text file named \"Sim0_Parameters.txt\" in the case of simulation\eqn{=0}. - \emph{Species range} (\code{Sim0_Range.txt}) \cr contains the following general information regarding the species’ range:\cr diff --git a/RangeShiftR/man/StageStructure.Rd b/RangeShiftR/man/StageStructure.Rd index 60a492a..598e553 100644 --- a/RangeShiftR/man/StageStructure.Rd +++ b/RangeShiftR/man/StageStructure.Rd @@ -49,39 +49,39 @@ In stage-structured populations, generations can overlap and individuals can be demographic parameters. Individuals are characterized by their age and stage. Each stage has a certain fecundity, survival probability and probability of developing to the next stage. These parameters are provided through classical transition matrices \insertCite{caswell2001}{RangeShiftR}. -\ifelse{html}{\out{φi}}{\eqn{φ_i}} is the fecundity of stage \eqn{i} ; -\ifelse{html}{\out{σi}}{\eqn{σ_i}} is the survival probability of an individual in stage \eqn{i} ; -and \ifelse{html}{\out{γi-j}}{\eqn{γ_(i-j)}} is the probability of developing from stage \eqn{i} to stage \eqn{j}. +\ifelse{html}{\out{φi}}{\eqn{\phi_i}} is the fecundity of stage \eqn{i} ; +\ifelse{html}{\out{σi}}{\eqn{\sigma_i}} is the survival probability of an individual in stage \eqn{i} ; +and \ifelse{html}{\out{γi-j}}{\eqn{\gamma_(i-j)}} is the probability of developing from stage \eqn{i} to stage \eqn{j}. In this way, the transition matrix describes the effect of each individuals current stage (column) on all stages at the next timestep (rows). Since all offspring is born into the juvenile stage (stage 0), all fecundities are always located in the first row of the matrix. However, in \emph{RangeShiftR}, these parameters are not used deterministically as \emph{rates} (like it is typical for matrix models) but, instead, as \emph{probabilities} which are -applied stochastically at the individual level. Hence, each female at stage \eqn{i}, if it reproduces, produces a number of offspring given by \eqn{Poisson}(\ifelse{html}{\out{φi}}{\eqn{φ_i}}), -while Bernoulli trials \eqn{Bern}(\ifelse{html}{\out{σi}}{\eqn{σ_i}}) and \eqn{Bern}(\ifelse{html}{\out{γi,i+1}}{\eqn{γ_(i,i+1)}}) determine if an individual/female survives or not +applied stochastically at the individual level. Hence, each female at stage \eqn{i}, if it reproduces, produces a number of offspring given by \eqn{Poisson}(\ifelse{html}{\out{φi}}{\eqn{\phi_i}}), +while Bernoulli trials \eqn{Bern}(\ifelse{html}{\out{σi}}{\eqn{\sigma_i}}) and \eqn{Bern}(\ifelse{html}{\out{γi,i+1}}{\eqn{\gamma_(i,i+1)}}) determine if an individual/female survives or not and - if it survives - if it develops to the next stage or not. An example transition matrix for a 3-staged only-female or simple sexual (\code{ReproductionType={0,1}}) population model: -\tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{φ_2}} \cr -\eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{σ_1 (1 − γ_(1-2))}} \tab | \tab \eqn{0} \cr -\eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{σ_1 γ_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{σ_2}} \cr} +\tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{\phi_2}} \cr +\eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{\sigma_1 (1 - \gamma_(1-2))}} \tab | \tab \eqn{0} \cr +\eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{\sigma_1 \gamma_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{\sigma_2}} \cr} -In a female-only model (\code{ReproductionType=0}), \ifelse{html}{\out{φ}}{\eqn{φ}} represents the number of female offspring per female and reproductive event. \cr +In a female-only model (\code{ReproductionType=0}), \ifelse{html}{\out{φ}}{\eqn{\phi}} represents the number of female offspring per female and reproductive event. \cr Note that for an implicit (simple) sexual model (\code{ReproductionType=1}), the demographic parameters are not sex-specific. However, individuals are defined by their sex, which is acknowledged for example in the dispersal -process and transmission of alleles. The fecundities \ifelse{html}{\out{φ}}{\eqn{φ}} refer to the number of all offspring (males and females) per female and reproductive event. +process and transmission of alleles. The fecundities \ifelse{html}{\out{φ}}{\eqn{\phi}} refer to the number of all offspring (males and females) per female and reproductive event. In case of an explicit (complex) sexual model (\code{ReproductionType=2}), in contrast, each stage must be represented by two columns and rows to distinguish male and female demographic parameters. -Note, however, that in any case the juvenile stage has only one row; it contains the fecundities. Male fecundities should have one of two possible values: set \ifelse{html}{\out{φm}}{\eqn{φ_m}} \eqn{=1.0} for reproductive males or \ifelse{html}{\out{φm}}{\eqn{φ_m}} \eqn{=0.0} for non-reproductive males.\cr +Note, however, that in any case the juvenile stage has only one row; it contains the fecundities. Male fecundities should have one of two possible values: set \ifelse{html}{\out{φm}}{\eqn{\phi_m}} \eqn{=1.0} for reproductive males or \ifelse{html}{\out{φm}}{\eqn{\phi_m}} \eqn{=0.0} for non-reproductive males.\cr An example transition matrix for a 3-staged explicit sexual population model \insertCite{weeks1986,lindstrom1998}{RangeShiftR}: -\tabular{ccccccccccc}{\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{φ1m}}{\eqn{φ_1m}} \tab | \tab \ifelse{html}{\out{φ1f}}{\eqn{φ_1f}} \tab | \tab \ifelse{html}{\out{φ2m}}{\eqn{φ_2m}} \tab | \tab \ifelse{html}{\out{φ2f}}{\eqn{φ_2f}} \cr -\eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m (1-γ1-2,m)}}{\eqn{σ_1m (1 − γ_(1-2,m))}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr -\eqn{0} \tab | \tab \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{σ_1f γ_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr -\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m γ1-2,m}}{\eqn{σ_1m γ_(1-2,m)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2m}}{\eqn{σ_2m}} \tab | \tab \eqn{0} \cr -\eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{σ_1f γ_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2f}}{\eqn{σ_2f}} \cr}#' The mating system is explicitly modelled and a female’s probability of reproducing is determined as described in \code{\link[RangeShiftR]{Demography}} \insertCite{weeks1986,caswell2001}{RangeShiftR}. +\tabular{ccccccccccc}{\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{φ1m}}{\eqn{\phi_1m}} \tab | \tab \ifelse{html}{\out{φ1f}}{\eqn{\phi_1f}} \tab | \tab \ifelse{html}{\out{φ2m}}{\eqn{\phi_2m}} \tab | \tab \ifelse{html}{\out{φ2f}}{\eqn{\phi_2f}} \cr +\eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m (1-γ1-2,m)}}{\eqn{\sigma_1m (1 - \gamma_(1-2,m))}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr +\eqn{0} \tab | \tab \eqn{1.0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{\sigma_1f \gamma_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \cr +\eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1m γ1-2,m}}{\eqn{\sigma_1m \gamma_(1-2,m)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2m}}{\eqn{\sigma_2m}} \tab | \tab \eqn{0} \cr +\eqn{0} \tab | \tab \eqn{0} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ1f γ1-2,f}}{\eqn{\sigma_1f \gamma_(1-2,f)}} \tab | \tab \eqn{0} \tab | \tab \ifelse{html}{\out{σ2f}}{\eqn{\sigma_2f}} \cr}#' The mating system is explicitly modelled and a female’s probability of reproducing is determined as described in \code{\link[RangeShiftR]{Demography}} \insertCite{weeks1986,caswell2001}{RangeShiftR}. A common mistake in building a transition matrix is made when offspring produced at year \eqn{t} develop to the next stage in the same year \insertCite{@ @caswell2001 pg. 60-62}{RangeShiftR}. To avoid this problem without losing the offspring stage, and hence the chance for simulating post-natal dispersal, we require an additional explicit juvenile stage (stage 0). Juveniles have to develop to stage 1 in the same year they are born. Hence the minimum number of stages of a stage-structured model is always \eqn{2}. It is important to note that juvenile mortality can be accounted for in -two ways. Either, as in the examples above, it is included in adult fecundity \ifelse{html}{\out{φ}}{\eqn{φ}} (by appropriately reducing its value), and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{σ_0 γ_(0-1)}} is equal to \eqn{1.0}. This is how it is typically accounted for in matrix models. Or, alternatively, -φ is equal to the true maximum fecundity and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{σ_0 γ_(0-1)}} is less than \eqn{1.0}. +two ways. Either, as in the examples above, it is included in adult fecundity \ifelse{html}{\out{φ}}{\eqn{\phi}} (by appropriately reducing its value), and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{\sigma_0 \gamma_(0-1)}} is equal to \eqn{1.0}. This is how it is typically accounted for in matrix models. Or, alternatively, +\eqn{\phi} is equal to the true maximum fecundity and \ifelse{html}{\out{σ0 γ(0-1)}}{\eqn{\sigma_0 \gamma_(0-1)}} is less than \eqn{1.0}. Only the first approach allows straightforward direct comparison with standard analytical matrix models. \emph{Minimum ages:} For every row in the transition matrix, a minimum age must be provided through a vector in argument \code{MinAge}. It specifies the age which an individual in stage \eqn{i-1} (with sex \eqn{m/f}, if applicable) must already have reached before it can develop into the next stage \eqn{(i)}. The vector must be in @@ -114,26 +114,26 @@ If the transition matrix contains the annual survival and development rates, \co \emph{Density dependence} can act on each of the three demographic phases (i.e. reproduction, survival and development) and is controlled by \code{FecDensDep,DevDensDep,SurvDensDep}. It is implemented as an exponential decay \insertCite{neubert2000}{RangeShiftR}: -\ifelse{html}{\out{   φi(r,t) = φ0,i * e - b(r) N(t) }}{\deqn{φ_i(r,t)=φ_(0,i) * exp(- b(r) N(t) ) }} +\ifelse{html}{\out{ φi(r,t) = φ0,i * e - b(r) N(t) }}{\deqn{\phi_i(r,t)=\phi_(0,i) * exp(- b(r) N(t) ) }} -\ifelse{html}{\out{   σi(r,t) = σ0,i * e - Cσ b(r) N(t) }}{\deqn{σ_i(r,t)=σ_(0,i) * exp(- C_\sigma b(r) N(t) ) }} +\ifelse{html}{\out{ σi(r,t) = σ0,i * e - Cσ b(r) N(t) }}{\deqn{\sigma_i(r,t)=\sigma_(0,i) * exp(- C_\sigma b(r) N(t) ) }} -\ifelse{html}{\out{   γi(r,t) = γ0,i * e - Cγ b(r) N(t) }}{\deqn{γ_i(r,t)=γ_(0,i) * exp(- C_γ b(r) N(t) ) }} +\ifelse{html}{\out{ γi(r,t) = γ0,i * e - Cγ b(r) N(t) }}{\deqn{\gamma_i(r,t)=\gamma_(0,i) * exp(- C_\gamma b(r) N(t) ) }} where \eqn{b(r)} is the strength of density dependence in fecundity at site \eqn{r}, which is given by the argument \code{K_or_DensDep} in the landscape module. -Furthermore, \ifelse{html}{\out{Cσ}}{\eqn{C_\sigma}} and \ifelse{html}{\out{Cγ}}{\eqn{C_γ}} (\code{DevDensCoeff,SurvDensCoeff}) +Furthermore, \ifelse{html}{\out{Cσ}}{\eqn{C_\sigma}} and \ifelse{html}{\out{Cγ}}{\eqn{C_\gamma}} (\code{DevDensCoeff,SurvDensCoeff}) scale the strength of density dependence in survival and development relative to that in fecundity. Moreover, the strength of density-dependence can be uniform for all stages or stage-dependent. Even greater complexity can be incorporated with different stages contributing differently to density-dependence \insertCite{caswell2004}{RangeShiftR}: -\ifelse{html}{\out{  φi(r,t) = φ0,i * e - b(r) ΣjS ωφ,ij N(j,t)}}{\deqn{φ_i(r,t)=φ_(0,i) * exp(- b(r) \Sigma_j^S ω_{φ,ij} N_j(t) ) }} +\ifelse{html}{\out{ φi(r,t) = φ0,i * e - b(r) ΣjS ωφ,ij N(j,t)}}{\deqn{\phi_i(r,t)=\phi_(0,i) * exp(- b(r) \Sigma_j^S \omega_{\phi,ij} N_j(t) ) }} -\ifelse{html}{\out{  σi(r,t) = σ0,i * e - Cσ b(r) ΣjS ωσ,ij N(j,t) }}{\deqn{σ_i(r,t)=σ_(0,i) * exp(- C_\sigma b(r) \Sigma_j^S ω_{σ,ij} N_j(t) )}} +\ifelse{html}{\out{ σi(r,t) = σ0,i * e - Cσ b(r) ΣjS ωσ,ij N(j,t) }}{\deqn{\sigma_i(r,t)=\sigma_(0,i) * exp(- C_\sigma b(r) \Sigma_j^S \omega_{\sigma,ij} N_j(t) )}} -\ifelse{html}{\out{  γi(r,t) = γ0,i * e - Cγ b(r) ΣjS ωγ,ij N(j,t)}}{\deqn{γ_i(r,t)=γ_(0,i) * exp(- C_γ b(r) \Sigma_j^S ω_{γ,ij} N_j(t) )}} +\ifelse{html}{\out{ γi(r,t) = γ0,i * e - Cγ b(r) ΣjS ωγ,ij N(j,t)}}{\deqn{\gamma_i(r,t)=\gamma_(0,i) * exp(- C_\gamma b(r) \Sigma_j^S \omega_{\gamma,ij} N_j(t) )}} -where \ifelse{html}{\out{ωφ}}{\eqn{ω_φ}}, \ifelse{html}{\out{ωσ}}{\eqn{ω_σ}}, \ifelse{html}{\out{ωγ}}{\eqn{ω_γ}} are weight matrices given by \code{FecStageWtsMatrix, DevStageWtsMatrix, SurvStageWtsMatrix}. Their elements \ifelse{html}{\out{ωij}}{\eqn{ω_ij}} +where \ifelse{html}{\out{ωφ}}{\eqn{\omega_\phi}}, \ifelse{html}{\out{ωσ}}{\eqn{\omega_\sigma}}, \ifelse{html}{\out{ωγ}}{\eqn{\omega_\gamma}} are weight matrices given by \code{FecStageWtsMatrix, DevStageWtsMatrix, SurvStageWtsMatrix}. Their elements \ifelse{html}{\out{ωij}}{\eqn{\omega_ij}} represent the contributions of the abundance of stage \eqn{j} to the density dependence in the fecundity / survival / development of stage \eqn{i}, thus they are quadratic matrices of size \code{Stages}\eqn{^2}. Note that the row sums are not required to be normalized, therefore they can be used to scale the density-dependence for the different stages. In fact, any real value will be accepted for the single weights, so care should be taken when setting them. } diff --git a/RangeShiftR/man/plotProbs.Rd b/RangeShiftR/man/plotProbs.Rd index 29d6497..98b37b3 100644 --- a/RangeShiftR/man/plotProbs.Rd +++ b/RangeShiftR/man/plotProbs.Rd @@ -31,20 +31,20 @@ Available methods and their options: If a mixed kernel was defined (i.e. \code{DoubleKernel=TRUE}), plot the resulting dispersal probability by... \itemize{ \item \code{combinekernels=FALSE} - ...plotting both kernels separately (default) - \item \code{combinekernels= TRUE} - ...combining both kernels, i.e. \ifelse{html}{ \out{p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1) } }{\deqn{ p(d; δ_1,δ_2) = p_I p(d;δ_1) + (1-p_I) p(d;δ_2)} } + \item \code{combinekernels= TRUE} - ...combining both kernels, i.e. \ifelse{html}{ \out{p(d; δ12) = pI p(d;δ1) + (1-pI) p(d;δ1) } }{\deqn{ p(d; \delta_1,\delta_2) = p_I p(d;\delta_1) + (1-p_I) p(d;\delta_2)} } } \item \code{\link[RangeShiftR]{StageStructure}}: plot fecundity as well as survival and development probabilities. Survival and development are calculated based on the transition matrix. Consider e.g. a 3 stage matrix with a transition matrix of - \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{φ_2}} \cr - \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{σ_1 (1 − γ_(1-2))}} \tab | \tab \eqn{0} \cr - \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{σ_1 γ_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{σ_2}} \cr} + \tabular{ccccc}{0 \tab | \tab 0 \tab | \tab \ifelse{html}{\out{φ2}}{\eqn{\phi_2}} \cr + \eqn{1.0} \tab | \tab \ifelse{html}{\out{σ1 (1-γ1-2)}}{\eqn{\sigma_1 (1 - \gamma_(1-2))}} \tab | \tab \eqn{0} \cr + \eqn{0} \tab | \tab \ifelse{html}{\out{σ1 γ1-2}}{\eqn{\sigma_1 \gamma_(1-2)}} \tab | \tab \ifelse{html}{\out{σ2}}{\eqn{\sigma_2}} \cr} The survival probability is calculated as the sum of the probability to stay in the same stage and the probability to reach the next stage. - E.g. for stage 1: \ifelse{html}{\out{σ1 = sum( σ1 (1-γ1-2), σ1 γ1-2}}{\eqn{σ_1 = sum(σ_1 (1 − γ_(1-2)), σ_1 γ_(1-2))}} + E.g. for stage 1: \ifelse{html}{\out{σ1 = sum( σ1 (1-γ1-2), σ1 γ1-2}}{\eqn{\sigma_1 = sum(\sigma_1 (1 - \gamma_(1-2)), \sigma_1 \gamma_(1-2))}} The development probability of stage 1 to stage 2 is the ratio of the probability to reach stage 2 and the previously calculated survival probability. - E.g. for stage 1: \ifelse{html}{\out{γ1-2 = σ1 γ1-2 / σ1}}{\eqn{γ_(1-2) = σ_1 / (σ_1 γ_(1-2) )}} + E.g. for stage 1: \ifelse{html}{\out{γ1-2 = σ1 γ1-2 / σ1}}{\eqn{\gamma_(1-2) = \sigma_1 / (\sigma_1 \gamma_(1-2) )}} } } diff --git a/RangeShiftR/src/Makevars b/RangeShiftR/src/Makevars index 5744dce..d4e75c3 100644 --- a/RangeShiftR/src/Makevars +++ b/RangeShiftR/src/Makevars @@ -1,7 +1,10 @@ -SOURCES = $(wildcard RScore/*.cpp) +SOURCES = RScore/Cell.cpp RScore/Community.cpp RScore/FractalGenerator.cpp \ + RScore/Genome.cpp RScore/Individual.cpp RScore/Landscape.cpp \ + RScore/Model.cpp RScore/Parameters.cpp RScore/Patch.cpp \ + RScore/Population.cpp RScore/RandomCheck.cpp RScore/RSrandom.cpp \ + RScore/Species.cpp RScore/SubCommunity.cpp OBJECTS = Rinterface.o RcppExports.o $(SOURCES:.cpp=.o) CXX_STD = CXX11 -PKG_CXXFLAGS = -O2 -# PKG_CXXFLAGS = -Wall -pedantic +# PKG_CXXFLAGS = -O2 diff --git a/RangeShiftR/src/Makevars.win b/RangeShiftR/src/Makevars.win index 477f4d0..15bb657 100644 --- a/RangeShiftR/src/Makevars.win +++ b/RangeShiftR/src/Makevars.win @@ -1,7 +1,10 @@ -SOURCES = $(wildcard RScore/*.cpp) +SOURCES = RScore/Cell.cpp RScore/Community.cpp RScore/FractalGenerator.cpp \ + RScore/Genome.cpp RScore/Individual.cpp RScore/Landscape.cpp \ + RScore/Model.cpp RScore/Parameters.cpp RScore/Patch.cpp \ + RScore/Population.cpp RScore/RandomCheck.cpp RScore/RSrandom.cpp \ + RScore/Species.cpp RScore/SubCommunity.cpp OBJECTS = Rinterface.o RcppExports.o $(SOURCES:.cpp=.o) CXX_STD = CXX11 PKG_CXXFLAGS = -DRSWIN64 -w -#PKG_CXXFLAGS = -H \ No newline at end of file