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.1330317 -0.0008489290  70.20672
#>  [2,] -0.1378015 -0.0009079068  62.22941
#>  [3,] -0.1376536 -0.0008840756  71.06320
#>  [4,] -0.1390130 -0.0005198582  63.03838
#>  [5,] -0.1509526 -0.0007331234  52.70341
#>  [6,] -0.1309739 -0.0007135738  65.43974
#>  [7,] -0.1408477 -0.0006438041  56.53945
#>  [8,] -0.1222765 -0.0006925408  80.03158
#>  [9,] -0.1487246 -0.0010608499  76.35739
#> [10,] -0.1469242 -0.0008345755  61.32497
#> 
#> $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.7638889 0.4472222 0.1305556 0.0250000 0.5527778 0.2361111
#>  [8] 0.8694444 0.6583333 0.9750000
#> 
#> 
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#>        Intercept      Anthro Fire_excl_anthro Precision
#>  [1,] -1.0138674 -0.01344516     -0.005623360  22.71409
#>  [2,] -1.1525134 -0.01484544     -0.006619803  19.76321
#>  [3,] -0.9793367 -0.01434372     -0.009403108  19.86349
#>  [4,] -0.9985666 -0.01826040     -0.010117518  20.61306
#>  [5,] -1.1296412 -0.01400262     -0.007831363  19.02762
#>  [6,] -1.0281048 -0.01807832     -0.008416914  20.67364
#>  [7,] -1.0436287 -0.01761566     -0.009942404  17.92777
#>  [8,] -1.0056569 -0.01400106     -0.006544974  20.24022
#>  [9,] -1.0512436 -0.01827552     -0.005005475  20.41033
#> [10,] -1.1202650 -0.01916557     -0.010315193  21.24218
#> 
#> $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.1305556 0.0250000 0.7638889 0.6583333 0.9750000 0.2361111
#>  [8] 0.5527778 0.3416667 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.1390620 -0.0007076800  72.91193
#>  [2,] -0.1483526 -0.0007807486  59.39384
#>  [3,] -0.1385161 -0.0009006851  60.28719
#>  [4,] -0.1282235 -0.0008973394  72.63551
#>  [5,] -0.1453215 -0.0006698346  59.93373
#>  [6,] -0.1417223 -0.0006482176  69.02820
#>  [7,] -0.1411384 -0.0008813321  67.77512
#>  [8,] -0.1437593 -0.0006712399  53.92498
#>  [9,] -0.1467292 -0.0008263383  73.15575
#> [10,] -0.1441684 -0.0007843594  65.29381
#> 
#> $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.2361111 0.1305556 0.9750000 0.6583333
#>  [8] 0.5527778 0.4472222 0.0250000
#> 
#> 
#> $coefSamples_Recruitment
#> $coefSamples_Recruitment$coefSamples
#>        Intercept  Total_dist
#>  [1,] -0.9276058 -0.01594136
#>  [2,] -0.9401023 -0.01733362
#>  [3,] -0.8958036 -0.01447962
#>  [4,] -1.0170804 -0.01575788
#>  [5,] -0.9242645 -0.01491721
#>  [6,] -1.0243856 -0.01588889
#>  [7,] -0.9968908 -0.01499644
#>  [8,] -0.9675003 -0.01683957
#>  [9,] -0.9997856 -0.01816528
#> [10,] -0.9706238 -0.01150629
#> 
#> $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.7638889 0.6583333 0.0250000 0.3416667 0.5527778 0.9750000 0.4472222
#>  [8] 0.8694444 0.2361111 0.1305556
#> 
#> 

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

sampleNationalCoefs(cfs[[1]], 10)
#> $coefSamples
#>        Intercept  Total_dist
#>  [1,] -0.9560495 -0.01590803
#>  [2,] -0.9777139 -0.01402601
#>  [3,] -0.9781208 -0.01504766
#>  [4,] -0.9259985 -0.01581897
#>  [5,] -1.0281292 -0.01580508
#>  [6,] -0.9624736 -0.01341013
#>  [7,] -0.9225039 -0.01384992
#>  [8,] -0.9610157 -0.01715434
#>  [9,] -0.9603943 -0.01448038
#> [10,] -0.9386900 -0.01462183
#> 
#> $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
#>