RePROCESS: PROCESS macro for R – Model 1

I have decided to write an R version of the PROCESS macro for mediation, moderation, and conditional process analysis, which is called RePROCESS.

I will regularly update the package as I add more models and post updates on this blog.

Unlike the SPSS macro, it generates the plots for you, and runs the analyses run at least four times faster! However, I’m not sure how computation time compares to the SAS version.

The development version of the package has now been released and allows you to run Model 1, which is for a single predictor and moderator variable.

Continue reading “RePROCESS: PROCESS macro for R – Model 1”

SF-12 v2 scoring using Australian population weights

Update: This post has been updated to use the dplyr library.

This brief post provides the R syntax to calculate SF-12 v2 scores using Australian population weights. The population weights are derived from:

Hawthorne, G., Osborne, R., Taylor, A., & Sansoni, J. (2007). The SF36 Version 2: critical analyses of population weights, scoring algorithms and population norms. Quality of Life Research, 16(4), 661-673. doi: 10.1007/s11136-006-9154-4

Continue reading “SF-12 v2 scoring using Australian population weights”

Testing R-squared change for linear regression models with heteroscedasticity-consistent standard errors

If you want to test whether the change in R2 is statistically significant for nested linear models with heteroscedasticity-consistent (HC) standard errors (e.g., hierarchical regression), then you can use vcovHC() from the sandwich package and waldtest() from the lmtest package.

Continue reading “Testing R-squared change for linear regression models with heteroscedasticity-consistent standard errors”

Moderation with a multicategorical moderating variable

UPDATE: Please see the following post for an all-in-one solution: RePROCESS Model 1

This post was was inspired by Nicholas Michalak’s Novum R-ganum blog posts on reproducing Hayes’ PROCESS Model 1 in R. He has two posts where he presents the R code for examining a continuous × continuous moderation and a dichotomous × continuous moderation.

However, a quick Google search suggests a paucity of information for conducting moderation analyses using a multicategorical moderating variables.

Therefore, this post will outline how to run the PROCESS Model 1 with a multicategorical moderator (M) in R. We will examine how to code the M variable,  simulate some data, run the PROCESS analyses in both SPSS and R, and compare the results from both software packages.

Continue reading “Moderation with a multicategorical moderating variable”

Bootstrap Mediation Analyses

Below is the R code for conducting mediation analyses using the bootstrap method detailed in Preacher and Hayes (2004). Please note that my function uses the bias corrected and accelarated (BCa) confidence intervals, whereas their SPSS and SAS macros use the bias corrected (BC) confidence intervals. However, they should yield similar results.

Continue reading “Bootstrap Mediation Analyses”

Sample size estimation for balanced randomised control trials

This post presents an R function to implement the sample size estimation presented in Twisk (2013) for continuous outcomes.

Formula 11.1 is used when the researcher wants to compare two groups at one single point in time (e.g., placebo versus treatment at post-intervention), whereas Formula 11.3 is used when there is more than one follow-up measurement and the researcher is interested in comparing the two groups based on the average in the outcome variable over the total follow-up period.

Continue reading “Sample size estimation for balanced randomised control trials”

Analysis of single-case research

I was recently asked to examine some single-case study data and ended up using the method described by Mueser, Yarnold, and Foy (1991). In order to use this method, your data must comprise a minimum of four assessment points at equally spaced intervals (e.g., baseline, 12-weeks, 24-weeks, and 36-weeks).

This method is based on classical test theory and the steps involved are as follows:

  • Calculate ipsative z-scores for the participant
  • Calculate the 1-lag autocorrelation factor
  • Calculate the critical difference (CD)
  • For each assessment point, we calculate the difference between the corresponding z-score and the z-score at baseline.
  • If the absolute value of this difference score is greater than the CD value, then it is statistically significant.

Continue reading “Analysis of single-case research”