Linear Mixed Model Sample Size Calculations

I have created a Shiny app to calculate the required sample size for a two-group linear mixed model.

It uses the power.mmrm function from the longpower package (see Lu, Luo, & Chen, 2008, for more information).

The input is simplified, whereby users are limited to five time-points, the correlation matrix is a compound symmetry correlation structure that is identical for both groups, and the attrition rate is assumed to be the same for both groups.

Shiny App

https://sammancuso.shinyapps.io/power/

Power Screenshot Continue reading “Linear Mixed Model Sample Size Calculations”

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”