turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-28-2016 05:28 PM - edited 08-29-2016 03:01 PM

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Medo_Aldeni

08-28-2016 07:54 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

08-28-2016 09:17 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Medo_Aldeni

08-28-2016 10:15 PM

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; "

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

08-28-2016 10:29 PM

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Medo_Aldeni

08-28-2016 10:50 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

08-28-2016 11:23 PM

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; "

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Medo_Aldeni

08-29-2016 03:46 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Medo_Aldeni

08-29-2016 07:45 AM

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:

- Run the simulation with one set of ICs and save the parameter estimates to MLE_EST1. Then run the simulation again with the other ICs and save the estimates to MLE_EST1.
- Plot the parameter estimates for the two runs against each other in a scatter plot.
- For most of samples, the two estimates should fall on or near the line y=x. For a few, you will probably see that the estimates are far from each other.
- If you label each marker with the simulation number, that will enable you to find out which samples are leading to different estimates.
- You can then investigate the MLE function for those samples.