regMixR2

regMixR2 R function description:

This function reads in regression mixture parameter estimates and outputs all relevant R2 measures and decompositions. That is, when Equation (1) or (2) (see Rights & Sterba, in press) is fit, R2’s in Table 1a and decompositions in Table 3 are outputted. When Equation (7) is fit, R2’s in Table 1b and decompositions in Table 4 and 5 are outputted. Additionally, barcharts for total R2 (and decompositions) and level-2 R2 (and decompositions) are produced, as in Figures 4, 7, and 8.

Any number of level-1 and/or level-2 classes is supported (including the special case of K=1, a multilevel mixture with classes only at level-2, or H=1, a single-level mixture). When fitting a multilevel mixture with classes at levels 1 and 2, if the number of level-1 classes differs across h (as described in manuscript Footnote 15), a researcher can constrain all parameters equal across class-combinations within any h (e.g., if there are K=3 level-1 classes, constraining two of these equal within h effectively yields Kh =2). Parameter estimates should still be entered as described below, which would involve entering all constrained parameters as though they were belonging to separate classes.

Rights, J.D., & Sterba, S.K. (in press). A framework of R-squared measures for single-level and multilevel regression mixture models. Psychological Methods.

regMixR2 input description:

data – Data set with rows denoting observations and columns denoting variables.

covariate.cols – List of numbers corresponding to the columns in the data set that represent the predictors used in the regression model

H – Number of level-2 classes.

K – Number of level-1 classes.

intslopes –  Vector of coefficient estimates for all class-combination-specific (or class-specific) intercepts and all class-combination-specific slopes, to be entered in the following order: (1) all intercepts going in order of increasing k (level-1 class) then increasing h (level-2 class) (e.g., k=1,h=1; k=2,h=1; k=1,h=2; k=2,h=2); (2) all slopes for each class-combination (classes increasing as in (1)), e.g., xslope1_k1h1, xslope2_k1h1, xslope1_k2h1, xslope2_k2h1, etc.) If coefficients are constrained equal across certain classes, then the same estimates would be entered for those classes.

resvar – Vector of class-combination-specific (or class-specific) residual variance estimates (entered in the order of classes described in intslopes above)

mcwi – Vector of level-1 class multinomial intercept estimates, entered in order of increasing k, with 0 entered for K

mcws – Vector of multinomial slopes of k on h estimates (entered in the order of classes described in intslopes above, with 0 entered for every k=K and h=H)

mcbi – Vector of level-2 class multinomial intercept estimates, entered in order of increasing h, with 0 entered for H

regMixR2 R function code and example input:

regMixR2

Back Home