The "margins" command in Stata allows one to plot the estimated effect of a variable X1 on an outcome Y for several values of a variable X2, in a model including a X1∗X2 interaction. Not only: it also permits the creation of a table with theestimated effects of X1 for multiple values of X2. This holds even when both variables are continuous:
https://stats.oarc.ucla.edu/stata/faq/how-can-i-understand-a-continuous-by-continuous-interaction-in-logistic-regression-stata-12/particular, by writing: /EMMEANS=TABLES(X1
Can anything like that be done with SPSS? The great majority of the online sources I found about SPSS relate to interactions between categorical variables. I found some examples involving one continuous variable, through the "emmeans" options. In
) WITH(X2=K), where k is a specific value, one can see the estimated effect of X1 for that value of X2to interaction between categorical variables.
(see, for example, the penultimate row and last command line here: https://www.theanalysisfactor.com/why-report-estimated-marginal-means-in-spss-glm/
/EMMEANS=TABLES(X) WITH(V=50)) . Does one have to write one command line for each value of X2 for which one wants to estimated effect of X1 on Y? Also, is there any way to graph this? The great majority of the online sources I found about SPSS relate
Hi Federico. AFAIK, there is no way in SPSS that is nearly as easy as -margins- and -marginsplot- in Stata. However, using NOMREG with a bunch of TEST sub-commands, I can duplicate the contrasts you get from -margins-, but with one caveat. Bear in mindthat when you use -margins- after -logit-, the default is to display predicted probabilities. If you want log-odds, you need to add the option predict(xb). I.e., try this:
margins, dydx(r) at(m=(30(5)70)) vsquish predict(xb)sub-command. But when you compare the table of coefficients to the table from Stata, you'll see that it estimates the same model.
Now the "slopes" that you see are on the log-odds scale, and look like this:
--------------------------------------
| Delta-method
| dy/dx std. err.
-------------+------------------------
r |
_at |
1 | .2405485 .0965139
2 | .2071807 .0807686
3 | .173813 .0653655
4 | .1404453 .0506178
5 | .1070776 .0373113
6 | .0737099 .0276142
7 | .0403421 .02595
8 | .0069744 .0335367
9 | -.0263933 .046005
--------------------------------------
I can reproduce those contrasts in SPSS using the NOMREG command to estimate the model with a a TEST sub-command, as follows. I used NOMREG because LOGISTIC REGRESSION and GENLIN, other commands you could use to estimate the model, do not have a TEST
NOMREG y (BASE=LAST ORDER=DESCENDING) WITH r mable to suggest less cumbersome approaches, but I will be surprised if any of them are as straightforward as -margins- and -marginsplot- in Stata.
/MODEL r m r*m
/INTERCEPT=INCLUDE
/PRINT=PARAMETER SUMMARY LRT CPS STEP MFI
/TEST "Intercept"
ALL 1 0 0 0
/TEST "B for simple effect of r"
ALL 0 1 0 0
/TEST "B for simple effect of m"
ALL 0 0 1 0
/TEST "B for r*m"
ALL 0 0 0 1
/TEST "r-slopes for m=30(5)70"
ALL 0 1 0 30;
ALL 0 1 0 35;
ALL 0 1 0 40;
ALL 0 1 0 45;
ALL 0 1 0 50;
ALL 0 1 0 55;
ALL 0 1 0 60;
ALL 0 1 0 65;
ALL 0 1 0 70
.
I included the 4 TEST sub-commands to demonstrate that I could reproduce the coefficients and SEs shown in the table of coefficients. The final TEST sub-command duplicates the 9 contrasts from Stata shown above. Here are is the relevant SPSS output:
Est SE Wald df Sig. Exp(B) Lower Upper
C1 .241 .097 6.212 1 .013 1.272 1.053 1.537
C2 .207 .081 6.580 1 .010 1.230 1.050 1.441
C3 .174 .065 7.071 1 .008 1.190 1.047 1.352
C4 .140 .051 7.699 1 .006 1.151 1.042 1.271
C5 .107 .037 8.236 1 .004 1.113 1.035 1.197
C6 .074 .028 7.125 1 .008 1.076 1.020 1.136
C7 .040 .026 2.417 1 .120 1.041 .990 1.095
C8 .007 .034 .043 1 .835 1.007 .943 1.075
C9 -.026 .046 .329 1 .566 .974 .890 1.066
To make those results accessible for graphing, you could use OMS to write the relevant tables to a new dataset, etc. But as you can already see, that is a fairly cumbersome process compared to using -margins- and -marginsplot- in Stata. Others may be
HTH.estimated effects of X1 for multiple values of X2. This holds even when both variables are continuous:
On Friday, February 24, 2023 at 8:49:00 AM UTC-5, federico tedeschi wrote:
The "margins" command in Stata allows one to plot the estimated effect of a variable X1 on an outcome Y for several values of a variable X2, in a model including a X1∗X2 interaction. Not only: it also permits the creation of a table with the
particular, by writing: /EMMEANS=TABLES(X1https://stats.oarc.ucla.edu/stata/faq/how-can-i-understand-a-continuous-by-continuous-interaction-in-logistic-regression-stata-12/
Can anything like that be done with SPSS? The great majority of the online sources I found about SPSS relate to interactions between categorical variables. I found some examples involving one continuous variable, through the "emmeans" options. In
to interaction between categorical variables.) WITH(X2=K), where k is a specific value, one can see the estimated effect of X1 for that value of X2
(see, for example, the penultimate row and last command line here: https://www.theanalysisfactor.com/why-report-estimated-marginal-means-in-spss-glm/
/EMMEANS=TABLES(X) WITH(V=50)) . Does one have to write one command line for each value of X2 for which one wants to estimated effect of X1 on Y? Also, is there any way to graph this? The great majority of the online sources I found about SPSS relate
Thank you very much, Bruce.
Are things easier in case the outcome is continuous?
Federico
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 468 |
Nodes: | 16 (2 / 14) |
Uptime: | 35:32:00 |
Calls: | 9,444 |
Calls today: | 1 |
Files: | 13,594 |
Messages: | 6,111,304 |