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).

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 https://cardiomoon.shinyapps.io/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

50

Version

0.2.6

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

KeonWoong Moon

Last Published

January 7th, 2021

Functions in processR (0.2.6)

adjustNodes

Adjust y position of nodes
addPlus

Add `+` mark to string
addCatVars

Add dummy vars to data.frame
addNodes

Add covariates to nodes
addTripleInteraction

Add triple interaction
addArrows

Add covariates to arrows
addCovarEquation

Add covariates to equation
addLabels

add name to labels
addLatentNodes

Add latent nodes information to nodes
addLine

Add line feed to string
adjustypos

Adjust y position
caskets

CASKETS dataset
bda.mediation.test

The Sobel mediation test
appendLabels

Append labels from vars, moderator and covar
compareMC

Compare effects of mean-centering and standardization of model
checkEquationVars

Check dependent variables in equations
changeLabelName

Change Label Names
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
conceptDiagram

Make conceptDiagram
densityPlot

Draw Smoothed Kernel density plot
deleteSingleNumber

remove coefficent number of equation
compareVIFTable

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

Make data.frame with covariates
countM

Count the group names start with "M"
adjustPosNodes

Adjust position of nodes
catMediation

Make Mediation Equation with one categorical variable
condPlotCat2

Draw direct and indirect effect plot
conceptDiagram2

Make concept Diagram
condPlot

Draw conditional effect plot
drawStatDiagram

draw StatDiagram
drawModel

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

Make arrows from estimatesTable
adjustxpos

Adjust x position
convertPvalue

convert vector of p values to string
centerPrint

Print a string in center
drawArrows

Draw arrows
est2Nodes

Make nodes from estimatesTable
conditionalEffectPlot

Make conditional effect plot
drawCovar

Draw covariate
drawConcept

Draw Concept Diagram
compareVIF

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

Make a table with correlation
corTable2

Make a table with correlation
compareMCTable

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

Disaster dataset
extractLatentVar

Extract Latent Variables Data
drawCatModel

Draw statistical diagram including categorical X
estimatesTable

convert parameterEstimates to data.frame
discriminantValidityTable

make discriminant Validity Table
extractX

Extract group by string
estimatesTable2

convert parameterEstimates to flextable
extractRange

Extract range from a data.frame
fit2table

Make estimateTable with a list of lm object
fit2vif

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

Draw node
extractLatentVarName

Extract Latent Variables Names
discriminantValidityTable2

make discriminant Validity Table in flextable format
divideEquation

divide equation
getMeanSd

get mean and sd
getNodes

Get nodes data with model no
findNames

convert a vector of names with list
findName

convert name with list
ggCor

Draw a heatmap of correlation test
corPlot

Draw correlation plot
getBootData

Get bootstrapped values
getCatSlopeDf

Make data summarizing regression slopes and intercepts
getYhat

Get predicted value from object of class "lm"
education

Data Set for education and income
eq2df

Convert equation to data.frame
get2ndIndirect

get2ndIndirect effect
equations2var

make data.frame with equation
fun2eq

Make equation from function
eq2var

make data.frame with equation
labels2table

Make table with labels
matrixPlot

Draw matrix plot
label2name

Change label into name
getYhat1

Get Yhat value from simple mediation
getCoef

Get coef summary table
getHelmert

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

Get information of a model
extractModerator

Extract name of moderator from string
extractNumber

extract number from string
getArrows

Get arrows data with no
estress

ESTRESS: Economic stress dataset
eq2fit

Make a list of objects of class lm
meanCentering

Perform mean centering
modelsSummary2Table

Make Summary Table 2 for Model Coefficients
modelsSummary2

Make Summary for Model Coefficients
myarrow2

Draw arrow with adjustment of a position
makeIndirectEquation

Make indirect equation
makeEquation3

Make mediation equations 3
glbwarm

Global Warming dataset
extractIMM

extract index of moderated mediation from string
makeAnovaDf

Make data summarizing ANOVA results
makeCEDf

Make data summarizing conditional effects
mycat

append something to file
makeCatEquation

Make equation for sem and lm for categorical variables
makeCatEquation2

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

get slope and intercept with 2 points
makeLabel

Make Labels
modSummary

Make moderation effect summary
mediationBK

Perform mediation analysis by Baron and Kenny Method
makePPTx

make powerpoint presentation
fit2alpha

Make a Cronbach alpha table
interactStr

make interaction equation
fit2df2

Make a data.frame for conceptDiagram
makeEquation1

Make mediation equations 1
makeCoefLabel

Change regression coefficient name
makeEquation

