Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graph of coefficients and intercepts at different levels of moderating variable

    Dear Statalist Users,
    I am reaching out to seek for some advice and help on how to plot conditional effects of x on y at different values of moderator.

    I am estimating a simple OLS regression with DV, IV a MODERATOR (with interaction term) and 4 COVARIATES. I cluster as observations are nested into groups.
    All variables are continuous except cov3.
    reg y = x mod int_term cov1 cov2 cov3 cov4, clusted(org)

    The coefficient on the interaction term - is positive and stat significant.
    It supports my intuition that the main substantive relationship between x and y is attenuated at increasing levels of MOD.

    I would like to graph this relationship into two ways:

    First, by showing the change in slope of x-> y relationship at different levels of MOD (say 25th, 50th and 75th percentile of MOD).
    This would be something like y on y-axis and x on the x-axis with three (or more) lines plotting the relationship.

    An illustration below from Pollack et al (2012, J of Org Behavior)

    Click image for larger version

Name:	Screen Shot 2018-08-02 at 10.01.08.png
Views:	1
Size:	80.4 KB
ID:	1456226

    Second, I would like to plot regions of significance for the main relationship (x->y) at different levels of MOD.
    An example is below
    Click image for larger version

Name:	Screen Shot 2018-08-02 at 10.01.19.png
Views:	1
Size:	111.0 KB
ID:	1456227


    I have found instructions and done it in the following way:

    * working on the graph of the moderation effect*
    reg y x MOD cov1 cov2 cov3 cov4, cluster(org_id)
    summ MOD
    local very_low = r(mean) - 2*r(sd)
    local low = r(mean) - r(sd)
    local medium = r(mean)
    local high = r(mean) + r(sd)
    local very_high = r(mean) + 2*r(sd)
    margins, at(MOD = (`very_low' `low' `medium' `high' `very_high'))
    marginsplot

    or by specifying meaningful values for MOD

    reg y x MOD cov1 cov2 cov3 cov4, cluster(org_id)
    margins, at(MOD = (5.333333 5.805556 6.033333))
    marginsplot

    I do not quite get what I want.

    Sorry for the lengthy post

    Amedeo

  • #2
    Code:
    reg y x MOD cov1 cov2 cov3 cov4, cluster(org_id)
    is not appropriate for use with -margins-. You must use factor variable notation in your regression in order for -margins- to work. Without that, -margins- has no idea that you are even doing an interaction model. Moreover, in your -margins- command you will need to specify values for both x and MOD to get the kind of plot you are seeking. (Otherwise you just get average marginal effects for MOD, which don't distinguish how things work at different values of x).

    What you need is:

    Code:
    reg y c.x##c.MOD cov1 cov2 cov3 cov4, cluster(org_id)
    margins x, at(MOD = (whatever_seems_appropriate_here) x = (appropriate_values_of_x))
    marginsplot
    You can customize the appearance of the graph by adding any options available with -graph twoway- to your -marginsplot- command. I'm not sure whether -marginsplot- will put MOD on the horizontal axis and give you graphs by values of x or the other way around. You can control this with the -xdimension()- option of -marginsplot-. Do read -help marginsplot-. And to get a better understanding of the -margins- command, I recommend the excellent Richard Williams' https://www3.nd.edu/~rwilliam/stats/Margins01.pdf.

    Comment

    Working...
    X