Skip to contents

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. 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. If useQuantiles = 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 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 sampleNationalCoefs a list with elements:

  • "coefSamples": Bootstrapped coefficients with replicates rows

  • "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

Examples

# sample coefficients for default models
getNationalCoefficients(10)
#> $modelVersion
#> [1] "Johnson"
#> 
#> $coefSamples_Survival
#> $coefSamples_Survival$coefSamples
#>        Intercept        Anthro Precision
#>  [1,] -0.1472022 -0.0009701287  68.27143
#>  [2,] -0.1469298 -0.0008191740  56.67486
#>  [3,] -0.1323722 -0.0008254303  63.57567
#>  [4,] -0.1573195 -0.0010439559  66.90766
#>  [5,] -0.1420795 -0.0005661739  58.92620
#>  [6,] -0.1378499 -0.0009381263  64.40734
#>  [7,] -0.1379965 -0.0008793043  56.69350
#>  [8,] -0.1384417 -0.0010318913  50.13912
#>  [9,] -0.1490496 -0.0009440608  68.73313
#> [10,] -0.1288543 -0.0008736138  58.39442
#> 
#> $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.2361111 0.1305556 0.9750000 0.7638889 0.6583333 0.8694444
#>  [8] 0.4472222 0.3416667 0.0250000
#> 
#> 
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#>        Intercept      Anthro Fire_excl_anthro Precision
#>  [1,] -1.0332593 -0.01403263     -0.010688450  22.77596
#>  [2,] -1.0868435 -0.01928253     -0.010915355  22.07115
#>  [3,] -0.9969955 -0.01810371     -0.006814328  21.81325
#>  [4,] -1.0354683 -0.01715699     -0.010030865  16.25115
#>  [5,] -0.9914256 -0.01622221     -0.008057672  21.91212
#>  [6,] -1.0451488 -0.01591948     -0.009941872  20.74802
#>  [7,] -0.9931645 -0.01807802     -0.010437777  22.78916
#>  [8,] -1.0426815 -0.01405399     -0.007293323  16.58941
#>  [9,] -0.9810816 -0.01695382     -0.008815216  19.43274
#> [10,] -0.9025128 -0.01827019     -0.006215156  16.12994
#> 
#> $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.1305556 0.9750000 0.7638889 0.3416667 0.5527778 0.6583333
#>  [8] 0.8694444 0.4472222 0.0250000
#> 
#> 

# 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.1410715 -0.0006397027  68.37837
#>  [2,] -0.1453358 -0.0007650405  71.63434
#>  [3,] -0.1356267 -0.0007067163  51.29347
#>  [4,] -0.1385893 -0.0007193395  74.66866
#>  [5,] -0.1413518 -0.0008737249  63.02043
#>  [6,] -0.1298295 -0.0008208346  60.71739
#>  [7,] -0.1461181 -0.0006669643  62.67577
#>  [8,] -0.1511114 -0.0004960677  53.49181
#>  [9,] -0.1384483 -0.0008490073  62.97938
#> [10,] -0.1460029 -0.0005730540  83.81427
#> 
#> $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.5527778 0.3416667 0.7638889 0.4472222 0.8694444 0.2361111
#>  [8] 0.6583333 0.1305556 0.9750000
#> 
#> 
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#>        Intercept  Total_dist
#>  [1,] -0.9475481 -0.01403615
#>  [2,] -0.9886984 -0.01402129
#>  [3,] -0.9687963 -0.01614093
#>  [4,] -0.9674310 -0.01658129
#>  [5,] -0.9057608 -0.01227179
#>  [6,] -0.9249821 -0.01608848
#>  [7,] -0.9293458 -0.01301454
#>  [8,] -0.8970949 -0.01680380
#>  [9,] -1.0055908 -0.01684102
#> [10,] -0.9228014 -0.01494342
#> 
#> $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.8694444 0.7638889 0.6583333 0.3416667 0.2361111 0.5527778 0.1305556
#>  [8] 0.4472222 0.9750000 0.0250000
#> 
#> 

cfs <- subsetNationalCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")

sampleNationalCoefs(cfs[[1]], 10)
#> $coefSamples
#>        Intercept  Total_dist
#>  [1,] -0.8980031 -0.01519546
#>  [2,] -0.8985087 -0.01617472
#>  [3,] -0.8929614 -0.01555581
#>  [4,] -0.9222301 -0.01742047
#>  [5,] -0.9577172 -0.01692083
#>  [6,] -0.9747707 -0.01284121
#>  [7,] -0.8781646 -0.01543472
#>  [8,] -0.9081156 -0.01450935
#>  [9,] -0.9352212 -0.01512369
#> [10,] -0.9682339 -0.01513684
#> 
#> $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
#>