Hi – I will really appreciate any thoughts here. I expect (hope) to produce a plot that looks something like the attached.
I have been attempting variations of two approaches (where x1 is my continuous IV and x2 is my nonnegative integer moderator).
The first approach is to graph three qfit lines onto the same plot:
nbreg y c.x1##c.x1 c.x1##c.x2 …
predict yhat, xb … {which plots fitted values at the means}
*in theory I would create three fitted values for yhat at the three values of x2 I want to graph. And from there generate the qfit plot. Yet I'm not sure about this because predict does not allow the ‘at’ option and I haven’t found a workaround.
The second approach is marginsplot:
nbreg y c.x1##c.x1 c.x1##c.x2 …
margins, dydx(x1) at(x2 =0 0.33 1.31)
marginsplot
*I am getting the following error for this (even though I have specified x2 as a factor variable)
variable '0.33' not found in list of covariates
(The issue is complicated slightly because x2 is positively skewed. Therefore, instead of using + and – SD points, I am using min, mean, and mean +SD.)
Huge thanks in advance for any feedback!
I have been attempting variations of two approaches (where x1 is my continuous IV and x2 is my nonnegative integer moderator).
The first approach is to graph three qfit lines onto the same plot:
nbreg y c.x1##c.x1 c.x1##c.x2 …
predict yhat, xb … {which plots fitted values at the means}
*in theory I would create three fitted values for yhat at the three values of x2 I want to graph. And from there generate the qfit plot. Yet I'm not sure about this because predict does not allow the ‘at’ option and I haven’t found a workaround.
The second approach is marginsplot:
nbreg y c.x1##c.x1 c.x1##c.x2 …
margins, dydx(x1) at(x2 =0 0.33 1.31)
marginsplot
*I am getting the following error for this (even though I have specified x2 as a factor variable)
variable '0.33' not found in list of covariates
(The issue is complicated slightly because x2 is positively skewed. Therefore, instead of using + and – SD points, I am using min, mean, and mean +SD.)
Huge thanks in advance for any feedback!
Comment