Defining derivatives and constrains?
Moderators: EViews Gareth, EViews Moderator

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Defining derivatives and constrains?
Hello There,
I'm trying to fit the following equation (known as lotkaVolterra) to real data series (x, y, z) to estimate its parameters (a, b, c, d):
dx/dt = (a)x  (b)x^2 + (c)x*y  (d)x*z
Could you please help mw with followings?
1 how could I define dx/dt in the equation specification?
2 Is there any option that I can put some constraints on some parameters, for example a<1 or b=>3?
3 Sometimes I get low R2, and high Probs. How can I better them?
Thanks.
I'm trying to fit the following equation (known as lotkaVolterra) to real data series (x, y, z) to estimate its parameters (a, b, c, d):
dx/dt = (a)x  (b)x^2 + (c)x*y  (d)x*z
Could you please help mw with followings?
1 how could I define dx/dt in the equation specification?
2 Is there any option that I can put some constraints on some parameters, for example a<1 or b=>3?
3 Sometimes I get low R2, and high Probs. How can I better them?
Thanks.

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
Simplifier12 wrote:Hello There,
I'm trying to fit the following equation (known as lotkaVolterra) to real data series (x, y, z) to estimate its parameters (a, b, c, d):
dx/dt = (a)x  (b)x^2 + (c)x*y  (d)x*z
Could you please help mw with followings?
1 how could I define dx/dt in the equation specification?
2 Is there any option that I can put some constraints on some parameters, for example a<1 or b=>3?
3 Sometimes I get low R2, and high Probs. How can I better them?
Thanks.
How did you define dx/dt when you got the low R2?

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:Simplifier12 wrote:Hello There,
I'm trying to fit the following equation (known as lotkaVolterra) to real data series (x, y, z) to estimate its parameters (a, b, c, d):
dx/dt = (a)x  (b)x^2 + (c)x*y  (d)x*z
Could you please help mw with followings?
1 how could I define dx/dt in the equation specification?
2 Is there any option that I can put some constraints on some parameters, for example a<1 or b=>3?
3 Sometimes I get low R2, and high Probs. How can I better them?
Thanks.
How did you define dx/dt when you got the low R2?
For example in the data series file, I added a column named dxdt and I defined it as x(t)x(t1).

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
Simplifier12 wrote:startz wrote:Simplifier12 wrote:Hello There,
I'm trying to fit the following equation (known as lotkaVolterra) to real data series (x, y, z) to estimate its parameters (a, b, c, d):
dx/dt = (a)x  (b)x^2 + (c)x*y  (d)x*z
Could you please help mw with followings?
1 how could I define dx/dt in the equation specification?
2 Is there any option that I can put some constraints on some parameters, for example a<1 or b=>3?
3 Sometimes I get low R2, and high Probs. How can I better them?
Thanks.
How did you define dx/dt when you got the low R2?
For example in the data series file, I added a column named dxdt and I defined it as x(t)x(t1).
That's a perfectly reasonable thing to do.
There aren't easy ways to impose constraints, but there are some tricks. For example replace a with 1@exp(f), where f is the coefficient to be estimated.
You can't improve the R2, etc., unless you change the data or the specification.

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:Simplifier12 wrote:startz wrote:How did you define dx/dt when you got the low R2?
For example in the data series file, I added a column named dxdt and I defined it as x(t)x(t1).
That's a perfectly reasonable thing to do.
There aren't easy ways to impose constraints, but there are some tricks. For example replace a with 1@exp(f), where f is the coefficient to be estimated.
You can't improve the R2, etc., unless you change the data or the specification.
Thanks. Okay for a<1, I should put 1@exp(f). But I have other different constraints. Could you let me know of the general tricks of defining various constraints by @exp(f)?

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
I'm not sure there are any general tricks, although perhaps someone has a list of useful ones.

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:I'm not sure there are any general tricks, although perhaps someone has a list of useful ones.
Dear Startz
I'm having the following equation and I need the constant (a) to be no smaller than zero:
Z = c + (a/X) + (bY/X)
I have already read the related post: viewtopic.php?f=4&t=48&p=99 , which says for onesided constraints like for the constant c no larger than 1 we should use [1Exp(c)] hack. Mine is no smaller than zero, but I cannot figure out if I should put Exp(c) or Exp(c) or sth else.
In case I use Exp(c), in the result table brings me the value of 0.25 as coefficient and Exp(0.64) next to the corresponding variable. But it does not make sense to me since how the answer of an Exp can be negative? I also used Exp(c), but again it gave me nonsense results. The coefficient value of 0.62 for Exp(0.254). I even dont know if I should ignore whatever value the tables shows inside Exp or it should be considered when calculating the primary constant.
Even though my constraint is one sided, I also used the two sided hack of (HL)*@Logit(c(2)) + L because it was giving more generic rules for making constraints. I imagined my constraint to be 0=<a<=2 and I changed the upper value to see how the results would change accordingly. For 0=<a<=2, I got the coefficient value of 0.60 for 2@Logit(0.395) as the corresponding constant. Here again I even dont know if I should ignore whatever value the tables shows inside Logit or it should be considered when calculating the primary constant.
I also wonder if the method (Lease Squares) in estimation setting should be changed as the estimating constant is no longer linear because they are being put in nonlinear expressions.
I'm a dummy in math.
Could you please help!!

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
You might want to post the exact command you used and your output.

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:You might want to post the exact command you used and your output.
Thanks for your reply. The exact equation is W = C1 + C2*(1/X) + (Y/X) + Z/X) with constraint C2>0 .
The first command: w c(1) (2*@logit(c(2)))*(1/x) (y/x) (z/x)
The first output:
The second command: w c(1) (@exp(c(2)))*(1/x) (y/x) (z/x)
The second output:
The third command: w c(1) (@exp(c(2)))*(1/x) (y/x) (z/x)
The third output:
Also when I give the same commands another run, the answer for the coefficient changes. I dont know why this happens. For example this is the results for a second run for the first command:
Just letting you know that I'm using the student version, and it does not allow me to save my results as it's limited.

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
I think what's happening is that the command you are using puts a coefficient in front of each term. Try writing this out specified as a formula as shown at http://www.eviews.com/help/helpintro.html#page/content%2FRegress1Specifying_an_Equation_in_EViews.html

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:I think what's happening is that the command you are using puts a coefficient in front of each term. Try writing this out specified as a formula as shown at http://www.eviews.com/help/helpintro.html#page/content%2FRegress1Specifying_an_Equation_in_EViews.html
Thanks very much for your tip. I read the post and accordingly modify the commends, but no success. I dont know if I'm still writing the commands wrong or sth else.
I have uploaded the data here. Could you please give them a go in your computer with your expertise?
 Attachments

 Eviews forum Simplifier.xlsx
 (22.86 KiB) Downloaded 23 times

 Nonnormality and collinearity are NOT problems!
 Posts: 3406
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Defining derivatives and constrains?
Show people exactly what you've done and maybe someone will chime in having figured out where things have gone astray.

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
startz wrote:Show people exactly what you've done and maybe someone will chime in having figured out where things have gone astray.
I exactly entered the commands that I mentioned above with the data provided in the excel file, and and I got the corresponding results. I also play around by putting space etc. but still no success. I'm really frustrated after 10 days of jiggling things around.
Could someone please please help with my rudimental problem!!!

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11926
 Joined: Tue Sep 16, 2008 5:38 pm
