Sample demographic regression model coefficients
Source:R/getNationalCoefficients.R, R/sampleNationalCoefs.R, R/subsetNationalCoefs.R
getNationalCoefficients.RdSelect 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.
getNationalCoefficients is a wrapper around subsetNationalCoefs(), which selects
coefficients and sampleNationalCoefs(), which samples coefficients, for both the
survival and recruitment models.
Usage
getNationalCoefficients(
replicates,
modelVersion = "Johnson",
survivalModelNumber = "M1",
recruitmentModelNumber = "M4",
useQuantiles = TRUE,
populationGrowthTable = popGrowthTableJohnsonECCC
)
sampleNationalCoefs(coefTable, replicates)
subsetNationalCoefs(populationGrowthTable, resVar, modelVersion, modNum)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.
- 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
subsetNationalCoefs()- resVar
character. Response variable, typically "femaleSurvival" or "recruitment"
- modNum
character vector. Which model number(s) to use see popGrowthTableJohnsonECCC for typical options.
Value
For getNationalCoefficients a list with elements:
"modelVersion": The name of the model version
"coefSamples_Survival" and"coefSamples_Recruitment": lists with elements:
"coefSamples": Bootstrapped coefficients with
replicatesrows"coefValues": Coefficient values taken from
populationGrowthTable"quantiles": A vector of randomly selected quantiles between 0.025 and 0.975 with length
replicates
For sampleNationalCoefs a list with elements:
"coefSamples": Bootstrapped coefficients with
replicatesrows"coefValues": Coefficient values taken from
populationGrowthTable
For subsetNationalCoefs: 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
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 estimateNationalRates() 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:
addN0Variation(),
bayesianScenariosWorkflow(),
bayesianTrajectoryWorkflow(),
betaNationalPriors(),
caribouPopGrowth(),
compareTrajectories(),
compositionBiasCorrection(),
convertTrajectories(),
dataFromSheets(),
demographicProjectionApp(),
estimateBayesianRates(),
estimateNationalRate(),
getScenarioDefaults(),
plotCompareTrajectories(),
plotSurvivalSeries(),
plotTrajectories(),
popGrowthTableJohnsonECCC,
simulateObservations(),
trajectoriesFromBayesian(),
trajectoriesFromNational(),
trajectoriesFromSummary(),
trajectoriesFromSummaryForApp()
Examples
# sample coefficients for default models
getNationalCoefficients(10)
#> $modelVersion
#> [1] "Johnson"
#>
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#> Intercept Anthro Precision
#> [1,] -0.1463908 -0.0006594020 67.14983
#> [2,] -0.1382797 -0.0006559971 60.29083
#> [3,] -0.1393394 -0.0009906889 45.29018
#> [4,] -0.1310796 -0.0007299568 49.62064
#> [5,] -0.1428755 -0.0008138035 57.71955
#> [6,] -0.1436199 -0.0007453830 71.52590
#> [7,] -0.1593762 -0.0008583286 60.65321
#> [8,] -0.1471567 -0.0005110905 59.00651
#> [9,] -0.1504714 -0.0006566093 79.57929
#> [10,] -0.1403587 -0.0008010685 69.97941
#>
#> $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.5527778 0.8694444 0.7638889 0.1305556 0.0250000 0.3416667 0.6583333
#> [8] 0.2361111 0.4472222 0.9750000
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro Fire_excl_anthro Precision
#> [1,] -1.0771263 -0.01558446 -0.008853480 20.94079
#> [2,] -1.0532554 -0.01652383 -0.008084726 20.10790
#> [3,] -0.9350379 -0.01353832 -0.011845509 18.54631
#> [4,] -0.9740598 -0.01697338 -0.006378484 18.47285
#> [5,] -1.0410642 -0.01604572 -0.007037944 19.08195
#> [6,] -0.9567975 -0.01686467 -0.006509098 19.75030
#> [7,] -0.9302817 -0.01692861 -0.009443443 19.28813
#> [8,] -0.9504101 -0.01600541 -0.013212479 20.81723
#> [9,] -0.9515109 -0.01590208 -0.007626218 20.93758
#> [10,] -1.0305331 -0.02062188 -0.008649508 19.79830
#>
#> $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.2361111 0.3416667 0.8694444 0.5527778 0.9750000 0.7638889 0.0250000
#> [8] 0.4472222 0.1305556 0.6583333
#>
#>
# try a different model
getNationalCoefficients(10, modelVersion = "Johnson", survivalModelNumber = "M1",
recruitmentModelNumber = "M3")
#> $modelVersion
#> [1] "Johnson"
#>
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#> Intercept Anthro Precision
#> [1,] -0.1377764 -0.0009204942 60.13935
#> [2,] -0.1348472 -0.0006389429 42.75384
#> [3,] -0.1212581 -0.0007483953 56.83476
#> [4,] -0.1536270 -0.0005884652 79.53772
#> [5,] -0.1539443 -0.0007427165 70.44809
#> [6,] -0.1384792 -0.0008100124 61.46737
#> [7,] -0.1429399 -0.0008391658 58.02447
#> [8,] -0.1288998 -0.0009877139 67.00292
#> [9,] -0.1376359 -0.0008363692 66.24340
#> [10,] -0.1389071 -0.0008152766 67.13242
#>
#> $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.0250000 0.6583333 0.1305556 0.4472222 0.7638889 0.9750000
#> [8] 0.8694444 0.2361111 0.5527778
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -0.9767022 -0.01161735
#> [2,] -1.0429083 -0.01085380
#> [3,] -0.9890227 -0.01598237
#> [4,] -0.9473893 -0.01432550
#> [5,] -0.9389702 -0.01400858
#> [6,] -0.9548833 -0.01555431
#> [7,] -1.0272492 -0.01325985
#> [8,] -0.9430757 -0.01452017
#> [9,] -0.9831684 -0.01383130
#> [10,] -0.9282868 -0.01614122
#>
#> $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.9750000 0.2361111 0.0250000 0.1305556 0.5527778 0.6583333 0.4472222
#> [8] 0.8694444 0.3416667 0.7638889
#>
#>
cfs <- subsetNationalCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")
sampleNationalCoefs(cfs[[1]], 10)
#> $coefSamples
#> Intercept Total_dist
#> [1,] -0.8787975 -0.01471032
#> [2,] -0.8439524 -0.01655607
#> [3,] -0.8211231 -0.01757973
#> [4,] -0.9584311 -0.01441397
#> [5,] -1.0239912 -0.01426505
#> [6,] -0.8936541 -0.01740971
#> [7,] -0.9225058 -0.01413450
#> [8,] -0.8580849 -0.01637382
#> [9,] -0.9852073 -0.01488279
#> [10,] -0.9000968 -0.01572517
#>
#> $coefValues
#> Intercept Total_dist
#> <num> <num>
#> 1: -0.956 -0.015
#>
#> $coefStdErrs
#> Intercept Total_dist
#> <num> <num>
#> 1: 0.0619898 0.001530612
#>
subsetNationalCoefs(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
#>