linearity of independent variables to log odds

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

linearity of independent variables to log odds

mllx4eg5
Hi,

I keep getting an error message
>Warning # 602
>The argument for the natural log function is less than or equal to zero.
The
>result has been set to the system-missing value.

when I run this syntax:
COMPUTE sexshun_LN=LN(sexshun)
EXECUTE.

How can I fix this?

(Sexshun is a binary variable)

thanks for any help



--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: linearity of independent variables to log odds

Rich Ulrich
Don't ever transform a binary variable. 
 - Unless it is a linear transformation, like adding 1 (0,1 becomes 1,2)
or deciding to center it (0,1 becomes -1, 1); or multiplying by a
constant (probably, to change the scale of the regression coefficient).

The message tells you that you can't take the log of zero. This time,
the incidental error saves you from the embarrassment of trying to
explain to someone else WHY you took the log of a binary variable.

--
Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of mllx4eg5 <[hidden email]>
Sent: Sunday, September 15, 2019 3:37 PM
To: [hidden email] <[hidden email]>
Subject: linearity of independent variables to log odds
 
Hi,

I keep getting an error message
>Warning # 602
>The argument for the natural log function is less than or equal to zero.
The
>result has been set to the system-missing value.

when I run this syntax:
COMPUTE sexshun_LN=LN(sexshun)
EXECUTE.

How can I fix this?

(Sexshun is a binary variable)

thanks for any help



--
Sent from: http://spssx-discussion.1045642.n5.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: linearity of independent variables to log odds

mllx4eg5
Thankyou,
So all I need to do is recode the varible to (1,2) instead of (0,1)?




--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: linearity of independent variables to log odds

Bruce Weaver
Administrator
What is your objection to 0/1 coding?  

