# Plotting the likelihood function

0

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;
```
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!

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

0

Many many thanks!

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;
```
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!

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

0

Many many thanks!

• ### Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

• ### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• ### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• ### Want to find out more?

Get a real answer from a real person

• ### Have a Specific Question?

Get a real answer from a real person

• Need Support?
• ### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• ### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!