Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: programming stata: storing results in arrays for future reference


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   st: Re: programming stata: storing results in arrays for future reference
Date   Mon, 21 Jun 2004 14:52:05 +0100

Alex,

There are several ways to save the log likelihood values.

You can include a local macro that retrieves the log likelihood estimate
using the -ereturn- post estimation results.

Let's say you want to retrieve the log likelihood estimated from a set of
mlogit using a loop:

foreach x in 0.1 0.2 0.5 {
mlogit depvar indvar (scaling factor==`x')
local ll_`x'=`e(ll)'
}

Where `e(ll)' is a scalar containing the log likelihood estimated result.
You will have all the log likelihood results in local macros named
ll_(scaling factor).

Alternatively you can generate new variables containing the log likelihood,
you simple change local ll_`x' for gen ll_`x' in the above loop. You can
also use the command -est store- to store all the estimation outcome, this
will allow you to access all the estimated results and post estimation
commands (and est. scalars, macros and matrix).

Type -ereturn list- after an estimation to see all the values that you can
retrieve and save after each estimation.

I hope this helps,

Rafa



----- Original Message -----
From: "Mitrani, Alex" <[email protected]>
To: <[email protected]>
Sent: Friday, June 18, 2004 6:56 PM
Subject: st: programming stata: storing results in arrays for future
reference


> Dear stata users,
>
> I am embarking on my first programming exercise with stata, and would
appreciate a little advice.  The task involves getting a model command to
iterate a number of times with a sub-set of the independent variables being
systematically modified each time using different values of a scaling factor
(say going from 0 to 5 in increments of 0.1).  I need to retrieve the log
likelihood of each model, and display them alongside the corresponding
values of the scaling factor.  In this way the scalilng factor that results
in the model best fitting the data can be obtained.
>
> I am sure this is all possible, but having read the material in the users'
guide on programming stata, I cannot see a simple way of storing the
different values of the log likelihood in an array (I know that this is very
straight-forward in most other programming languages), so that they can be
conveniently displayed after the model runs have been finished, for instance
by looping a display command over all the values contained in the array.
>
> Any help with this would be greatly appreciated.
>
>
> Alex
>
>
>
>
>
> Alex Mitrani
>
>
> Steer Davies Gleave
> 28-32 Upper Ground, London SE1 9PD, UK
>
> [direct] +44 (0)20 7910 5578
> [main] +44 (0)20 7919 8500
> [fax] +44 (0)20 7827 9850
> [e-mail]   [email protected]
>
> http://www.steerdaviesgleave.com/
> This message is sent in confidence for the addressee only. It may contain
legally privileged information. The contents are not to be disclosed to
anyone other than the addressee. Unauthorised recipients are requested to
preserve this confidentiality and to advise the sender immediately of any
error in transmission.
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index