Sample demographic regression model coefficients
Source:R/demographicCoefficients.R
, R/getCoefs.R
, R/sampleCoefs.R
demographicCoefficients.Rd
Select the regression coefficient values and standard errors for the desired
model version (see popGrowthTableJohnsonECCC
for options) and then sample
from the Gaussian distribution for each replicate population.
demographicCoefficients
is a wrapper around getCoefs()
, which selects
coefficients and sampleCoefs()
, which samples coefficients, for both the
survival and recruitment models.
Usage
demographicCoefficients(
replicates,
modelVersion = "Johnson",
survivalModelNumber = "M1",
recruitmentModelNumber = "M4",
useQuantiles = TRUE,
populationGrowthTable = popGrowthTableJohnsonECCC
)
getCoefs(populationGrowthTable, resVar, modelVersion, modNum)
sampleCoefs(coefTable, replicates)
Arguments
- replicates
integer. Number of replicate populations.
- modelVersion
character. Which model version to use. Currently the only option is "Johnson" for the model used in Johnson et. al. (2020), but additional options may be added in the future.
- survivalModelNumber, recruitmentModelNumber
character. Which model number to use see popGrowthTableJohnsonECCC for options.
- useQuantiles
logical or numeric. If it is a numeric vector it must be length 2 and give the low and high limits of the quantiles to use. If
useQuantiles != FALSE
, each replicate population is assigned to a quantile of the distribution of variation around the expected values, and remains in that quantile as covariates change. IfuseQuantiles = TRUE
, replicate populations will be assigned to quantiles in the default range of 0.025 and 0.975.- populationGrowthTable
data.frame.popGrowthTableJohnsonECCC is included in the package and should be used in most cases. A custom table of model coefficients and standard errors or confidence intervals can be provided but it must match the column names of popGrowthTableJohnsonECCC. If the table does not contain the standard error it is calculated from the confidence interval.
- resVar
character. Response variable, typically "femaleSurvival" or "recruitment"
- modNum
character vector. Which model number(s) to use see popGrowthTableJohnsonECCC for typical options.
- coefTable
data.table. Table must have columns "Coefficient" for the name of the coefficient, "Value" for the value of the coefficient and "StdErr" for the standard error of coefficients. Typically created with
getCoefs()
Value
For demographicCoefficients
a list with elements:
"modelVersion": The name of the model version
"coefSamples_Survival" and"coefSamples_Recruitment": lists with elements:
"coefSamples": Bootstrapped coefficients with
replicates
rows"coefValues": Coefficient values taken from
populationGrowthTable
"quantiles": A vector of randomly selected quantiles between 0.025 and 0.975 with length
replicates
For getCoefs
: a named list with one element per model version. The names are
modelVersion_modNum_Type
. Each element contains a data.frame that is a subset
of populationGrowthTable
for the selected model
For sampleCoefs
a list with elements:
"coefSamples": Bootstrapped coefficients with
replicates
rows"coefValues": Coefficient values taken from
populationGrowthTable
Details
Each population is optionally assigned to quantiles of the error
distributions for survival and recruitment. Using quantiles means that the
population will stay in these quantiles as disturbance changes over time, so
there is persistent variation in recruitment and survival among example
populations. See demographicRates()
for more details.
References
Johnson, C.A., Sutherland, G.D., Neave, E., Leblond, M., Kirby, P., Superbie, C. and McLoughlin, P.D., 2020. Science to inform policy: linking population dynamics to habitat for a threatened species in Canada. Journal of Applied Ecology, 57(7), pp.1314-1327. https://doi.org/10.1111/1365-2664.13637
See also
Caribou demography functions:
bbouMakeSummaryTable()
,
caribouBayesianPM()
,
caribouPopGrowth()
,
caribouPopSimMCMC()
,
compositionBiasCorrection()
,
demographicProjectionApp()
,
demographicRates()
,
doSim()
,
getBBNationalInformativePriors()
,
getOutputTables()
,
getPriors()
,
getScenarioDefaults()
,
getSimsInitial()
,
getSimsNational()
,
plotRes()
,
popGrowthTableJohnsonECCC
,
runScnSet()
,
simulateObservations()
Examples
# sample coefficients for default models
demographicCoefficients(10)
#> $modelVersion
#> [1] "Johnson"
#>
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#> Intercept Anthro Precision
#> [1,] -0.1479737 -0.0005701661 69.50197
#> [2,] -0.1600870 -0.0007653412 60.32224
#> [3,] -0.1391104 -0.0008816247 61.03651
#> [4,] -0.1400045 -0.0009048662 79.78217
#> [5,] -0.1550823 -0.0007689388 57.98898
#> [6,] -0.1418435 -0.0007356601 57.95633
#> [7,] -0.1502117 -0.0008732969 73.60800
#> [8,] -0.1369011 -0.0009297046 58.19659
#> [9,] -0.1563988 -0.0009521161 73.80030
#> [10,] -0.1392187 -0.0005823451 88.29372
#>
#> $coefSamples_Survival$coefValues
#> Intercept Anthro Precision
#> <num> <num> <num>
#> 1: -0.142 -8e-04 63.43724
#>
#> $coefSamples_Survival$coefStdErrs
#> Intercept Anthro Precision
#> <num> <num> <num>
#> 1: 0.007908163 0.000127551 8.272731
#>
#> $coefSamples_Survival$quantiles
#> [1] 0.3416667 0.7638889 0.1305556 0.8694444 0.6583333 0.2361111 0.4472222
#> [8] 0.0250000 0.5527778 0.9750000
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro fire_excl_anthro Precision
#> [1,] -1.0256774 -0.01928419 -0.012244233 17.94661
#> [2,] -1.1028337 -0.01888475 -0.008125937 19.50097
#> [3,] -1.0863459 -0.01842017 -0.010780208 19.65594
#> [4,] -1.0881254 -0.01586237 -0.009021197 18.27424
#> [5,] -1.0348292 -0.01803598 -0.007302765 22.21539
#> [6,] -1.0549527 -0.01722112 -0.006245603 21.53186
#> [7,] -0.9958618 -0.01753239 -0.007792693 18.81505
#> [8,] -1.0225244 -0.01728490 -0.007348486 19.32067
#> [9,] -1.0520696 -0.01741152 -0.008420639 20.97041
#> [10,] -1.0013358 -0.01754949 -0.006746403 20.68298
#>
#> $coefSamples_Recruitment$coefValues
#> Intercept Anthro fire_excl_anthro Precision
#> <num> <num> <num> <num>
#> 1: -1.023 -0.017 -0.0081 19.86189
#>
#> $coefSamples_Recruitment$coefStdErrs
#> Intercept Anthro fire_excl_anthro Precision
#> <num> <num> <num> <num>
#> 1: 0.06122449 0.001530612 0.002040816 2.228655
#>
#> $coefSamples_Recruitment$quantiles
#> [1] 0.1305556 0.3416667 0.6583333 0.7638889 0.9750000 0.8694444 0.2361111
#> [8] 0.0250000 0.5527778 0.4472222
#>
#>
# try a different model
demographicCoefficients(10, modelVersion = "Johnson", survivalModelNumber = "M1",
recruitmentModelNumber = "M3")
#> $modelVersion
#> [1] "Johnson"
#>
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#> Intercept Anthro Precision
#> [1,] -0.1406094 -0.0008738126 82.21153
#> [2,] -0.1475970 -0.0008725362 70.94926
#> [3,] -0.1423618 -0.0011029748 57.29278
#> [4,] -0.1361523 -0.0006950322 64.61082
#> [5,] -0.1348468 -0.0009443865 83.97125
#> [6,] -0.1330162 -0.0006964976 60.84120
#> [7,] -0.1406062 -0.0007705769 51.13521
#> [8,] -0.1347637 -0.0009495385 52.84935
#> [9,] -0.1412607 -0.0008936014 65.44509
#> [10,] -0.1602444 -0.0008518974 59.61873
#>
#> $coefSamples_Survival$coefValues
#> Intercept Anthro Precision
#> <num> <num> <num>
#> 1: -0.142 -8e-04 63.43724
#>
#> $coefSamples_Survival$coefStdErrs
#> Intercept Anthro Precision
#> <num> <num> <num>
#> 1: 0.007908163 0.000127551 8.272731
#>
#> $coefSamples_Survival$quantiles
#> [1] 0.6583333 0.3416667 0.2361111 0.4472222 0.0250000 0.1305556 0.9750000
#> [8] 0.8694444 0.7638889 0.5527778
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -1.0135408 -0.01468051
#> [2,] -1.0281064 -0.01469810
#> [3,] -0.9943457 -0.01577657
#> [4,] -0.9723026 -0.01801268
#> [5,] -0.9882687 -0.01468921
#> [6,] -0.9819609 -0.01408032
#> [7,] -0.8250118 -0.01227711
#> [8,] -0.9762388 -0.01355187
#> [9,] -0.9953704 -0.01621627
#> [10,] -0.8683654 -0.01739138
#>
#> $coefSamples_Recruitment$coefValues
#> Intercept Total_dist
#> <num> <num>
#> 1: -0.956 -0.015
#>
#> $coefSamples_Recruitment$coefStdErrs
#> Intercept Total_dist
#> <num> <num>
#> 1: 0.0619898 0.001530612
#>
#> $coefSamples_Recruitment$quantiles
#> [1] 0.4472222 0.1305556 0.3416667 0.6583333 0.5527778 0.7638889 0.2361111
#> [8] 0.9750000 0.0250000 0.8694444
#>
#>
getCoefs(popGrowthTableJohnsonECCC, "femaleSurvival", "Johnson", "M1")
#> $Johnson_M1_National
#> modelVersion responseVariable ModelNumber Type Coefficient Value
#> <char> <char> <char> <char> <char> <num>
#> 1: Johnson femaleSurvival M1 National Intercept -0.14200
#> 2: Johnson femaleSurvival M1 National Anthro -0.00080
#> 3: Johnson femaleSurvival M1 National Precision 63.43724
#> StdErr lowerCI upperCI
#> <num> <num> <num>
#> 1: 0.007908163 -0.158 -0.1270
#> 2: 0.000127551 -0.001 -0.0005
#> 3: 8.272730950 NA NA
#>
cfs <- getCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")
sampleCoefs(cfs[[1]], 10)
#> $coefSamples
#> Intercept Total_dist
#> [1,] -0.9690062 -0.01339890
#> [2,] -1.0262298 -0.01431645
#> [3,] -0.8795843 -0.01274850
#> [4,] -1.0427081 -0.01236832
#> [5,] -1.1211793 -0.01438444
#> [6,] -0.9170617 -0.01449715
#> [7,] -0.8526879 -0.01561124
#> [8,] -0.8735087 -0.01223460
#> [9,] -0.9530443 -0.01330164
#> [10,] -0.9903259 -0.01339865
#>
#> $coefValues
#> Intercept Total_dist
#> <num> <num>
#> 1: -0.956 -0.015
#>
#> $coefStdErrs
#> Intercept Total_dist
#> <num> <num>
#> 1: 0.0619898 0.001530612
#>