Nonlinear Regression (help needed)

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

Nonlinear Regression (help needed)

Medo
Hi all,

So I have been working on this non-linear Reg model, which is a bit tough.
One of its variables is recursive and this makes things complicated. Here is the formula:

A (t)= B (t) +alpha * C(t)
B(t)= D(t)+Beta * B (t-1)

A(t), C(t) and D (t) are known. B(t=1) =0 and the rest should be estimated.
I tried to use Lag, but for Lag it requires Beta to be a variable (as far as I have understood), but Beta is a parameter as well as alpha. So these two formulas should somehow come together for the estimation.
Can anyone help me with the non-linear regression coding of this in SPSS?

I would be really grateful.

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

Ryan
First, please distinguish random variables from coefficients (aka parameters to be estimated) in your equations. Next, please describe each random variable. Finally, it would helpful if you provided some information about the study.

Ryan

Sent from my iPhone

> On Jan 20, 2016, at 6:43 PM, Medo <[hidden email]> wrote:
>
> Hi all,
>
> So I have been working on this non-linear Reg model, which is a bit tough.
> One of its variables is recursive and this makes things complicated. Here is
> the formula:
>
> A (t)= B (t) +alpha * C(t)
> B(t)= D(t)+Beta * B (t-1)
>
> A(t), C(t) and D (t) are known. B(t=1) =0 and the rest should be estimated.
> I tried to use Lag, but for Lag it requires Beta to be a variable (as far as
> I have understood), but Beta is a parameter as well as alpha. So these two
> formulas should somehow come together for the estimation.
> Can anyone help me with the non-linear regression coding of this in SPSS?
>
> I would be really grateful.
>
> Cheers
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Nonlinear-Regression-help-needed-tp5731360.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: Nonlinear Regression (help needed)

Medo
Thanks Ryan for the swift response to my post.

The problem is a famous operations management decision rule for ordering behaviors of individuals.

To be exact, below is the actual model:

