Page 2 of 2

Re: Maximise a piecewise defined function

Posted: Thu Jul 18, 2013 5:07 pm
by TomDoan
Works fine for me. You can get rid of the simplex iterations. They aren't necessary and could cause it to leave the non-negative range for beta. (PMETHOD=SIMPLEX doesn't use the constraints).

Re: Maximise a piecewise defined function

Posted: Thu Jul 18, 2013 5:17 pm
by rbelhach95
Many Thanks Tom, still getting Rats Stopped...., could you send me your output or advise me what I should do. I will reboot may be that would help or reinstall the program again. Just to be sure, did you run the last code I sent you? Thank you
Rachid

Re: Maximise a piecewise defined function

Posted: Thu Jul 18, 2013 5:27 pm
by TomDoan

Code: Select all

MAXIMIZE - Estimation by BFGS
Convergence in     3 Iterations. Final criterion was  0.0000002 <=  0.0000100
Usable Observations                      1150
Function Value                     -1055.2676

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  MUGZ                         3.3767076290 0.0137455081    245.65899  0.00000000
2.  SIGMAGZ                      0.7382213094 0.0152971412     48.25878  0.00000000
3.  ALPHA                        2.1819414012 0.2767405879      7.88443  0.00000000
4.  BETA                         0.2209384865 0.0103424435     21.36231  0.00000000

Re: Maximise a piecewise defined function

Posted: Thu Jul 18, 2013 5:38 pm
by rbelhach95
Dear Tom,
Thanks for the output. Could you send me the text file too. Thanks
Rachid

Re: Maximise a piecewise defined function

Posted: Fri Jul 19, 2013 12:04 am
by rbelhach95
Dear Tom,

I was not may be clear in my last email to you, I meant the code I last sent you to see if you haven't made any changes, anyhow I appreciate and thank you for all your efforts.
Rachid

Maximise a piecewise defined function

Posted: Sat Sep 14, 2013 3:33 pm
by rbelhach95
Dear Tom,

Hope all is well. I have a question along the same line of my last email, but different objective function this time. I run the code, it works fine but no output, I believe the looping is empty. I am not sure if my %if statement is where it should be. Please advise, I have attached the code and the data. Thank you
Rachid

Re: Maximise a piecewise defined function

Posted: Sat Sep 14, 2013 5:44 pm
by TomDoan
On

g5=1/2+(1/2)*%gamma(1/alpha)*%sign(c*(x(t)-mux))*%gammainc(abs((b*c*(x(t)-mux)))^alpha,1/alpha) , $

use .5 or 1.0/2 rather than 1/2. The last does an integer divide giving 0.

Re: Maximise a piecewise defined function

Posted: Sat Sep 14, 2013 7:24 pm
by rbelhach95
Thanks Tom, very much appreciated.
Rachid

Re: Maximise a piecewise defined function

Posted: Tue Sep 17, 2013 5:13 am
by rbelhach95
Dear Tom,

Hope my email finds you well. I run the attached code and data, it converges to something that I don't want (negative sigma2), (output is also attached), however, in the output, many of my data points are "skipped/missing" , could it be because of bad choice of starting values? or maybe I need to add more information into the code to read all the data set. Please advise. Thank you
Rachid

Re: Maximise a piecewise defined function

Posted: Tue Sep 17, 2013 10:21 am
by TomDoan
Yes. You probably have a problem at your guess values. I suspect that the problem is with the following:

g1=-(-(x(t)-mux1)*b/sigmax1)^alpha1, $
g2=-((x(t)-mux2)*b/sigmax2)^alpha2, $

Negative number to real power isn't defined. If you're mux1 and mux2 aren't chosen to make that (x(t)-mu)*b/sigma negative in the first line and positive in the second, you'll trigger a missing value at t.

Re: Maximise a piecewise defined function

Posted: Tue Sep 17, 2013 10:22 am
by TomDoan
Yes. You probably have a problem at your guess values. I suspect that the problem is with the following:

g1=-(-(x(t)-mux1)*b/sigmax1)^alpha1, $
g2=-((x(t)-mux2)*b/sigmax2)^alpha2, $

Negative number to real power isn't defined. If your mux1 and mux2 aren't chosen to make that (x(t)-mu)*b/sigma negative in the first line and positive in the second, you'll trigger a missing value at t. But at any rate, you'll have to see where the missing values are, evaluate the FRML there and check the intermediate calculations.

Re: Maximise a piecewise defined function

Posted: Tue Sep 17, 2013 2:05 pm
by rbelhach95
Thanks Tom for your thoughtful insights, my mistake, I left off the factors d and (1-d) in the terms you mentioned. Thanks
Rachid