Association Between a Count Response and a Continuous Predictor
Source:R/preference_order_methods.R
f_r2_counts.Rd
These functions take a data frame with a integer counts response "y", and a continuous predictor "x", fit a univariate model, and return the R-squared of observations versus predictions:
f_r2_glm_poisson()
Pearson's R-squared between a count response and the predictions of a GLM model with formulay ~ x
and familystats::poisson(link = "log")
.f_r2_glm_poisson_poly2()
Pearson's R-squared between a count response and the predictions of a GLM model with formulay ~ stats::poly(x, degree = 2, raw = TRUE)
and familystats::poisson(link = "log")
.f_r2_gam_poisson()
Pearson's R-squared between a count response and the predictions of amgcv::gam()
model with formulay ~ s(x)
and familystats::poisson(link = "log")
.f_r2_rpart()
: Pearson's R-squared of a Recursive Partition Tree fitted withrpart::rpart()
with formulay ~ x
.f_r2_rf()
: Pearson's R-squared of a 100 trees Random Forest model fitted withranger::ranger()
and formulay ~ x
.
See also
Other preference_order_functions:
f_auc
,
f_r2
,
f_v()
,
f_v_rf_categorical()
Other preference_order_functions:
f_auc
,
f_r2
,
f_v()
,
f_v_rf_categorical()
Other preference_order_functions:
f_auc
,
f_r2
,
f_v()
,
f_v_rf_categorical()
Other preference_order_functions:
f_auc
,
f_r2
,
f_v()
,
f_v_rf_categorical()
Examples
#load example data
data(vi)
#reduce size to speed-up example
vi <- vi[1:1000, ]
#integer counts response and continuous predictor
#to data frame without NAs
df <- data.frame(
y = vi[["vi_counts"]],
x = vi[["swi_max"]]
) |>
na.omit()
#GLM model with Poisson family
f_r2_glm_poisson(df = df)
#> [1] 0.5263779
#GLM model with second degree polynomials and Poisson family
f_r2_glm_poisson_poly2(df = df)
#> [1] 0.6427394
#GAM model with Poisson family
f_r2_gam_poisson(df = df)
#> [1] 0.6712053