Make mediation equations 3
getRatioTable

Get coding table for dummy variables
makeCatEquation3

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

Get aspect information of a ggplot
getRepValues

Get representative values
modSummary3Table

Make flextable summarizing moderation effect
meanSummary

Make mean summary table
modelFitTable2

Extract model fit measures to flextable
meanSummaryTable

Make mean summary table
modSummary3

Summary of moderation effect
makeCatModel

Make simple regression model with one categorical variable
medSummary

Summarize the mediation effects
moderator2pos

get position from moderator
myarrow

Draw arrow
multipleMediation

Make Mediation Equation with multiple X or multiple Y
pformat

Make p value format
print.meanSummary

S3 method of class meanSummary
print.medSummary

S3 method print for an object of class medSummary
pastecolon

paste two character with colon
modmedEquation

Make moderated mediation equation
print.modmedSummary2

S3 method print for an object of class modmedSummary2
jnPlot

Draw johnson_neyman plot
medSummaryTable

Make a table summarizing the mediation effects
showModels

Run process macro shiny app
regEquation

Make regression equation
pmi

PMI: Presumed Media Influence dataset
print.compareVIF

S3 method of class compareVIF
modelsSummary

Make Summary for Model Coefficients
numberSubscript

Make number subscript
reliabilityTable

make reliability Table
nodes

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

Make flextable summarizing moderation effect
r2diff

Calculate difference of R2 and adjusted R2
r2pptx

Make powerpoint presentation from R file
theme_clean2

Clean theme for ggCor
rightPrint

Print a string in right alignment
productEq

Make products of equations
seekGroup

Find group with variable name
medSummaryTable2

Make a table summarizing the mediation effects
makeEquation2

Make mediation equations 2
medSummaryTable1

Make a table summarizing the mediation effects
standardize

Standardize variable
vars2df

Make data.frame from a list of vars
str_detect2

Extension of str_detect to list
makeIndirectEquationCat

Make indirect equation for categorical variables
treatInteraction

unfold interaction
vif

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

Model fit guide table
makeIndirectEquationCat2

Make indirect equation for categorical variables
moderator2df

Make data.frame from a list of moderator
moreModels

more models data
modelsSummaryTable

Make Summary Table for Model Coefficients
myformat

Format a numeric vector
modmedSummaryTable

Make a table summarizing the moderated mediation
plot.mediationBK

S3 method for class mediationBK
mylm

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

Make data.frame with matrix
matrix2no

Calculate the dimension of matrix
modSummary2

Make table summarizing moderation effect
modSummary2Table

Make flextable summarizing moderation effect
ztable.compareMC

S3 method for class compareMC
tripleInteraction

Make triple interaction equation
str_setdiff

Remove matched pattern from string
unfold

Unfold equations
ztable.modelSummary

S3 method for class 'modelSummary'
p2chr

Convert p values to character
myflatten

flatten string
p2asterisk

Convert p values to asterisk
mycor

Perform correlation and linear regression for a data.frame
modelFitGuideTable2

Model fit guide table
pmacroModel

draw conceptual diagram of process macro model
print.modelSummary

S3 method print for object modelSummary
print.modSummary

S3 method of class modSummary
pmacro

Data Set for process macro model
plotCoef

Make Slopes Plot
protest

Protest dataset
removeParentheses

Remove parentheses
reliabilityTable2

make reliability Table in flextable format
separateEq

Separate equation
qqPlot

Draw quantile-quantile plot
seekVar

Seek var form covariates
statisticalDiagram

Draw statistical diagram
seekNameVars

select names of variables from list var
standardizeDf

standardize data
setPositionNodes

Set Position of nodes
tripleEquation

Make equation with triple interaction
treatModerator

Treat moderator name with mean value
sumEquation

summation of equations
summary.mediationBK

S3 method for class mediationBK
modelFitTable

Extract model fit measures to data.frame
modmedSummary2Table

make table summarizing moderated mediation effect
modmedSummary

Summarize the moderated mediation
parrows

Arrow Data Set for drawing statistical diagram of process macro model
parallelMatrix

Make bmatrix for parallel multiple mediator model
print.medSummary2

S3 method print for an object of class medSummary2
print.modelSummary2

S3 method print for object modelSummary2
print.modmedSummary

S3 method print for an object of class modmedSummary
print.mediationBK

S3 method for class mediationBK
seekGroup1

Find group with variable name
seekGroup2

Find group with variable name
strGrouping

Make Grouping equation
str2vector

Make character vector from string
teams

Teams data set
teachers

Teacher Efficacy Data