Plotting marginal effects of a binary logistic regression

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotting marginal effects of a binary logistic regression

Christen, Ramon
This post was updated on .
Hi everyone

using spss 17.0 i'd like to do a binary logistic regression with an interaction term. to illustrate the results, a plot with the marginal effects would be helpful. this way it is not only possible to see the coefficients for certain values of the interaction variables (normaly the minimum, center and maximum), but for the entire range include its confidence intervalls. i found several examples from people who did this with stata (e.g. here ). unfortunately i don't know stata very well and that's why i wanted to ask you, whether this is also possible in spss.
in case you should need some more information about the data set etc. please ask.
thanks for your help.
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Plotting marginal effects of a binary logistic regression

Looman, Wendy

I am out of the office until Tuesday, September 4, 2012. If you need assistance prior to September 4th, please contact: David M. Bass, Vice President for Research, Benjamin Rose Institute on Aging, Margaret Blenkner Research Institute, 11900 Fairhill Road, #300, Cleveland, OH 44120-1053. Phone: 216-373-1664. Email: [hidden email]

 

 

-----------------------------------------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: The documents accompanying this email may contain confidential information, which is legally privileged. This information is intended only for the use of the recipient named above. If you are not the addressee or the employee or agent of the intended recipient, you are hereby notified that you are strictly prohibited from printing, storing, disseminating, distributing, or copying this communication. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer.
-----------------------------------------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Plotting marginal effects of a binary logistic regression

Maguin, Eugene
In reply to this post by Christen, Ramon
Zir,

Two problems to solve, right? Building the plot dataset and writing the plot code, which I assume you'll use GPL. Probably you already know this but marginal effects are the partial derivatives. If you can find a copy of Regression Models for Categorical and Limited Dependent Variables, the author, J. Scott Long, discusses marginal effects on pages 71-75. But he does not illustrate the computation of confidence intervals for those effects. Probably other high level books on logistic regression, such as Hosmer and Lemeshow,  probably also discuss marginal effects. Another thing to do is to try to get the Stata code used; no doubt there are people on this list who also use Stata and could easily translate it to Spss code.

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ZirFulgore
Sent: Thursday, August 30, 2012 5:08 AM
To: [hidden email]
Subject: Plotting marginal effects of a binary logistic regression

Hi everyone

using spss 17.0 i'd like to do a binary logistic regression with an interaction term. to illustrate the results, a plot with the marginal effects would be helpful. this way it is not only possible to see the coefficients for certain values of the interaction variables (normaly the minimum, cetner and maximum), but for the entire range include its confidence intervalls. i found several examples from people who did this with stata (e.g.
http://img.springerimages.com/Images/Springer/PUB%3DSpringer_US-Boston/JOU%3D11109/VOL%3D2006.28/ISU%3D3/ART%3D2006_9009/MediaObjects/WATER_11109_2006_9009_Fig2_HTML.jpg
here  ). unfortunately i don't know stata very well and that's why i wanted to ask you, whether this is also possible in spss.
in case you should need some more information about the data set etc. please ask.
thanks for your help.



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effects-of-a-binary-logistic-regression-tp5714906.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Plotting marginal effects of a binary logistic regression

Bruce Weaver
Administrator
Alternatively, I think you could get a pretty good approximation of that plot by running your model via GENLIN (with a logit link & binomial error distribution), and saving MEANPRED, CIMEANPREDL and CIMEANPREDU.  To get the full range of X-axis values you want, you might have to add some dummy cases to the working data file that have all the desired combinations of predictor variables, but nothing for the outcome variable.  If GENLIN works like other procedures, the cases where Y is missing will still have saved values of MEANPRED etc, but they will be generated using the model computed from the cases with complete data.  Make sure your dummy cases have a filter variable so you can pick them out afterwards and use them for making your graph.  (If you include enough dummy cases with small enough differences in the X-axis variable, you'll get something pretty close to the graph you showed).  

HTH.


Maguin, Eugene wrote
Zir,

Two problems to solve, right? Building the plot dataset and writing the plot code, which I assume you'll use GPL. Probably you already know this but marginal effects are the partial derivatives. If you can find a copy of Regression Models for Categorical and Limited Dependent Variables, the author, J. Scott Long, discusses marginal effects on pages 71-75. But he does not illustrate the computation of confidence intervals for those effects. Probably other high level books on logistic regression, such as Hosmer and Lemeshow,  probably also discuss marginal effects. Another thing to do is to try to get the Stata code used; no doubt there are people on this list who also use Stata and could easily translate it to Spss code.

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ZirFulgore
Sent: Thursday, August 30, 2012 5:08 AM
To: [hidden email]
Subject: Plotting marginal effects of a binary logistic regression

Hi everyone

using spss 17.0 i'd like to do a binary logistic regression with an interaction term. to illustrate the results, a plot with the marginal effects would be helpful. this way it is not only possible to see the coefficients for certain values of the interaction variables (normaly the minimum, cetner and maximum), but for the entire range include its confidence intervalls. i found several examples from people who did this with stata (e.g.
http://img.springerimages.com/Images/Springer/PUB%3DSpringer_US-Boston/JOU%3D11109/VOL%3D2006.28/ISU%3D3/ART%3D2006_9009/MediaObjects/WATER_11109_2006_9009_Fig2_HTML.jpg
here  ). unfortunately i don't know stata very well and that's why i wanted to ask you, whether this is also possible in spss.
in case you should need some more information about the data set etc. please ask.
thanks for your help.



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effects-of-a-binary-logistic-regression-tp5714906.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Plotting marginal effects of a binary logistic regression