Re: Defining derivatives and constrains?
People are helping you. You have to help yourself. And help them help you.
Follow us on Twitter @IHSEViews

 Posts: 18
 Joined: Tue Sep 18, 2018 8:45 pm
Re: Defining derivatives and constrains?
EViews Gareth wrote:People are helping you. You have to help yourself. And help them help you.
Hello Gareth,
Yes, you're right. But I already mentioned my problem. Okay I will reexplain what I do.
I'm having the following equation with variables W, X, Y, and Z, and I need to estimate the constants C1, C2, C3, and C4. However, I want C2 to be no smaller than zero (C2>0):
W = C1 + C2*(1/X) + C3*(Y/X) + C4*(Z/X)
The post: viewtopic.php?f=4&t=48&p=99 says for onesided constraints like c no larger than 1 we should use [1Exp(c)] hack. Since in my case C2 should be no smaller than zero, I dont know if I should put Exp(c) or Exp(c) or sth else. Anyway I tried both Exp(c) or Exp(c) and I got the following results for each command:
The first command: w c(1) (@exp(c(2)))*(1/x) (y/x) (z/x)
The first output:
The second command: w c(1) (@exp(c(2)))*(1/x) (y/x) (z/x)
The second output:
As you can in both results, I get values inside both the Exp, which I dont know if I should ignore the values or they should be considered when calculating the primary constant. Also the coefficient value that both tables show me does not make sense as any outcome of Exp should it positive.
Anyway I changed the constraint in my problem from C2>=0 to 0<=C2<= 2 so I try the logit hack, i.e. (HL)*@Logit(c(2)) + L. So, for my constraint I used 2*@Logit(c(2)) in the equation as in the following command and I got the following results table:
The first command: w c(1) (2*@logit(c(2)))*(1/x) (y/x) (z/x)
The first output:
Though the value for coefficient makes sense, unlike the values for the Exps, I still get values inside the logit expression as you can see in the table, which I dont know if it's normal.
Just one more thing: When I use the same commands and run the estimation function, the answer for the coefficient changes constantly. I dont know why this happens. For example this is the results for a second run for the first command which is different compared to the first table of results:
I have attached my data here as well in case someone needed to do it on their PC.
Thanks so very much for your cooperation and I look forward to your help.
Regards,
 Attachments

 Eviews forum Simplifier.xlsx
 (22.86 KiB) Downloaded 23 times
Who is online
Users browsing this forum: No registered users and 12 guests