Extract and format model coefficients from fitted linear models, including significance levels and standard errors. This is useful for creating tables of trend statistics or identifying significant trends across multiple stations.

pr_get_coeffs(Models, id = "Station")

Arguments

Models

A list of model objects extracted using pr_get_model() from a dataframe that has been processed with pr_model_data()

id

Name for the column containing model identifiers (station names or bioregion names). Default is "Station".

Value

A tibble containing model coefficients with columns:

  • Model identifier column (name specified by id parameter)

  • term - Model term name

  • estimate - Coefficient estimate

  • std.error - Standard error of estimate

  • statistic - t-statistic

  • p.value - P-value

  • signif - Significance indicator (*, **, ***)

Details

The function uses broom::tidy() to extract coefficients from each model and adds significance indicators:

  • *** p ≤ 0.001 (highly significant)

  • ** p ≤ 0.01 (very significant)

  • * p ≤ 0.05 (significant)

  • (blank) p > 0.05 (not significant)

For NRS/LTM data, station codes are automatically added if station names are used as identifiers.

Interpreting Coefficients

  • Year_Local: The rate of change per year (slope). Positive = increasing, negative = decreasing

  • pr_harmonic(Month, k = 1)1: Sine component of seasonal cycle

  • pr_harmonic(Month, k = 1)2: Cosine component of seasonal cycle

  • Intercept: Expected value at Year = 0 (often not interpretable)

The Year_Local coefficient is typically of most interest for detecting long-term trends. Significant harmonic terms indicate a strong seasonal cycle.

See also

pr_model_data() for fitting models, pr_get_model() for extracting model objects

Examples

# Fit models and extract coefficients
df <- planktonr::pr_get_EOVs(Survey = "NRS") %>%
  dplyr::filter(Parameters == "Biomass_mgm3") %>%
  pr_remove_outliers(2) %>%
  pr_model_data()

models <- pr_get_model(df)
coeffs <- pr_get_coeffs(models)

# View only Year trends
coeffs %>% dplyr::filter(term == "Year_Local")
#> # A tibble: 10 × 7
#>    Station                 term      estimate std.error statistic p.value signif
#>    <chr>                   <chr>        <dbl>     <dbl>     <dbl>   <dbl> <chr> 
#>  1 Darwin                  Year_Loc…   2.27      1.18       1.91  5.79e-2 ""    
#>  2 Esperance               Year_Loc…  -0.0779    0.585     -0.133 8.97e-1 ""    
#>  3 Kangaroo Island         Year_Loc…   0.617     0.126      4.90  7.95e-6 "***" 
#>  4 Maria Island            Year_Loc…   0.0571    0.140      0.407 6.84e-1 ""    
#>  5 Ningaloo                Year_Loc…   2.56      4.13       0.620 5.55e-1 ""    
#>  6 North Stradbroke Island Year_Loc…   0.0423    0.0896     0.472 6.38e-1 ""    
#>  7 Port Hacking            Year_Loc…  -0.196     0.141     -1.39  1.67e-1 ""    
#>  8 Rottnest Island         Year_Loc…   0.197     0.102      1.94  5.44e-2 ""    
#>  9 Bonney Coast            Year_Loc…  -8.19      9.55      -0.857 5.49e-1 ""    
#> 10 Yongala                 Year_Loc…   0.264     0.191      1.38  1.69e-1 ""    

# Identify stations with significant trends
coeffs %>% 
  dplyr::filter(term == "Year_Local", signif != "")
#> # A tibble: 1 × 7
#>   Station         term       estimate std.error statistic    p.value signif
#>   <chr>           <chr>         <dbl>     <dbl>     <dbl>      <dbl> <chr> 
#> 1 Kangaroo Island Year_Local    0.617     0.126      4.90 0.00000795 ***