Maguin, Eugene
Bruce, following your suggestion (adding cases with missing DV values was astute) to Zir, I looked at the Genlin command, which I have not used, and I wonder if you would correct me if I am not understanding what a couple of the possible save variables are. There's
XBPRED (varname | rootname:n).Predicted value(s) of the linear predictor.
XBSTDERROR (varname | rootname:n).Estimated standard error(s) of the predicted value
of the linear predictor.

The phrasing of the description seems odd to me but I'm understanding  XBPRED as the predicted value of the DV for each case and XBSTDERROR to be the standard error of the predicted value for each case. Thus, I'd guess that the SEs will be different for each set of unique IV values. Have I got all this right?

Thanks, Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Thursday, August 30, 2012 9:56 AM
To: [hidden email]
Subject: Re: Plotting marginal effects of a binary logistic regression

Alternatively, I think you could get a pretty good approximation of that plot by running your model via GENLIN (with a logit link & binomial error distribution), and saving MEANPRED, CIMEANPREDL and CIMEANPREDU.  To get the full range of X-axis values you want, you might have to add some dummy cases to the working data file that have all the desired combinations of predictor variables, but nothing for the outcome variable.  If GENLIN works like other procedures, the cases where Y is missing will still have saved values of MEANPRED etc, but they will be generated using the model computed from the cases with complete data.  Make sure your dummy cases have a filter variable so you can pick them out afterwards and use them for making your graph.  (If you include enough dummy cases with small enough differences in the X-axis variable, you'll get something pretty close to the graph you showed).

HTH.



Maguin, Eugene wrote

>
> Zir,
>
> Two problems to solve, right? Building the plot dataset and writing
> the plot code, which I assume you'll use GPL. Probably you already
> know this but marginal effects are the partial derivatives. If you can
> find a copy of Regression Models for Categorical and Limited Dependent
> Variables, the author, J. Scott Long, discusses marginal effects on
> pages 71-75. But he does not illustrate the computation of confidence
> intervals for those effects. Probably other high level books on
> logistic regression, such as Hosmer and Lemeshow,  probably also
> discuss marginal effects. Another thing to do is to try to get the
> Stata code used; no doubt there are people on this list who also use
> Stata and could easily translate it to Spss code.
>
> Gene Maguin
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@.UGA] On Behalf Of
> ZirFulgore
> Sent: Thursday, August 30, 2012 5:08 AM
> To: SPSSX-L@.UGA
> Subject: Plotting marginal effects of a binary logistic regression
>
> Hi everyone
>
> using spss 17.0 i'd like to do a binary logistic regression with an
> interaction term. to illustrate the results, a plot with the marginal
> effects would be helpful. this way it is not only possible to see the
> coefficients for certain values of the interaction variables (normaly
> the minimum, cetner and maximum), but for the entire range include its
> confidence intervalls. i found several examples from people who did
> this with stata (e.g.
> http://img.springerimages.com/Images/Springer/PUB%3DSpringer_US-Boston
> /JOU%3D11109/VOL%3D2006.28/ISU%3D3/ART%3D2006_9009/MediaObjects/WATER_
> 11109_2006_9009_Fig2_HTML.jpg here  ). unfortunately i don't know
> stata very well and that's why i wanted to ask you, whether this is
> also possible in spss.
> in case you should need some more information about the data set etc.
> please ask.
> thanks for your help.
>
>
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effect
> s-of-a-binary-logistic-regression-tp5714906.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the command.
> To leave the list, send the command SIGNOFF SPSSX-L For a list of
> commands to manage subscriptions, send the command INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the command.
> To leave the list, send the command SIGNOFF SPSSX-L For a list of
> commands to manage subscriptions, send the command INFO REFCARD
>




-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effects-of-a-binary-logistic-regression-tp5714906p5714909.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Plotting marginal effects of a binary logistic regression

Bruce Weaver
Administrator
Hi Gene.  I've not taken the time (yet) to try to understand what XBPRED and XBSTDERROR are all about, and I agree that the descriptions are a bit odd.  

