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”

Free step-down re-sampling adjustment for multiple testing in linear regression

This brief post presents a function to implement the free step-down re-sampling p-value adjustment for multiple-testing for regression models. It is an adaptation of the R code presented in Foulkes (2009, pp. 114-119), but it implements the minP method in addition to the maxT method.

Continue reading “Free step-down re-sampling adjustment for multiple testing in linear regression”

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”

Promoting an open research culture

You may have guessed from my last post that I am an advocate for transparency, openness, and reproducibility in research. Part of this involves making data and code publically available.

Nosek and colleagues (2015) published an article in Science outlining the Transparency and Openness Promotion (TOP) guidelines and is well worth a read.

It is available from Science or, if you don’t have access to Science, it’s available from ResearchGate.

Nosek, B.A., Alter, G., Banks, G.C., Borsboom, D., Bowman, S.D., Breckler, S.J., . . . Yarkoni, T. (2015). Promoting an open research culture. Science, 348, 1422-1425. doi: 10.1126/science.aab2374

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”