regrrr v0.1.1

0

Monthly downloads

0th

Percentile

Toolkit for Compiling, (Post-Hoc) Testing, and Plotting Regression Results

Compiling regression results into a publishable format, conducting post-hoc hypothesis testing, and plotting moderating effects (the effect of X on Y becomes stronger/weaker as Z increases).

Readme

regrrr (Toolkit for Compiling and Plotting Regression Results)

Rdoc

Description

Compiling regression results into a publishable format, conducting post-hoc hypothesis testing, and plotting moderating effects (the effect of X on Y becomes stronger/weaker as Z increases).

Installation

To install from CRAN:

install.packages("regrrr")
library(regrrr)

You can also use devtools to install the latest development version:

devtools::install_github("raykyang/regrrr")
library(regrrr)

Examples

# build regression models using mtcars dataset
data(mtcars)
m0 <- lm(mpg ~ vs + carb + hp + wt, data = mtcars)
m1 <- update(m0, . ~ . + wt * hp)
m2 <- update(m1, . ~ . + wt * vs)
# compile the correlation table
cor.table(data = m2$model)
# compile the regression table
regression_table <- rbind(
combine_long_tab(to_long_tab(summary(m0)$coef),
                 to_long_tab(summary(m1)$coef),
                 to_long_tab(summary(m2)$coef)),
compare_models(m0, m1, m2))
rownames(regression_table) <- NULL
print(regression_table)
# plot the moderating effect
plot_effect(reg.coef = summary(m2)$coefficients, data = mtcars, model = m2,
            x_var.name = "wt", y_var.name = "mpg", moderator.name = "hp",
            confidence_interval = TRUE,  CI_Ribbon = FALSE, 
            xlab = "Weight", ylab = "MPG", moderator.lab = "Horsepower") +
ggplot2::theme(text=ggplot2::element_text(family="Times New Roman", size = 16))

Functions in regrrr

Name Description
compare_models Compare regression models, which is compatible with the reg.table output # updated 9/13/2018 #
combine_long_tab Combine regression results from different models by columns
add.n.r Add row numbers to regression result data.frame
regrrr regrrr: a toolkit for compiling regression results
plot_effect plotting the marginal effect of X on Y, with or without one or multiple interaction terms
add.pr Add approximate p-value based on t score or z score, when sample size is large
check_na_in quickly check the proportion of NAs in each columns of a dataframe
check_vif quickly check the vifs in a regression model; for checking multi-collinearity
scale_01 Scale a vector into the 0-1 scale
test_tilted_slopes significance of regression slope (the marginal effect) under moderation testing restriction: the sig. of beta_x under the moderation of z1, with or without additional interaction terms (z2, z3, etc.)
to_long_tab Convert the regression result to the long format: the standard errors are in parentheses and beneath the betas
test_coef_equality testing equality of two coefficients (difference between coefficients of regressors), a Wald test note: if v is not alternatively specified, use car::linearHypothesis(lm_model, "X1 = X2")
add.sig Add significance level marks to the regression result
cor.table make the correlation matrix from the data.frame used in regression
load.pkgs load multiple packages
check_cor quickly check correlation matrix, or the correlation between a particular X and all other vars could be useful for looking for relevant instrument
No Results!

Last month downloads

Details

Type Package
License GPL-3
Encoding UTF-8
LazyData true
RoxygenNote 7.0.2
BugReports https://github.com/RayKYang/regrrr/issues
NeedsCompilation no
Packaged 2020-02-02 21:14:05 UTC; ray_mac
Repository CRAN
Date/Publication 2020-02-02 21:30:02 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/regrrr)](http://www.rdocumentation.org/packages/regrrr)