Learn R Programming

⚠️There's a newer version (0.2.7) of this package.Take me there.

R package processR

The processR package aims to be a user-friendly way to perform moderation, mediation, moderated mediation and moderated moderation in R. This package is inspired from famous PROCESS macro for SPSS and SAS created by Andrew Hayes.

processR is under the GPL-3 license. For a commercial license, please [contact me](mailto: cardiomoon@gmail.com).

If you find processR useful, please consider supporting its development!

PROCESS macro and R package processR

Andrew F. Hayes was not involved in the development of this R package or application and cannot attest to the quality of the computations implemented in the code you are using. Use at your own risk.

Installation

You can install the processR package from github.

if(!require(devtools)) install.packages("devtools")
devtools::install_github("cardiomoon/processR")

What does this package cover ?

The processR package covers moderation, mediation, moderated mediation and moderated moderation with R. Supporting models are as follows.

library(processR)
sort(pmacro$no)
 [1]  0.0  1.0  2.0  3.0  4.0  4.2  5.0  6.0  6.3  6.4  7.0  8.0  9.0 10.0
[15] 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0
[29] 28.0 29.0 30.0 31.0 35.0 36.0 40.0 41.0 45.0 49.0 50.0 58.0 59.0 60.0
[43] 61.0 62.0 63.0 64.0 65.0 66.0 67.0 74.0 75.0 76.0

Currently, 52 models are supported.

Example: Moderated Mediation (PROCESS macro model 8)

I will explain functions of processR package by a example.

Concept Diagram and Statistical Diagram

You can draw concept diagram and statistical diagram easily. For example, you can draw the concept diagram for PROCESS macro model 8.

pmacroModel(8)

You can draw statistical diagram of this model.

statisticalDiagram(8)

Full vignette

You can see full vignette for model 8 at http://rpubs.com/cardiomoon/468602

Shiny App

I have developed a shiny app. You can test the app at http://web-r.space:3838/processR. I will appreciate any comment.

How to perform this analysis with shiny app

You can see how to perform this analysis at http://rpubs.com/cardiomoon/468600

Sample powerpoint file

In the shiny app, you can download the analysis results as a powerpoint file. You can download the sample file model8.pptx - view with office web viewer.

Copy Link

Version

Install

install.packages('processR')

Monthly Downloads

53

Version

0.2.3

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

KeonWoong Moon

Last Published

January 27th, 2020

Functions in processR (0.2.3)

addTripleInteraction

Add triple interaction
addCovarEquation

Add covariates to equation
addArrows

Add covariates to arrows
adjustNodes

Adjust y position of nodes
addCatVars

Add dummy vars to data.frame
addNodes

Add covariates to nodes
addLine

Add line feed to string
addPlus

Add `+` mark to string
addLatentNodes

Add latent nodes information to nodes
changeLabelName

Change Label Names
bda.mediation.test

The Sobel mediation test
conceptDiagram2

Make concept Diagram
countM

Count the group names start with "M"
condPlot

Draw conditional effect plot
covar2df

Make data.frame with covariates
caskets

CASKETS dataset
addLabels

add name to labels
adjustypos

Adjust y position
appendLabels

Append labels from vars, moderator and covar
adjustPosNodes

Adjust position of nodes
catMediation

Make Mediation Equation with one categorical variable
drawArrows

Draw arrows
condPlot2

Draw conditional plot for moderated moderation
condPlotCat

Make conditional effect plot with data including a categorical variable
checkEqVars

Check dependent variables in a equation
adjustxpos

Adjust x position
checkEquationVars

Check dependent variables in equations
deleteSingleNumber

remove coefficent number of equation
compareMC

Compare effects of mean-centering and standardization of model
convertPvalue

convert vector of p values to string
corPlot

Draw correlation plot
centerPrint

Print a string in center
densityPlot

Draw Smoothed Kernel density plot
compareVIFTable

Make table comparing correlation, tolerance, vif of mean-centered and standardized models
est2Nodes

Make nodes from estimatesTable
findName

convert name with list
get2ndIndirect

get2ndIndirect effect
drawStatDiagram

draw StatDiagram
fun2eq