I suggested MEANPRED because for a model with logit link and binomial error distribution, it saves the predicted probability.  Note that by default, you'll get the predicted probability that Y = 0, because by default (for GENLIN) the last category is the referent.  If Y is coded 0-1, most folks want the 0 as the referent, so you have to include a REFERENCE = FIRST in the GENLIN command.  (This is noted in the help.)

Finally, my preference is to display the predicted values of Y not as predicted probabilities, but on the log-odds scale.  On the log-odds scale, things that are linear in the model appear linear, etc.  It's easy enough to throw in 3 COMPUTES to convert MEANPRED and the two confidence limits.

HTH.


Maguin, Eugene wrote
Bruce, following your suggestion (adding cases with missing DV values was astute) to Zir, I looked at the Genlin command, which I have not used, and I wonder if you would correct me if I am not understanding what a couple of the possible save variables are. There's
XBPRED (varname | rootname:n).Predicted value(s) of the linear predictor.
XBSTDERROR (varname | rootname:n).Estimated standard error(s) of the predicted value
of the linear predictor.

The phrasing of the description seems odd to me but I'm understanding  XBPRED as the predicted value of the DV for each case and XBSTDERROR to be the standard error of the predicted value for each case. Thus, I'd guess that the SEs will be different for each set of unique IV values. Have I got all this right?

Thanks, Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Thursday, August 30, 2012 9:56 AM
To: [hidden email]
Subject: Re: Plotting marginal effects of a binary logistic regression

Alternatively, I think you could get a pretty good approximation of that plot by running your model via GENLIN (with a logit link & binomial error distribution), and saving MEANPRED, CIMEANPREDL and CIMEANPREDU.  To get the full range of X-axis values you want, you might have to add some dummy cases to the working data file that have all the desired combinations of predictor variables, but nothing for the outcome variable.  If GENLIN works like other procedures, the cases where Y is missing will still have saved values of MEANPRED etc, but they will be generated using the model computed from the cases with complete data.  Make sure your dummy cases have a filter variable so you can pick them out afterwards and use them for making your graph.  (If you include enough dummy cases with small enough differences in the X-axis variable, you'll get something pretty close to the graph you showed).

HTH.



Maguin, Eugene wrote
>
> Zir,
>
> Two problems to solve, right? Building the plot dataset and writing
> the plot code, which I assume you'll use GPL. Probably you already
> know this but marginal effects are the partial derivatives. If you can
> find a copy of Regression Models for Categorical and Limited Dependent
> Variables, the author, J. Scott Long, discusses marginal effects on
> pages 71-75. But he does not illustrate the computation of confidence
> intervals for those effects. Probably other high level books on
> logistic regression, such as Hosmer and Lemeshow,  probably also
> discuss marginal effects. Another thing to do is to try to get the
> Stata code used; no doubt there are people on this list who also use
> Stata and could easily translate it to Spss code.
>
> Gene Maguin
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@.UGA] On Behalf Of
> ZirFulgore
> Sent: Thursday, August 30, 2012 5:08 AM
> To: SPSSX-L@.UGA
> Subject: Plotting marginal effects of a binary logistic regression
>
> Hi everyone
>
> using spss 17.0 i'd like to do a binary logistic regression with an
> interaction term. to illustrate the results, a plot with the marginal
> effects would be helpful. this way it is not only possible to see the
> coefficients for certain values of the interaction variables (normaly
> the minimum, cetner and maximum), but for the entire range include its
> confidence intervalls. i found several examples from people who did
> this with stata (e.g.
> http://img.springerimages.com/Images/Springer/PUB%3DSpringer_US-Boston
> /JOU%3D11109/VOL%3D2006.28/ISU%3D3/ART%3D2006_9009/MediaObjects/WATER_
> 11109_2006_9009_Fig2_HTML.jpg here  ). unfortunately i don't know
> stata very well and that's why i wanted to ask you, whether this is
> also possible in spss.
> in case you should need some more information about the data set etc.
> please ask.
> thanks for your help.
>
>
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effect
> s-of-a-binary-logistic-regression-tp5714906.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the command.
> To leave the list, send the command SIGNOFF SPSSX-L For a list of
> commands to manage subscriptions, send the command INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the command.
> To leave the list, send the command SIGNOFF SPSSX-L For a list of
> commands to manage subscriptions, send the command INFO REFCARD
>




-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Plotting-marginal-effects-of-a-binary-logistic-regression-tp5714906p5714909.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Plotting marginal effects of a binary logistic regression

Christen, Ramon
In reply to this post by Christen, Ramon
Thanks to everyone for your contribution. The problem could finally be solved by drawing on to the following literature: Hosmer/Lemeshow, 2000. So if anyone would do something similar, this will help (see esp. page 85 ff.)