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:
bayesianScenariosWorkflow(),
bayesianTrajectoryWorkflow(),
betaNationalPriors(),
caribouPopGrowth(),
compareTrajectories(),
compositionBiasCorrection(),
convertTrajectories(),
dataFromSheets(),
demographicProjectionApp(),
demographyDefaults(),
disturbanceDefaults(),
estimateBayesianRates(),
estimateNationalRate(),
getScenarioDefaults(),
monitoringDefaults(),
nationalTrajectoryDefaults(),
plotCompareTrajectories(),
plotSurvivalSeries(),
plotTrajectories(),
popGrowthTableJohnsonECCC,
simulateObservations(),
timeDefaults(),
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.1628418 -0.0008575427 63.70226
#> [2,] -0.1509012 -0.0006965204 69.51780
#> [3,] -0.1351682 -0.0009563004 64.17198
#> [4,] -0.1436065 -0.0007124144 72.92578
#> [5,] -0.1483595 -0.0008493398 51.72799
#> [6,] -0.1622561 -0.0007593232 59.57174
#> [7,] -0.1526208 -0.0008042221 56.63785
#> [8,] -0.1451219 -0.0011198489 67.85582
#> [9,] -0.1477934 -0.0007611648 57.99822
#> [10,] -0.1470173 -0.0007410262 59.63421
#>
#> $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.1305556 0.8694444 0.9750000 0.4472222 0.6583333 0.3416667
#> [8] 0.2361111 0.7638889 0.0250000
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro Fire_excl_anthro Precision
#> [1,] -1.0521363 -0.01753745 -0.005625995 20.72120
#> [2,] -0.9577237 -0.01626065 -0.011627139 21.37973
#> [3,] -1.0383450 -0.01426171 -0.006817813 19.85325
#> [4,] -0.9895442 -0.01454410 -0.007010106 22.07628
#> [5,] -0.9839861 -0.01683662 -0.010340598 18.15098
#> [6,] -1.0165307 -0.01711541 -0.010190822 18.93360
#> [7,] -1.0247730 -0.01657281 -0.006141538 19.74671
#> [8,] -1.0595903 -0.01644229 -0.008597131 21.49523
#> [9,] -1.0561684 -0.01675843 -0.006556276 21.44018
#> [10,] -1.0961644 -0.01543853 -0.004985479 15.64913
#>
#> $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.5527778 0.9750000 0.3416667 0.4472222 0.1305556 0.7638889 0.2361111
#> [8] 0.6583333 0.0250000 0.8694444
#>
#>
# 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.1254340 -0.0007199660 49.12892
#> [2,] -0.1487624 -0.0007511073 59.68286
#> [3,] -0.1517141 -0.0008383841 77.06746
#> [4,] -0.1270605 -0.0009067014 83.57118
#> [5,] -0.1399792 -0.0007976345 51.56020
#> [6,] -0.1425090 -0.0008331491 67.44312
#> [7,] -0.1418231 -0.0006977259 76.34615
#> [8,] -0.1485342 -0.0008030285 62.71765
#> [9,] -0.1392352 -0.0009231098 67.06173
#> [10,] -0.1403059 -0.0006726058 59.82742
#>
#> $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.0250000 0.2361111 0.8694444 0.7638889 0.9750000 0.3416667 0.6583333
#> [8] 0.4472222 0.1305556 0.5527778
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -1.0179285 -0.01685174
#> [2,] -0.9510655 -0.01674760
#> [3,] -0.9538000 -0.01378705
#> [4,] -0.9670359 -0.01336060
#> [5,] -0.9463361 -0.01212140
#> [6,] -0.9928634 -0.01315047
#> [7,] -1.0117745 -0.01385015
#> [8,] -0.9648691 -0.01376552
#> [9,] -1.0269050 -0.01400982
#> [10,] -0.9258763 -0.01485310
#>
#> $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.2361111 0.8694444 0.4472222 0.7638889 0.3416667 0.5527778 0.1305556
#> [8] 0.0250000 0.9750000 0.6583333
#>
#>
cfs <- subsetNationalCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")
sampleNationalCoefs(cfs[[1]], 10)
#> $coefSamples
#> Intercept Total_dist
#> [1,] -0.9734603 -0.01354884
#> [2,] -0.9601535 -0.01465737
#> [3,] -0.9261674 -0.01463926
#> [4,] -1.0777365 -0.01518621
#> [5,] -0.9463894 -0.01685955
#> [6,] -0.9506953 -0.01767048
#> [7,] -0.9312783 -0.01280973
#> [8,] -1.0153388 -0.01454879
#> [9,] -0.9839651 -0.01445689
#> [10,] -1.0232801 -0.01434276
#>
#> $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
#>