O(i,t)=Max{0, CO(i,t)+alpha(i) * (S'(i)-S (i,t)-(Beta(i)*SL (i,t)))}

where,
O(i,t)= orders placed by subject i in week t
CO (i,t)= Expected customer orders by subject i in period t
S' = Desired level of total inventory of subject i
S= actual on-hand inventory by subject i in period t
SL= actual on-order inventory by subject i in period t
alpha (i)= parameter showing how the inventory levels are underestimated by subject i
Beta (i) parameter showing how SL is underestimated by subject i

Also we have:
CO (i,t)= Theta (i) * IO (i,t)+(1-Theta (i) * CO (i, t-1)

where,
IO (i,t)= incoming orders received by subject i in period t
Theta (i) = is a smoothing parameter of subject i

The above shows how people decide about the order quantity based on the available data on their inventory and customer orders.

Theta, alpha, Beta and S' are parameters to be estimated.
The data for O(i,t), S, SL and IO (i,t) are available.
And CO(i,t) should also be calculated. CO (i, t=1)=0 (model's assumption)

We made some attempts to formulate this in SPSS with Lag for CO (i,t) but it keeps sending us errors.
If you were interested, I can also post our codes. Can you help?

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

David Marso
Administrator
This post was updated on .
I believe data, code(s) and exact error messages would be imperative for anyone attempting to leap into this rabbit hole!!!  
Nabble accepts attachments, so bring it on ;-)
Posting link in case you are posting from UGA.
http://spssx-discussion.1045642.n5.nabble.com/Nonlinear-Regression-help-needed-td5731360.html
Medo wrote
Thanks Ryan for the swift response to my post.

The problem is a famous operations management decision rule for ordering behaviors of individuals.

To be exact, below is the actual model:

O(i,t)=Max{0, CO(i,t)+alpha(i) * (S'(i)-S (i,t)-(Beta(i)*SL (i,t)))}

where,
O(i,t)= orders placed by subject i in week t
CO (i,t)= Expected customer orders by subject i in period t
S' = Desired level of total inventory of subject i
S= actual on-hand inventory by subject i in period t
SL= actual on-order inventory by subject i in period t
alpha (i)= parameter showing how the inventory levels are underestimated by subject i
Beta (i) parameter showing how SL is underestimated by subject i

Also we have:
CO (i,t)= Theta (i) * IO (i,t)+(1-Theta (i) * CO (i, t-1)

where,
IO (i,t)= incoming orders received by subject i in period t
Theta (i) = is a smoothing parameter of subject i

The above shows how people decide about the order quantity based on the available data on their inventory and customer orders.

Theta, alpha, Beta and S' are parameters to be estimated.
The data for O(i,t), S, SL and IO (i,t) are available.
And CO(i,t) should also be calculated. CO (i, t=1)=0 (model's assumption)

We made some attempts to formulate this in SPSS with Lag for CO (i,t) but it keeps sending us errors.
If you were interested, I can also post our codes. Can you help?

Cheers
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

Maguin, Eugene
In reply to this post by Medo
Am I not understanding the problem? What am I missing?
Two equations.
A (t)= B (t) +alpha * C(t).
B(t)= D(t)+Beta * B (t-1).
Could be rewritten as
A (t)= D(t)+Beta * B (t-1) +alpha * C(t).

In the absence of other (more) information, we assume a dataset with A, B, C, and D having valid data.
D(t) is a question but why not estimate (A (t)- D(t))=Beta * B (t-1) +alpha * C(t).
The dataset has to be worked on a tiny bit to pull B(t-1) forward and the N becomes N-1.
Ordinary regression problem. All relationships are linear. Why nonlinear?
If "t" is construed to mean time, then is this a time series problem?

Gene Maguin
PS. Isn't it kind of curious that two different people (Medo and Chalam) posted nearly the same question?


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Medo
Sent: Wednesday, January 20, 2016 6:43 PM
To: [hidden email]
Subject: Nonlinear Regression (help needed)

Hi all,

So I have been working on this non-linear Reg model, which is a bit tough.
One of its variables is recursive and this makes things complicated. Here is the formula:

A (t)= B (t) +alpha * C(t)
B(t)= D(t)+Beta * B (t-1)

A(t), C(t) and D (t) are known. B(t=1) =0 and the rest should be estimated.
I tried to use Lag, but for Lag it requires Beta to be a variable (as far as I have understood), but Beta is a parameter as well as alpha. So these two formulas should somehow come together for the estimation.
Can anyone help me with the non-linear regression coding of this in SPSS?

I would be really grateful.

Cheers



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Nonlinear-Regression-help-needed-tp5731360.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: Nonlinear Regression (help needed)

Bruce Weaver
Administrator
Maguin, Eugene wrote
--- snip ---
PS. Isn't it kind of curious that two different people (Medo and Chalam) posted nearly the same question?
Gene, I hope you're not suggesting that this might be a homework problem!  :-O  
--
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: Nonlinear Regression (help needed)

Maguin, Eugene
Bruce,
It just seemed interesting coincidence. A common cause? I don't know. But whether common cause or not, I'm curious/interested to see how the now clarified problem described by the most recent posting by Medo can be worked in spss.  Such a problem seems to be way outside of what may be encountered in "soft" social sciences. As an aside, when read the recent posting, I thought of work done in 70s/80s by a just-deceased Nobelist in economics, I think, that had facilitated efficient operation of long supply chain structures.

Gene Maguin
PS: I recognize :-) and :-(  but not :-O  (shock? Surprise? horror? Ironic quotes needed?)


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Thursday, January 21, 2016 11:20 AM
To: [hidden email]
Subject: Re: Nonlinear Regression (help needed)

Maguin, Eugene wrote
> --- snip ---
> PS. Isn't it kind of curious that two different people (Medo and
> Chalam) posted nearly the same question?

Gene, I hope you're not suggesting that this might be a homework problem!
:-O  



-----
--
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/Nonlinear-Regression-help-needed-tp5731360p5731369.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: Nonlinear Regression (help needed)

Medo
Gene,

Thank you very much for the response. To clarify things, this is part of research project Chalam and I are working on. We are not undergrads and this is not a homework, don't worry :-)

Gene, I think it helps more if you take a look at my post here earlier defining the actual problem as follows:

O(i,t)=Max{0, CO(i,t)+alpha(i) * (S'(i)-S (i,t)-(Beta(i)*SL (i,t)))}

where,
O(i,t)= orders placed by subject i in week t
CO (i,t)= Expected customer orders by subject i in period t
S' = Desired level of total inventory of subject i
S= actual on-hand inventory by subject i in period t
SL= actual on-order inventory by subject i in period t
alpha (i)= parameter showing how the inventory levels are underestimated by subject i
Beta (i) parameter showing how SL is underestimated by subject i

Also we have:
CO (i,t)= Theta (i) * IO (i,t)+(1-Theta (i) * CO (i, t-1)

where,
IO (i,t)= incoming orders received by subject i in period t
Theta (i) = is a smoothing parameter of subject i

We used the following code:
DATASET ACTIVATE DataSet1.
* NonLinear Regression.
MODEL PROGRAM  alpha=0 Beta=0 SP=0 Theta=0.
Do IF $casenum EQ 1.  /* t = 1.
COMPUTE CO = IO.
ELSE /* t > 1.
COMPUTE CO = Theta *IO + (1 - Theta) * LAG(CO).
END IF.
COMPUTE  PRED_=MAX (0, CO + alpha * (SP - S - (Beta * SL))).
NLR O
  /OUTFILE='C:\Users\AppData\Local\Temp\spss12284\SPSSFNLR.TMP'
  /PRED PRED_
  /BOUNDS alpha <= 1; Beta <= 1; Theta <= 1; alpha >= 0; Beta >= 0; SP >= 0; Theta >= 0
  /CRITERIA STEPLIMIT 2 ISTEP 1E+20.

and it does not work!
So could you help us with it?

Bests,
Medo
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

David Marso
Administrator
"and it does not work!
So could you help us with it? "
That is absolutely useless 'information' for anyone to render assistance!!
Data/Code/Error messages!!!!

--
Medo wrote
Gene,

Thank you very much for the response. To clarify things, this is part of research project Chalam and I are working on. We are not undergrads and this is not a homework, don't worry :-)

Gene, I think it helps more if you take a look at my post here earlier defining the actual problem as follows:

O(i,t)=Max{0, CO(i,t)+alpha(i) * (S'(i)-S (i,t)-(Beta(i)*SL (i,t)))}

where,
O(i,t)= orders placed by subject i in week t
CO (i,t)= Expected customer orders by subject i in period t
S' = Desired level of total inventory of subject i
S= actual on-hand inventory by subject i in period t
SL= actual on-order inventory by subject i in period t
alpha (i)= parameter showing how the inventory levels are underestimated by subject i
Beta (i) parameter showing how SL is underestimated by subject i

Also we have:
CO (i,t)= Theta (i) * IO (i,t)+(1-Theta (i) * CO (i, t-1)

where,
IO (i,t)= incoming orders received by subject i in period t
Theta (i) = is a smoothing parameter of subject i

We used the following code:
DATASET ACTIVATE DataSet1.
* NonLinear Regression.
MODEL PROGRAM  alpha=0 Beta=0 SP=0 Theta=0.
Do IF $casenum EQ 1.  /* t = 1.
COMPUTE CO = IO.
ELSE /* t > 1.
COMPUTE CO = Theta *IO + (1 - Theta) * LAG(CO).
END IF.
COMPUTE  PRED_=MAX (0, CO + alpha * (SP - S - (Beta * SL))).
NLR O
  /OUTFILE='C:\Users\AppData\Local\Temp\spss12284\SPSSFNLR.TMP'
  /PRED PRED_
  /BOUNDS alpha <= 1; Beta <= 1; Theta <= 1; alpha >= 0; Beta >= 0; SP >= 0; Theta >= 0
  /CRITERIA STEPLIMIT 2 ISTEP 1E+20.

and it does not work!
So could you help us with it?

Bests,
Medo
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

Medo
David,

Here is the code we used:
DATASET ACTIVATE DataSet1.
* NonLinear Regression.
MODEL PROGRAM  alpha=0 Beta=0 SP=0 Theta=0.
Do IF $casenum EQ 1.  /* t = 1.
COMPUTE PRED_= MAX(0, (IO) + alpha * (SP - S - (Beta * SL))).
COMPUTE CO = IO.
ELSE. /* t > 1.
COMPUTE PRED_O=MAX(0,( Theta *IO + (1-Theta)*LAG(CO)) + alpha * (SP - S - (Beta * SL))).
COMPUTE CO = Theta *IO + (1-Theta)*LAG(CO).
END IF.
NLR O
  /OUTFILE='C:\Users\AppData\Local\Temp\spss12284\SPSSFNLR.TMP'
  /PRED PRED_
  /CRITERIA STEPLIMIT 2 ISTEP 1E+20.

and here are the errors:
Warnings
Undefined variable name.
Execution of this command stops.
Unrecognized keyword in the SAVE subcommand. The valid keywords are PRED, RESID, DERIV, and (for CNLR but not NLR) LOSS.
Unrecognized keyword in the SAVE subcommand. The valid keywords are PRED, RESID, DERIV, and (for CNLR but not NLR) LOSS.
No model program has been defined. Refer to your manual for a description of the commands needed to define the model.


Hope this clarifies things.
Reply | Threaded
Open this post in threaded view
|

Re: Nonlinear Regression (help needed)

Ryan
Hello ________:

I don't use NLR for a variety of reasons. But I dabbled in NLR a couple years ago and figured out how to fit a generalized linear model typically referred to as binary logistic regression by carefully reading the fine manual. Looking back at my syntax, I can see that your syntax is missing key pieces and that some of your syntax needs to be revised.

To help get you started, I recommend you start with a very simple model and make sure it is converging without errors. Then slowly add in complexity, making sure each time you make the model more complex it still converges. To help get you started, below is the simulated example I created years ago.

Ryan
--

 INPUT PROGRAM.
     LOOP ID= 1 to 10000.
     COMPUTE  x = rv.normal(0,1).
     IF  (ID<=5000) group=0.
     IF (ID>5000) group=1.
     COMPUTE  #eta  = -1.5 + 1.2*group + 0.9*x.
     COMPUTE y = rv.bernoulli(1 / (1+ exp(-#eta))).
     END CASE.
   END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
 
* Fit logistic regression model using NonLinear Regression procedure.
MODEL PROGRAM  b0=0 b1=0 b2=0.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
CNLR  y
  /PRED PRED_
  /LOSS LOSS_
  /BOOTSTRAP.




On Thu, Jan 21, 2016 at 6:14 PM, Medo <[hidden email]> wrote:
David,

Here is the code we used:
DATASET ACTIVATE DataSet1.
* NonLinear Regression.
MODEL PROGRAM  alpha=0 Beta=0 SP=0 Theta=0.
Do IF $casenum EQ 1.  /* t = 1.
COMPUTE PRED_= MAX(0, (IO) + alpha * (SP - S - (Beta * SL))).
COMPUTE CO = IO.
ELSE. /* t > 1.
COMPUTE PRED_O=MAX(0,( Theta *IO + (1-Theta)*LAG(CO)) + alpha * (SP - S -
(Beta * SL))).
COMPUTE CO = Theta *IO + (1-Theta)*LAG(CO).
END IF.
NLR O
  /OUTFILE='C:\Users\AppData\Local\Temp\spss12284\SPSSFNLR.TMP'
  /PRED PRED_
  /CRITERIA STEPLIMIT 2 ISTEP 1E+20.

and here are the errors:
Warnings
Undefined variable name.
Execution of this command stops.
Unrecognized keyword in the SAVE subcommand. The valid keywords are PRED,
RESID, DERIV, and (for CNLR but not NLR) LOSS.
Unrecognized keyword in the SAVE subcommand. The valid keywords are PRED,
RESID, DERIV, and (for CNLR but not NLR) LOSS.
No model program has been defined. Refer to your manual for a description of
the commands needed to define the model.


Hope this clarifies things.



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Nonlinear-Regression-help-needed-tp5731360p5731374.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: Nonlinear Regression (help needed)

Medo
Thanks very much, Ryan. This might be very helpful. We will give a try.