simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

Estimate simple intercepts in probe2WayMC #127

Closed mronkko closed 1 year ago

mronkko commented 1 year ago

probe2WayMC currently calculates simple intercepts only if factor means are estimated. I do not think that this is desirable. The simple intercepts are calculated as

b_0 + b_2 Z, where Z are the values of the moderator provided by the user.

If factor means are not estimated, the absolute position of the plot on the X and Y axes does not mean anything. However, the relative positions of the curves still provides useful information.

TDJorgensen commented 1 year ago

I have to agree, but I can understand why Sunthud made the $SimpleIntcept element NULL when the y-intercept is not estimated. It is because there is no element in vcov(fit) corresponding to the fixed parameter Y~1, so there is no basis for testing a H_0 about simple intercepts. Intercepts are also essentially fixed, conditional on other values of the moderator, but their model-implied values are obviously not all zero.

So I agree probe*Way*C() should still populate the $SimpleIntcept element with the model-implied simple intercepts, although the SEs and z tests can be omitted. That would resolve the issue with plotProbe() setting every line's origin at zero. Today I'll look for how to make that happen.

TDJorgensen commented 1 year ago

From the NEWS file:

Simple intercepts are now always returned by probe2WayMC(), probe2WayRC(), probe3WayMC(), and probe3WayRC(), even when the y-intercept is fixed in the fitted model. This is not actually a bug, but the old default behavior led to plotProbe() incorrectly plotting all regression lines through the origin (see https://github.com/simsem/semTools/issues/125 and https://github.com/simsem/semTools/issues/127).

Let me know if you notice anything that still needs fixing.