 # Plotting the likelihood function

Hi,

I am wondering how can I extract the information from the optmum command with respect to the likelihood function values during the optimization path.

In other words, I would like the value of the likelihood at each iteration of the optimization so that I can plot it.

Any help?

thanks!

Barbara

0

accepted

If you want to write just the value of the likelihood function to a file, you would need to add the output call to your likelihood procedure right after it is calculated, but before you return:

```proc (1) = myLikelihood(b);

//calculate likelihood
current_likelihood = ...

output file=likelihood_vector.txt on;
print current_likelihood;
output off;

retp(current_likelihood);
endp;
```

This, above, will append each value to the text file. However, you could alternatively assign this to a global vector which you could then print out later, like this:

```//create empty matrix
global_likelihood_vector = {};

//Settings and call to 'optmum'
...
...

proc (1) = myLikelihood(x);
local current_likelihood;

//Calculate likelihood
current_likelihood = ...

//Concatenate current likelihood to vector
//of all likelihoods
global_likelihood_vector = global_likelihood_vector | current_likelihood;

retp(current_likelihood);
endp;
``` aptech

1,518

0

Assuming your objective function is computing -logL (it has to be minus because Optmum minimizes rather than maximizes the objective function), then

output file = thisrun.txt reset;
__output = 1;
.
.
.
.
output off;

the value of the objective function, -logL, will be printed to the output file, thisrun.txt as well as to the screen. It will be printed with a lot of other information so it might be hard to grab. You could copy and paste each line containing the function value at each iteration to another file. Or you could write a GAUSS program to read that file and collect the function values into another file. That's what I would do. 0

Thanks a lot! Babi

6

0

Hi,

I did what you suggested, but I dont get anything new from what I already see in the command window when I am estimating. The only thing I get is a .txt file with all the iterations and the function value in each of them. But what I want is a vector with all those values so that I can plot them.

How can I get this?

Thanks again.

Barbara Babi

6

0

Many many thanks! Babi

6

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.