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.1453352 -0.0007210705 63.72014
#> [2,] -0.1473837 -0.0005423740 69.62486
#> [3,] -0.1482437 -0.0008272712 72.39114
#> [4,] -0.1280231 -0.0009052976 61.68574
#> [5,] -0.1397141 -0.0008156162 50.69393
#> [6,] -0.1308452 -0.0006850281 45.52158
#> [7,] -0.1583651 -0.0008755280 67.69897
#> [8,] -0.1459811 -0.0009906209 60.83737
#> [9,] -0.1478008 -0.0009825958 47.31376
#> [10,] -0.1360905 -0.0007430011 61.65108
#>
#> $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.4472222 0.7638889 0.8694444 0.9750000 0.6583333
#> [8] 0.5527778 0.1305556 0.2361111
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Anthro Fire_excl_anthro Precision
#> [1,] -0.9938340 -0.01656790 -0.007375357 19.20890
#> [2,] -0.9722727 -0.01750226 -0.009260458 18.93872
#> [3,] -1.0314951 -0.01762293 -0.008821593 17.36374
#> [4,] -1.0583891 -0.01531573 -0.004200913 18.78151
#> [5,] -0.9369486 -0.01819157 -0.008189645 19.78456
#> [6,] -0.9132213 -0.01976578 -0.008680760 21.31301
#> [7,] -1.0851949 -0.01836373 -0.009633775 20.12745
#> [8,] -0.9620740 -0.01772219 -0.007505794 23.25467
#> [9,] -1.0610169 -0.01706086 -0.009310949 16.62016
#> [10,] -1.0178980 -0.01685476 -0.006107319 19.47443
#>
#> $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.9750000 0.5527778 0.0250000 0.3416667 0.7638889 0.1305556
#> [8] 0.6583333 0.8694444 0.4472222
#>
#>
# 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.1323015 -0.0007515289 59.81512
#> [2,] -0.1431649 -0.0009999043 64.00762
#> [3,] -0.1426562 -0.0010056002 75.44278
#> [4,] -0.1432292 -0.0007254387 50.88792
#> [5,] -0.1532945 -0.0007679980 77.42524
#> [6,] -0.1456425 -0.0009115292 74.47883
#> [7,] -0.1596577 -0.0008207631 64.74065
#> [8,] -0.1428434 -0.0007889782 71.92091
#> [9,] -0.1483780 -0.0007923798 64.95162
#> [10,] -0.1435121 -0.0007156552 53.63821
#>
#> $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.7638889 0.2361111 0.5527778 0.0250000 0.1305556 0.8694444
#> [8] 0.6583333 0.9750000 0.3416667
#>
#>
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#> Intercept Total_dist
#> [1,] -1.0079095 -0.01308417
#> [2,] -0.9927748 -0.01575397
#> [3,] -0.9311430 -0.01317155
#> [4,] -0.8989627 -0.01272457
#> [5,] -0.9833175 -0.01713613
#> [6,] -0.9864799 -0.01351076
#> [7,] -0.9670682 -0.01731172
#> [8,] -0.9225740 -0.01679563
#> [9,] -0.9858490 -0.01368674
#> [10,] -0.8256387 -0.01440441
#>
#> $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.5527778 0.8694444 0.6583333 0.7638889 0.4472222 0.1305556 0.2361111
#> [8] 0.3416667 0.0250000 0.9750000
#>
#>
cfs <- subsetNationalCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")
sampleNationalCoefs(cfs[[1]], 10)
#> $coefSamples
#> Intercept Total_dist
#> [1,] -1.0609096 -0.01695619
#> [2,] -0.9396271 -0.01545455
#> [3,] -1.0430414 -0.01687253
#> [4,] -0.9639169 -0.01274949
#> [5,] -0.8635075 -0.01643609
#> [6,] -0.9469428 -0.01355622
#> [7,] -1.0163095 -0.01571717
#> [8,] -0.9467755 -0.01681584
#> [9,] -0.9141551 -0.01331974
#> [10,] -1.0459054 -0.01610858
#>
#> $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
#>