It would also be helpful if you provided more context.  What kind of model
are you estimating?  (You mentioned log odds, so I suspect it is logistic
regression, but you've not said.)  What is the outcome variable?  What are
the explanatory variables?  Why do you think you need to transform the
variable you are asking about?  

Thanks for clarifying.  



mllx4eg5 wrote

> Thankyou,
> So all I need to do is recode the varible to (1,2) instead of (0,1)?
>
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.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





-----
--
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.

--
Sent from: http://spssx-discussion.1045642.n5.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
--
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: linearity of independent variables to log odds

Ryan
I think the OP wants to take the natural log of a binary DV to evaluate the linearity assumption in the context of binary logistic regression. That’s not the way to evaluate linearity, and it’s mathematically impossible to take the natural log when values = zero.

Assuming there is only one explanatory variable which happens to be continuous, one quick and dirty approach would be to create bins of the continuous explanatory variable, refit the binary logistic regression model with the new categorical explanatory variable, output the predicted values on the log-odds scale, and then plot the original continuous explanatory variable against the predicted log-odds.

Ryan

Sent from my iPhone

> On Sep 15, 2019, at 9:48 PM, Bruce Weaver <[hidden email]> wrote:
>
> What is your objection to 0/1 coding?  
>
> It would also be helpful if you provided more context.  What kind of model
> are you estimating?  (You mentioned log odds, so I suspect it is logistic
> regression, but you've not said.)  What is the outcome variable?  What are
> the explanatory variables?  Why do you think you need to transform the
> variable you are asking about?  
>
> Thanks for clarifying.  
>
>
>
> mllx4eg5 wrote
>> Thankyou,
>> So all I need to do is recode the varible to (1,2) instead of (0,1)?
>>
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.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
>
>
>
>
>
> -----
> --
> 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.
>
> --
> Sent from: http://spssx-discussion.1045642.n5.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: linearity of independent variables to log odds

spss.giesel@yahoo.de
In reply to this post by mllx4eg5
Mind the missing dot at the end of COMPUTE.

Mario Giesel
Munich, Germany


Am Montag, 16. September 2019, 01:10:27 MESZ hat mllx4eg5 <[hidden email]> Folgendes geschrieben:


Hi,

I keep getting an error message
>Warning # 602
>The argument for the natural log function is less than or equal to zero.
The
>result has been set to the system-missing value.

when I run this syntax:
COMPUTE sexshun_LN=LN(sexshun)
EXECUTE.

How can I fix this?

(Sexshun is a binary variable)

thanks for any help



--

=====================
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: linearity of independent variables to log odds

Bruce Weaver
Administrator
In reply to this post by Ryan
If so, then another approach would be the Box-Tidwell Transformation
test--point #3 here:

  http://www.statisticalassociates.com/logistic10.htm

Given that it entails taking the log of X, negative values of X are
precluded.  

Here's a question for Jon (or anyone else who might know):  Is there a way
to make SPSS do the equivalent of Stata's -lowess outcome predictor, logit-
as described here?

https://www.statalist.org/forums/forum/general-stata-discussion/general/1516231-logistic-regression
https://www.stata.com/manuals/rlowess.pdf




Ryan Black wrote

> I think the OP wants to take the natural log of a binary DV to evaluate
> the linearity assumption in the context of binary logistic regression.
> That’s not the way to evaluate linearity, and it’s mathematically
> impossible to take the natural log when values = zero.
>
> Assuming there is only one explanatory variable which happens to be
> continuous, one quick and dirty approach would be to create bins of the
> continuous explanatory variable, refit the binary logistic regression
> model with the new categorical explanatory variable, output the predicted
> values on the log-odds scale, and then plot the original continuous
> explanatory variable against the predicted log-odds.
>
> Ryan
>
> Sent from my iPhone





-----
--
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.

--
Sent from: http://spssx-discussion.1045642.n5.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
--
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: linearity of independent variables to log odds

Jon Peck
I don't know the details of the Stata procedure, but there are a few Statistics extension commands that might be relevant.  These can, as usual, be installed via Extensions > Extension Hub.  They require the R Essentials, which can be obtained from the IBM Predictive Analytics site

STATS LOESS (Analyze > Regression > LOESS fit) does a loess fit and can calculate corresponding predicted values.  It has several options.  From the dialog help...

Alpha Specify the proportion of cases to be used for the fit at each point. The value will usually be less than or equal to 1, but larger values are allowed. Values greater than 1 mean to use all the points but taper the weights more slowly as the distance increases.

Polynomial degree A value of 0 means locally constant (use with caution), 1 means linear, and 2 means quadratic.

Family Gaussian means fit by least squares. Symmmetric means fit by an re-descending M estimator with a Tukey biweight function.

The STATS GAM (Analyze > Generalized Linear Models > Generalized Additive Model)  extension command fits a generalized additive model.  From the dialog help...

This procedure calculates a generalized additive model (GAM). GAMs are linear in predictor terms that can be simple variables or various kinds of splines or polynomials. This preserves the simplicity of the linear model while allowing flexibly for predictors to have a nonlinear effect on the dependent variable. In addition, you can specify the error distribution and link function for the model.

The dialog box supports only a subset of the functionality available in syntax. See the Additional Features section below for details.

Split files and the Statistics case weights are not supported by this procedure.

Dependent Variable Specify the dependent variable. Since the default error distribution and link are for a continuous dependent variable, if it is categorical, change the error distribution and link specification appropriately.

Linear Terms Select the linear predictors for the model, if any.

Type of NonlinearityParameter 1, and Parameter2 Specify the type of predictor nonlinearity and corresponding parameters. The dropdown list provides five types: smoothing spline, loess, orthogonal polynomials, bspline, and natural spline. The same type will be used for all the nonlinear terms. Each type takes one or two parameters, shown as parm1 and parm2 in the list. Enter the parameter value or values in the Parameter fields. The degrees of freedom parameter is a smoothing parameter. For spline, the difference between the degree and degrees of freedom is the number of knots. The natural spline is always cubic.


On Mon, Sep 16, 2019 at 5:53 AM Bruce Weaver <[hidden email]> wrote:
If so, then another approach would be the Box-Tidwell Transformation
test--point #3 here:

  http://www.statisticalassociates.com/logistic10.htm

Given that it entails taking the log of X, negative values of X are
precluded. 

Here's a question for Jon (or anyone else who might know):  Is there a way
to make SPSS do the equivalent of Stata's -lowess outcome predictor, logit-
as described here?

https://www.statalist.org/forums/forum/general-stata-discussion/general/1516231-logistic-regression
https://www.stata.com/manuals/rlowess.pdf




Ryan Black wrote
> I think the OP wants to take the natural log of a binary DV to evaluate
> the linearity assumption in the context of binary logistic regression.
> That’s not the way to evaluate linearity, and it’s mathematically
> impossible to take the natural log when values = zero.
>
> Assuming there is only one explanatory variable which happens to be
> continuous, one quick and dirty approach would be to create bins of the
> continuous explanatory variable, refit the binary logistic regression
> model with the new categorical explanatory variable, output the predicted
> values on the log-odds scale, and then plot the original continuous
> explanatory variable against the predicted log-odds.
>
> Ryan
>
> Sent from my iPhone





-----
--
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.

--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: linearity of independent variables to log odds

Rich Ulrich
In reply to this post by Ryan
Assuming Ryan is right - I think that a pretty good guide to the
regression is provided by what SPSS provides, as the
Hosmer-Lemeshow goodness-of-fit statistic

I think there is an associated plot which shows some more.

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of Ryan Black <[hidden email]>
Sent: Sunday, September 15, 2019 9:56 PM
To: [hidden email] <[hidden email]>
Subject: Re: linearity of independent variables to log odds
 
I think the OP wants to take the natural log of a binary DV to evaluate the linearity assumption in the context of binary logistic regression. That’s not the way to evaluate linearity, and it’s mathematically impossible to take the natural log when values = zero.

Assuming there is only one explanatory variable which happens to be continuous, one quick and dirty approach would be to create bins of the continuous explanatory variable, refit the binary logistic regression model with the new categorical explanatory variable, output the predicted values on the log-odds scale, and then plot the original continuous explanatory variable against the predicted log-odds.

Ryan

Sent from my iPhone

> On Sep 15, 2019, at 9:48 PM, Bruce Weaver <[hidden email]> wrote:
>
> What is your objection to 0/1 coding? 
>
> It would also be helpful if you provided more context.  What kind of model
> are you estimating?  (You mentioned log odds, so I suspect it is logistic
> regression, but you've not said.)  What is the outcome variable?  What are
> the explanatory variables?  Why do you think you need to transform the
> variable you are asking about? 
>
> Thanks for clarifying. 
>
>
>
> mllx4eg5 wrote
>> Thankyou,
>> So all I need to do is recode the varible to (1,2) instead of (0,1)?
>>
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.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
>
>
>
>
>
> -----
> --
> 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.
>
> --
> Sent from: http://spssx-discussion.1045642.n5.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
===================== 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