Hello,
Attached is the code I'm using to find MLEs.
I'm trying to find the bias and standard deviation for given parameters.
my problem is: whenever I changed the initial values for the parameters, I get a different answer (output).
For example, if I change the initial values ( lambda30, lambda40) from 0.1,0.1 to 0.4,0.4 , respectively, I will get different answers.
Could you figure out why?
Can you make a refinement for the code?
Sincere thanks!
If you haven't already read these articles, please look at
I don't seem to be able to reproduce what you are seeing. I set nr=1 and optn={1 2}. I ran the program twice, once with initial conditions (1, 1, 0.1, 0.1) and again with (1, 1, 0.4, 0.4).
I got the exact same optimum both times.
Perhaps you could post a screenshot of what you are seeing.
Thank you professor.
Please see the attachment.
That is because the following code change the result: " parest=estmat[:,]; gamma_mle=parest[1]; c_mle=parest[2]; lm3_mle=parest[3]; lm4_mle=parest[4]; gamma_bias=gammav-gamma_mle; c_bias=cv-c_mle; lm3_bias=lambda3v-lm3_mle; lm4_bias=lambda4v-lm4_mle; onev=j(nrow(estmat),1,1); devv=(estmat-onev*parest)#(estmat-onev*parest); varr=devv[+,]/(nrow(estmat)-1); stdev=sqrt(varr); gamma_sd=stdev[1]; c_sd=stdev[2]; lm3_sd=stdev[3]; lm4_sd=stdev[4]; res1[nc,]=lambda4v||cv||gammav||lambda3v||gamma_bias||gamma_sd||lm3_bias||lm3_sd||c_bias||c_sd||lm4_bias||lm4_sd; "
Hello Xia Keshan,
I don't think so the reason is what you have mensioned, since I defined a nother function (lf2(x)) and I GOT THE SAME RESULTS.
I think the reason is the function itself.
Thanks!
No. Once you change optn={1 0}; -> optn={1 2}; which means you can the result of call nlptr() .
After running the code with different initial value , I got the result, in other words, there must be
some code from you to change the final result.
gamma0=1; c0=1; lambda30=0.1; lambda40=0.1;
OUTPUT:
MLE-simulation
Optimization Results
Parameter Estimates
N Parameter Estimate Gradient
Objective
Function
1 X1 1.865201 0.000001331
2 X2 2.079614 0.000016103
3 X3 1.054787 0.000024134
4 X4 0.790518 0.000010652
Value of Objective Function = -313.0280387
gamma0=1; c0=1; lambda30=0.4; lambda40=0.4;
OUTPUT:
MLE-simulation
Optimization Results
Parameter Estimates
N Parameter Estimate Gradient
Objective
Function
1 X1 1.865201 0.000009320
2 X2 2.079609 -0.000002477
3 X3 1.054794 -0.000003713
4 X4 0.790524 0.000008522
Value of Objective Function = -313.0280387
Do you know how to fix the code in order to get correct standard dev and bias. Your help would be appreciated.
parest=estmat[:,]; gamma_mle=parest[1]; c_mle=parest[2]; lm3_mle=parest[3]; lm4_mle=parest[4]; gamma_bias=gammav-gamma_mle; c_bias=cv-c_mle; lm3_bias=lambda3v-lm3_mle; lm4_bias=lambda4v-lm4_mle; onev=j(nrow(estmat),1,1); devv=(estmat-onev*parest)#(estmat-onev*parest); varr=devv[+,]/(nrow(estmat)-1); stdev=sqrt(varr); gamma_sd=stdev[1]; c_sd=stdev[2]; lm3_sd=stdev[3]; lm4_sd=stdev[4]; res1[nc,]=lambda4v||cv||gammav||lambda3v||gamma_bias||gamma_sd||lm3_bias||lm3_sd||c_bias||c_sd||lm4_bias||lm4_sd; "
No. I have no time to go through all these. You have to check it on your own. I am sure matrix estmat[ ] is right.
You are displaying the Monte Carlo means of the parameter estimates. Means are, of course, not robust statistics, so this could be caused by a small number of random samples for which one initial conditions (ICs) converges and the other does not (or converges to a different local maximum.)
Here's how to determine what is happening:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!