Make equation from function
findNames

convert a vector of names with list
est2Arrows

Make arrows from estimatesTable
drawModel

Draw statistical diagram with an object of class lavaan or a list of class lm
drawConcept

Draw Concept Diagram
compareMCTable

Make table comparing effects of mean-centering and standardization of model
drawCovar

Draw covariate
condPlotCat2

Draw direct and indirect effect plot
conceptDiagram

Make conceptDiagram
extractNumber

extract number from string
equations2var

make data.frame with equation
discriminantValidityTable

make discriminant Validity Table
extractModerator

Extract name of moderator from string
eq2var

make data.frame with equation
conditionalEffectPlot

Make conditional effect plot
disaster

Disaster dataset
fit2alpha

Make a Cronbach alpha table
compareVIF

Compare correlation, tolerance, vif of mean-centered and standardized models
corTable

Make a table with correlation
fit2df2

Make a data.frame for conceptDiagram
makeEquation

Make mediation equations 3
makeCatEquation2

Make equation for sem and lm for multiple X or multiple Y
matrix2no

Calculate the dimension of matrix
getInfo

Get information of a model
makeCatEquation

Make equation for sem and lm for categorical variables
makeCoefLabel

Change regression coefficient name
matrix2df

Make data.frame with matrix
getHelmert

Get Helmert Coding of column j of group with length of unique values (count-1)
drawCatModel

Draw statistical diagram including categorical X
corTable2

Make a table with correlation
modSummary3

Summary of moderation effect
extractLatentVarName

Extract Latent Variables Names
eq2fit

Make a list of objects of class lm
eq2df

Convert equation to data.frame
getArrows

Get arrows data with no
extractLatentVar

Extract Latent Variables Data
getEq2p

get slope and intercept with 2 points
makeCEDf

Make data summarizing conditional effects
makeAnovaDf

Make data summarizing ANOVA results
getCoef

Get coef summary table
discriminantValidityTable2

make discriminant Validity Table in flextable format
makeEquation3

Make mediation equations 3
drawtext

Draw node
education

Data Set for education and income
divideEquation

divide equation
extractRange

Extract range from a data.frame
makeIndirectEquation

Make indirect equation
modelsSummaryTable

Make Summary Table for Model Coefficients
moderator2df

Make data.frame from a list of moderator
modSummary3Table

Make flextable summarizing moderation effect
multipleMediation

Make Mediation Equation with multiple X or multiple Y
meanSummary

Make mean summary table
getAspectRatio

Get aspect information of a ggplot
getMeanSd

get mean and sd
meanSummaryTable

Make mean summary table
extractIMM

extract index of moderated mediation from string
estimatesTable2

convert parameterEstimates to flextable
fit2table

Make estimateTable with a list of lm object
estimatesTable

convert parameterEstimates to data.frame
estress

ESTRESS: Economic stress dataset
medSummaryTable1

Make a table summarizing the mediation effects
medSummaryTable2

Make a table summarizing the mediation effects
modelsSummary2Table

Make Summary Table 2 for Model Coefficients
fit2vif

Summarizing correlation, tolerance and variance inflation factors of a model
myarrow2

Draw arrow with adjustment of a position
modelsSummary2

Make Summary for Model Coefficients
extractX

Extract group by string
getBootData

Get bootstrapped values
getRatioTable

Get coding table for dummy variables
getCatSlopeDf

Make data summarizing regression slopes and intercepts
getYhat

Get predicted value from object of class "lm"
getRepValues

Get representative values
glbwarm

Global Warming dataset
makeIndirectEquationCat2

Make indirect equation for categorical variables
makeIndirectEquationCat

Make indirect equation for categorical variables
makeLabel

Make Labels
ggCor

Draw a heatmap of correlation test
label2name

Change label into name
labels2table

Make table with labels
getYhat1

Get Yhat value from simple mediation
getNodes

Get nodes data with model no
interactStr

make interaction equation
myarrow

Draw arrow
meanCentering

Perform mean centering
makeEquation2

Make mediation equations 2
matrixPlot

Draw matrix plot
makeEquation1

Make mediation equations 1
moderator2pos

