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.1524029 -0.0008458567 44.07229
#> [2,] -0.1410464 -0.0007764965 63.43823
#> [3,] -0.1455076 -0.0006650922 44.79467
#> [4,] -0.1457936 -0.0008477356 70.63688
#> [5,] -0.1489571 -0.0009285907 61.29695
#> [6,] -0.1539896 -0.0009093222 69.69131
#> [7,] -0.1400398 -0.0008223592 54.25443
#> [8,] -0.1442556 -0.0006222231 54.07474
#> [9,] -0.1451088 -0.0010617606 62.00751
#> [10,] -0.1474808 -0.0005522907 55.16935
#>
#> $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.8694444 0.3416667 0.7638889 0.9750000 0.6583333 0.4472222 0.0250000
#> [8] 0.1305556 0.2361111 0.5527778
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro fire_excl_anthro Precision
#> [1,] -1.0743471 -0.01468985 -0.004430440 17.22820
#> [2,] -1.0509878 -0.01673233 -0.006685519 20.15505
#> [3,] -1.0092618 -0.01619560 -0.008470479 25.30203
#> [4,] -0.9990547 -0.01625811 -0.010641559 25.36992
#> [5,] -1.0780622 -0.01934783 -0.009311621 20.74759
#> [6,] -0.9821302 -0.01813720 -0.008116238 21.72878
#> [7,] -1.0366444 -0.01487133 -0.008197971 17.55254
#> [8,] -1.0431174 -0.01574956 -0.004557604 19.95784
#> [9,] -1.0703729 -0.01776042 -0.010127167 17.33536
#> [10,] -1.0562158 -0.01847031 -0.005249157 17.73874
#>
#> $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.8694444 0.6583333 0.2361111 0.0250000 0.4472222 0.7638889 0.3416667
#> [8] 0.9750000 0.1305556 0.5527778
#>
#>
# 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.1432790 -0.0010206482 60.38695
#> [2,] -0.1451701 -0.0010013729 65.90540
#> [3,] -0.1530160 -0.0006952228 65.63829
#> [4,] -0.1352511 -0.0008203324 74.29173
#> [5,] -0.1481530 -0.0007162199 58.68887
#> [6,] -0.1557108 -0.0010120885 68.28352
#> [7,] -0.1504700 -0.0009224886 56.92566
#> [8,] -0.1408988 -0.0006436047 81.94125
#> [9,] -0.1484119 -0.0006744282 47.25909
#> [10,] -0.1451069 -0.0010573534 48.90999
#>
#> $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.1305556 0.5527778 0.7638889 0.2361111 0.0250000 0.6583333
#> [8] 0.9750000 0.4472222 0.8694444
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -0.9531376 -0.01453544
#> [2,] -0.9957924 -0.01489054
#> [3,] -1.0209085 -0.01504632
#> [4,] -0.8520430 -0.01373584
#> [5,] -0.9289971 -0.01464891
#> [6,] -0.9790085 -0.01835901
#> [7,] -0.9239932 -0.01321764
#> [8,] -0.9250341 -0.01699696
#> [9,] -0.9805313 -0.01651394
#> [10,] -0.8189712 -0.01431127
#>
#> $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.0250000 0.1305556 0.8694444 0.5527778 0.3416667 0.9750000 0.4472222
#> [8] 0.2361111 0.6583333 0.7638889
#>
#>
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.8988161 -0.01430347
#> [2,] -0.9254142 -0.01349646
#> [3,] -0.9113061 -0.01379094
#> [4,] -0.9150069 -0.01177211
#> [5,] -0.9375718 -0.01400269
#> [6,] -1.0781409 -0.01625282
#> [7,] -1.0277161 -0.01676929
#> [8,] -0.9474866 -0.01588833
#> [9,] -0.8908662 -0.01812883
#> [10,] -1.0183984 -0.01326584
#>
#> $coefValues
#> Intercept Total_dist
#> <num> <num>
#> 1: -0.956 -0.015
#>
#> $coefStdErrs
#> Intercept Total_dist
#> <num> <num>
#> 1: 0.0619898 0.001530612
#>