Functions to do fast regression modelling. The functions return a tibble::tibble with statistics. Use plot() for an extensive model visualisation.
regression(x, ...)
# Default S3 method
regression(x, y = NULL, type = "lm", family = stats::gaussian, ...)
# S3 method for class 'data.frame'
regression(x, var1, var2 = NULL, type = "lm", family = stats::gaussian, ...)
# S3 method for class 'certestats_reg'
plot(x, ...)
# S3 method for class 'certestats_reg'
autoplot(object, ...)runif(10) |> regression()
#> # A tibble: 2 × 5
#> term estimate std.error statistic p.value
#> * <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 3.49 1.92 1.81 0.107
#> 2 x 3.71 3.10 1.20 0.266
data.frame(x = 1:50, y = runif(50)) |>
regression(x, y)
#> # A tibble: 2 × 5
#> term estimate std.error statistic p.value
#> * <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 0.555 0.0778 7.13 0.00000000463
#> 2 x -0.00153 0.00266 -0.577 0.567
mrsa_from_blood_years <- c(0, 1, 0, 0, 2, 0, 1, 3, 1, 2, 3, 1, 2)
mrsa_from_blood_years |> plot()
mrsa_from_blood_years |> regression()
#> # A tibble: 2 × 5
#> term estimate std.error statistic p.value
#> * <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 4.33 1.38 3.14 0.00946
#> 2 x 2.17 0.854 2.54 0.0277
mrsa_from_blood_years |> regression() |> plot()
#> Warning: `fortify(<lm>)` was deprecated in ggplot2 3.6.0.
#> ℹ Please use `broom::augment(<lm>)` instead.
#> ℹ The deprecated feature was likely used in the ggplot2 package.
#> Please report the issue at <https://github.com/tidyverse/ggplot2/issues>.
#> `geom_smooth()` using formula = 'y ~ x'