Running simple linear regression (slr) on multiple variables across multiple grouping variables.

grouped_slr(data, dep.vars, indep.vars, grouping.vars)

Arguments

data

Dataframe from which variables are to be taken.

dep.vars

List criterion or dependent variables for simple linear model (y in y ~ x).

indep.vars

List predictor or independent variables for simple linear model (x in y ~ x).

grouping.vars

List of grouping variables.

Value

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.

See also

Examples

# 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 #> <fct> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 setosa Sepal.Length ~ Sepal.Width 7.68 0.743 0.548 0.937 #> 2 versicolor Sepal.Length ~ Sepal.Width 4.28 0.526 0.279 0.773 #> 3 virginica Sepal.Length ~ Sepal.Width 3.56 0.457 0.199 0.715 #> 4 setosa Petal.Length ~ Petal.Width 2.44 0.332 0.0578 0.605 #> 5 versicolor Petal.Length ~ Petal.Width 8.83 0.787 0.607 0.966 #> 6 virginica Petal.Length ~ Petal.Width 2.36 0.322 0.0474 0.597 #> std.error p.value significance #> <dbl> <dbl> <chr> #> 1 0.0967 6.71e-10 *** #> 2 0.123 8.77e- 5 *** #> 3 0.128 8.43e- 4 *** #> 4 0.136 1.86e- 2 * #> 5 0.0891 1.27e-11 *** #> 6 0.137 2.25e- 2 *