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.
demographicCoefficients(
replicates,
modelVersion = "Johnson",
survivalModelNumber = "M1",
recruitmentModelNumber = "M4",
useQuantiles = TRUE,
populationGrowthTable = popGrowthTableJohnsonECCC
)
getCoefs(populationGrowthTable, resVar, modelVersion, modNum)
sampleCoefs(coefTable, replicates)
integer. Number of replicate populations.
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.
character. Which model number to use see popGrowthTableJohnsonECCC for options.
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. If useQuantiles = TRUE
,
replicate populations will be assigned to quantiles in the default range of
0.025 and 0.975.
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.
character. Response variable, typically "femaleSurvival" or "recruitment"
character vector. Which model number(s) to use see popGrowthTableJohnsonECCC for typical options.
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()
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
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.
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
Caribou demography functions:
caribouBayesianPM()
,
caribouPopGrowth()
,
compositionBiasCorrection()
,
demographicProjectionApp()
,
demographicRates()
,
getOutputTables()
,
getPriors()
,
getScenarioDefaults()
,
getSimsNational()
,
plotRes()
,
popGrowthTableJohnsonECCC
,
runScnSet()
,
simulateObservations()
# sample coefficients for default models
demographicCoefficients(10)
#> $modelVersion
#> [1] "Johnson"
#>
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#> Intercept Anthro Precision
#> [1,] -0.1336595 -0.0007624518 59.53215
#> [2,] -0.1409718 -0.0008269774 60.53790
#> [3,] -0.1331624 -0.0008968514 59.79600
#> [4,] -0.1279467 -0.0009351104 54.49847
#> [5,] -0.1402076 -0.0007126604 67.70302
#> [6,] -0.1341783 -0.0009816173 68.66600
#> [7,] -0.1278602 -0.0008103753 58.57169
#> [8,] -0.1476828 -0.0007057689 79.48561
#> [9,] -0.1480838 -0.0008060019 56.88737
#> [10,] -0.1379074 -0.0010090037 61.13307
#>
#> $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.4472222 0.9750000 0.6583333 0.3416667 0.7638889 0.5527778 0.0250000
#> [8] 0.1305556 0.2361111 0.8694444
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro fire_excl_anthro Precision
#> [1,] -1.0385914 -0.01784110 -0.005095197 16.24928
#> [2,] -0.9935816 -0.01546560 -0.007507857 17.86046
#> [3,] -1.0024445 -0.01887748 -0.006386528 18.14406
#> [4,] -1.0387195 -0.01414084 -0.004974346 18.99112
#> [5,] -1.0087392 -0.01477727 -0.012179255 21.82254
#> [6,] -1.1043363 -0.01951234 -0.011224992 24.66386
#> [7,] -0.9196172 -0.01576567 -0.008414955 15.99503
#> [8,] -1.1234125 -0.01502318 -0.004762866 17.96014
#> [9,] -1.0537040 -0.01606396 -0.005006864 20.54785
#> [10,] -0.8653840 -0.01818452 -0.010078639 22.75818
#>
#> $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.4472222 0.2361111 0.6583333 0.1305556 0.7638889 0.0250000 0.9750000
#> [8] 0.8694444 0.5527778 0.3416667
#>
#>
# 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.1478660 -0.0009110440 56.49724
#> [2,] -0.1446051 -0.0006600159 53.13350
#> [3,] -0.1384197 -0.0009008546 73.85101
#> [4,] -0.1431392 -0.0006623174 59.66967
#> [5,] -0.1404038 -0.0009753110 69.12058
#> [6,] -0.1360657 -0.0006962018 63.91080
#> [7,] -0.1542562 -0.0008695985 65.19231
#> [8,] -0.1530940 -0.0007732620 65.08848
#> [9,] -0.1553243 -0.0008528537 62.93344
#> [10,] -0.1581460 -0.0006450591 69.57432
#>
#> $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.7638889 0.4472222 0.8694444 0.3416667 0.9750000 0.0250000 0.6583333
#> [8] 0.1305556 0.5527778 0.2361111
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -0.8062151 -0.01563943
#> [2,] -0.9196684 -0.01593913
#> [3,] -0.8979511 -0.01562644
#> [4,] -1.0171600 -0.01356781
#> [5,] -0.9280347 -0.02011052
#> [6,] -0.9018135 -0.01677620
#> [7,] -0.8550586 -0.01417455
#> [8,] -0.9719659 -0.01426752
#> [9,] -0.9180666 -0.01365285
#> [10,] -0.8895341 -0.01191941
#>
#> $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.3416667 0.7638889 0.6583333 0.0250000 0.5527778 0.2361111 0.9750000
#> [8] 0.4472222 0.8694444 0.1305556
#>
#>
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.9578218 -0.01492273
#> [2,] -0.9135661 -0.01039179
#> [3,] -0.9276099 -0.01584458
#> [4,] -0.9451325 -0.01377702
#> [5,] -0.9568116 -0.01266597
#> [6,] -1.0399361 -0.01389490
#> [7,] -0.9200718 -0.01369685
#> [8,] -1.0040460 -0.01466352
#> [9,] -1.0560931 -0.01433763
#> [10,] -1.0387943 -0.01374982
#>
#> $coefValues
#> Intercept Total_dist
#> <num> <num>
#> 1: -0.956 -0.015
#>
#> $coefStdErrs
#> Intercept Total_dist
#> <num> <num>
#> 1: 0.0619898 0.001530612
#>