calc_stat_scores {halk}R Documentation

Compute test statistics for comparing actual and estimated ages

Description

Using these functions you can compute either a Kolmogorov-Smirnov (KS) statistic or a Chi-squared test statistic to compare estimated ages to actual ages. See details for how each test works and what is reported.

Usage

calc_ks_score(
  data,
  summary_fun = mean,
  age_col = "age",
  suppress_warnings = TRUE,
  return_val = "statistic",
  ...
)

calc_chi_score(
  data,
  age_col = "age",
  suppress_warnings = TRUE,
  return_val = "statistic",
  ...
)

Arguments

data

A data.frame containing estimated ages as returned by assign_ages

summary_fun

Function used to compute summary statistics for calc_ks_score for each age group (default is mean)

age_col

Character string specifying the name of the age column

suppress_warnings

Logical. Should any warnings from the function call to ks.test or chisq.test be suppressed (TRUE, the default)

return_val

Character. The name of the object to return from the given test

...

Additional arguments to pass to summary_fun (calc_ks_score) or chisq.test (calc_chi_score)

Details

The KS test compares length distributions for each age class from known ages against that of estimated ages computed by the assign_ages function. The output is a summary value of the test statistics as specified by summary_fun.

The calc_chi_score function performs a Chi-square test (using the chisq.test function) on the number of estimated and actual ages for each age group.

Value

A numeric value for each level that was used in the model to assign ages

Examples

halk <- make_halk(spp_data, levels = c("spp"))
newdat <- laa_data
newdat$spp <- "bluegill"
pred_ages <- assign_ages(newdat, halk)
calc_ks_score(pred_ages)
calc_chi_score(pred_ages)

[Package halk version 0.0.5 Index]