[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Ernest Berkhout <[email protected]> |

To |
[email protected] |

Subject |
RE: st: calling the value of a scalar into a variable |

Date |
Mon, 06 Oct 2003 13:32:45 +0200 |

At 12:36 6-10-2003, you wrote:

Stata users,One approach could be to create a dataset within your loop, recording in one variable the number of lags you include (`x' that is) and in the second and third the matching AIC`x' and SIC`i'. As far as I know -but that knowledge might still be superseded by more experienced programmers- that might best be done using 'postfile'.

I have a small problem that I am sure can be solved by you experts. I am running some dickey fuller test, and computing my own Akaike Information criteria or Scharwtz Information Criteria. I saved the results of these in a scalar.

I want to ask stata to create a variable that computes the minimum of the AIC or SIC and return the value in that variable, rather than me cheking it from the screen everytime. Can anybody help please? I am copying the loop file below.

local z "1 2 3 4 5 6"

foreach x of local z{

regress D.netpremmean L.netpremmean L`x'D.netpremmean

matrix b`x'=get(_b)

scalar AIC`x'=log(_result(4)/_result(1))+(colsof(b`x')/_result(1))*2

scalar SIC`x'=log(_result(4)/_result(1))+(colsof(b`x')/_result(1))*log(_result(1))

}

scalar list

So rather than calling scalar list and looking at the screen, I want a variable that stores the min of AIC and SIC so that I can see it in the data editor. I want to do that because at some point I would need to loop that over many series.

postfile myhandle lags aic sic using adftests, replace

forvalues x = 1/6 {

regress D.netpremmean L.netpremmean L`x'D.netpremmean

matrix b`x'=get(_b)

scalar AIC`x'=log(_result(4)/_result(1))+(colsof(b`x')/_result(1))*2

scalar SIC`x'=log(_result(4)/_result(1))+(colsof(b`x')/_result(1))*log(_result(1))

post myhandle (`x') (AIC`x') (SIC`x')

}

postclose myhandle

This should give you a dataset adftests.dta with the values you want. From there it is easy to detect the minimum value of a variable using normal Stata functions for generate and/or egen.

Ernest Berkhout

SEO Amsterdam Economics

University of Amsterdam

Room 3.08

Roetersstraat 29

1018 WB Amsterdam

The Netherlands

tel.:+ 31 20 525 1657

fax:+ 31 20 525 1686

http://www.seo.nl

===========================

A statistician: someone who insists

on being certain about uncertainty

===========================

*

* 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/

**Follow-Ups**:**RE: st: calling the value of a scalar into a variable***From:*"Nick Cox" <[email protected]>

**References**:**RE: st: calling the value of a scalar into a variable***From:*"Dev Vencappa" <[email protected]>

- Prev by Date:
**Re: st: Zero Inflated Models** - Next by Date:
**st: beta-testing xtgraph.** - Previous by thread:
**RE: st: calling the value of a scalar into a variable** - Next by thread:
**RE: st: calling the value of a scalar into a variable** - Index(es):

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