R/grouped_slr.R
grouped_slr.Rd
Running simple linear regression (slr) on multiple variables across multiple grouping variables.
grouped_slr(data, dep.vars, indep.vars, grouping.vars)
data | Dataframe from which variables are to be taken. |
---|---|
dep.vars | List criterion or dependent variables for simple linear
model ( |
indep.vars | List predictor or independent variables for simple
linear model ( |
grouping.vars | List of grouping variables. |
A tibble dataframe with tidy results from simple linear regression
analyses. The estimates are standardized, i.e. the lm
model used is
scale(y) ~ scale(x)
, and not y ~ x
.
# for reproducibility set.seed(123) # in case of just one grouping variable groupedstats::grouped_slr( data = iris, dep.vars = c(Sepal.Length, Petal.Length), indep.vars = c(Sepal.Width, Petal.Width), grouping.vars = Species )#> # A tibble: 6 x 9 #> Species formula t.value estimate conf.low conf.high std.error p.value #> <fct> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 setosa Sepal.Length… 7.68 0.743 0.548 0.937 0.0967 6.71e-10 #> 2 versicol… Sepal.Length… 4.28 0.526 0.279 0.773 0.123 8.77e- 5 #> 3 virginica Sepal.Length… 3.56 0.457 0.199 0.715 0.128 8.43e- 4 #> 4 setosa Petal.Length… 2.44 0.332 0.0578 0.605 0.136 1.86e- 2 #> 5 versicol… Petal.Length… 8.83 0.787 0.607 0.966 0.0891 1.27e-11 #> 6 virginica Petal.Length… 2.36 0.322 0.0474 0.597 0.137 2.25e- 2 #> # … with 1 more variable: significance <chr>