get position from moderator
modSummary

Make moderation effect summary
modmedEquation

Make moderated mediation equation
mediationBK

Perform mediation analysis by Baron and Kenny Method
p2asterisk

Convert p values to asterisk
jnPlot

Draw johnson_neyman plot
makePPTx

make powerpoint presentation
modSummary2Table

Make flextable summarizing moderation effect
modSummary2

Make table summarizing moderation effect
modelFitGuideTable2

Model fit guide table
p2chr

Convert p values to character
r2pptx

Make powerpoint presentation from R file
print.medSummary

S3 method print for an object of class medSummary
r2diff

Calculate difference of R2 and adjusted R2
print.meanSummary

S3 method of class meanSummary
makeCatEquation3

Make equation for sem and lm for multiple X or multiple Y
modelFitTable

Extract model fit measures to data.frame
modmedSummary2Table

make table summarizing moderated mediation effect
mylm

Correlation and Fitting linear model function for function "mycor"
modmedSummary

Summarize the moderated mediation
myformat

Format a numeric vector
mycat

append something to file
print.mediationBK

S3 method for class mediationBK
parallelMatrix

Make bmatrix for parallel multiple mediator model
parrows

Arrow Data Set for drawing statistical diagram of process macro model
print.medSummary2

S3 method print for an object of class medSummary2
protest

Protest dataset
myflatten

flatten string
seekGroup1

Find group with variable name
mycor

Perform correlation and linear regression for a data.frame
makeCatModel

Make simple regression model with one categorical variable
nodes

Node Data Set for drawing statistical diagram of process macro model
numberSubscript

Make number subscript
showModels

Run process macro shiny app
standardize

Standardize variable
seekGroup2

Find group with variable name
medSummary

Summarize the mediation effects
modSummaryTable

Make flextable summarizing moderation effect
modelFitGuideTable

Model fit guide table
medSummaryTable

Make a table summarizing the mediation effects
plot.mediationBK

S3 method for class mediationBK
modelFitTable2

Extract model fit measures to flextable
regEquation

Make regression equation
print.modelSummary2

S3 method print for object modelSummary2
print.modmedSummary

S3 method print for an object of class modmedSummary
plotCoef

Make Slopes Plot
qqPlot

Draw quantile-quantile plot
pmacro

Data Set for process macro model
str2vector

Make character vector from string
strGrouping

Make Grouping equation
reliabilityTable

make reliability Table
reliabilityTable2

make reliability Table in flextable format
summary.mediationBK

S3 method for class mediationBK
sumEquation

summation of equations
pastecolon

paste two character with colon
modelsSummary

Make Summary for Model Coefficients
moreModels

more models data
modmedSummaryTable

Make a table summarizing the moderated mediation
pformat

Make p value format
print.compareVIF

S3 method of class compareVIF
tripleInteraction

Make triple interaction equation
pmi

PMI: Presumed Media Influence dataset
print.modelSummary

S3 method print for object modelSummary
removeParentheses

Remove parentheses
pmacroModel

draw conceptual diagram of process macro model
rightPrint

Print a string in right alignment
print.modmedSummary2

S3 method print for an object of class modmedSummary2
str_detect2

Extension of str_detect to list
seekGroup

Find group with variable name
str_setdiff

Remove matched pattern from string
productEq

Make products of equations
theme_clean2

Clean theme for ggCor
treatInteraction

unfold interaction
seekNameVars

select names of variables from list var
unfold

Unfold equations
standardizeDf

standardize data
seekVar

Seek var form covariates
ztable.modelSummary

S3 method for class 'modelSummary'
ztable.compareMC

S3 method for class compareMC
separateEq

Separate equation
setPositionNodes

Set Position of nodes
vif

Variance Inflation Factors Calculates variance-inflation and generalized variance-inflation factors for linear, generalized linear, and other models.
vars2df

Make data.frame from a list of vars
teachers

Teacher Efficacy Data
teams

Teams data set
statisticalDiagram

Draw statistical diagram
treatModerator

Treat moderator name with mean value
tripleEquation

Make equation with triple interaction
print.modSummary

S3 method of class modSummary