This vignette demonstrates how to compute the Shape AIC for nominal
variables using the shape_aic function from the
nomiShape package. Shape AIC quantifies the goodness-of-fit
of different shape models to the distribution of a nominal variable.
# Example usage of shape_aic
shape_aic(categories, "animal")
#> Shape AIC DeltaAIC
#> 1 Uniform 1198.948 0.00000
#> 2 Triangular 1267.201 68.25385
#> 3 Exponential 1994.144 795.19640
#> 4 Normal 2897.166 1698.21859# Example usage of shape_aic
shape_aic(categories2, "animal")
#> Shape AIC DeltaAIC
#> 1 Triangular 1137.919 0.000000
#> 2 Exponential 1140.017 2.098416
#> 3 Uniform 1198.948 61.028672
#> 4 Normal 1986.456 848.536855# Example usage of shape_aic
shape_aic(categories3, "animal")
#> Shape AIC DeltaAIC
#> 1 Exponential 822.6242 0.0000
#> 2 Normal 961.7948 139.1706
#> 3 Triangular 981.4556 158.8314
#> 4 Uniform 1198.9476 376.3234# Example usage of shape_aic
shape_aic(starwars, "species")
#> Shape AIC DeltaAIC
#> 1 Exponential 555.1934 0.000000
#> 2 Triangular 559.2814 4.088026
#> 3 Uniform 599.4124 44.218957
#> 4 Normal 781.9204 226.727018# approximate rate from top counts
obs <- sort(table(starwars$species), decreasing = TRUE)
ranks <- seq_along(obs)
rate_est <- -coef(lm(log(obs + 1e-6) ~ ranks))[2] # linear fit in log-space
rate_est
#> ranks
#> 0.03724241shape_aic(starwars, "species")
#> Shape AIC DeltaAIC
#> 1 Exponential 555.1934 0.000000
#> 2 Triangular 559.2814 4.088026
#> 3 Uniform 599.4124 44.218957
#> 4 Normal 781.9204 226.727018