f_r2 {collinear}R Documentation

Association Between a Continuous Response and a Continuous Predictor

Description

These functions take a data frame with two numeric continuous columns "x" (predictor) and "y" (response), fit a univariate model, and return the R-squared of the observations versus the model predictions:

Usage

f_r2_pearson(df)

f_r2_spearman(df)

f_r2_glm_gaussian(df)

f_r2_glm_gaussian_poly2(df)

f_r2_gam_gaussian(df)

f_r2_rpart(df)

f_r2_rf(df)

Arguments

df

(required, data frame) with columns:

  • "x": (numeric) continuous predictor.

  • "y" (numeric) continuous response.

Value

numeric: R-squared

See Also

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Other preference_order_functions: f_auc, f_r2_counts, f_v(), f_v_rf_categorical()

Examples


data(vi)

#reduce size to speed-up example
vi <- vi[1:1000, ]

#numeric response and predictor
#to data frame without NAs
df <- data.frame(
  y = vi[["vi_numeric"]],
  x = vi[["swi_max"]]
) |>
  na.omit()

# Continuous response

#Pearson R-squared
f_r2_pearson(df = df)

#Spearman R-squared
f_r2_spearman(df = df)

#R-squared of a gaussian gam
f_r2_glm_gaussian(df = df)

#gaussian glm with second-degree polynomials
f_r2_glm_gaussian_poly2(df = df)

#R-squared of a gaussian gam
f_r2_gam_gaussian(df = df)

#recursive partition tree
f_r2_rpart(df = df)

#random forest model
f_r2_rf(df = df)

#load example data
data(vi)

#reduce size to speed-up example
vi <- vi[1:1000, ]

#continuous response and predictor
#to data frame without NAs
df <- data.frame(
  y = vi[["vi_numeric"]],
  x = vi[["swi_max"]]
) |>
  na.omit()

# Continuous response

#Pearson R-squared
f_r2_pearson(df = df)

#Spearman R-squared
f_r2_spearman(df = df)

#R-squared of a gaussian gam
f_r2_glm_gaussian(df = df)

#gaussian glm with second-degree polynomials
f_r2_glm_gaussian_poly2(df = df)

#R-squared of a gaussian gam
f_r2_gam_gaussian(df = df)

#recursive partition tree
f_r2_rpart(df = df)

#random forest model
f_r2_rf(df = df)


[Package collinear version 2.0.0 Index]