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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: re: beginning programming advice |

Date |
Mon, 15 Oct 2007 10:58:08 -0400 |

Thomas says

Here is a more detailed problem definition with two companies and one

year of trading data for each - I did not populate the sample

Accounting values(Acct), Market Equity (MktEq) or Equity Volatility

(EqVol) variables but they would have a value for each company and

trading day combination:

Company, TradeDay, Acct1, Acct2, MktEq, EqVol

1 1

1 2

...

1 252

2 1

...

2 252

On each day I am solving the following non-linear equations each of

which has one or more cumulative normal distribution functions

embedded in the right hand side and I have introduced the variables I

need to solve for: Market Value of Assets (MktAssets) and Asset

Volatility (AssetVol):

MktEq = f(Acct1, Acct2, EqVol, MktAssets, AssetVol)

EqVol = f(Acct1, Acct2, MktEq, MktAssets, AssetVol)

I would then have a file or dataset in memory that appears as:

Company, TradeDay, Acct1, Acct2, MktEq, EqVol, MktAssets, AssetVol

for use in econometric modeling.

If you sort the dataset by day then firm, you can pass each day's data to Mata in a view matrix of 252 x 8. You can then call -optimize ()- to solve the equations involving those variables, and return the results to Stata in whatever form would be useful to accumulate. For instance, if there is one daily value that arises from the solution of each equation, create a couple of new variables in Stata (with missing values) and create a view matrix in Mata that fills in their daily observations.

As a fancier technique, you can use Mata's panelsetup() to tell Mata that the data are defined in a perverse sort of panel with i and t subscripts reversed: you have 252 panels each comprised of a number of firms. Then you could just pass the entire dataset to Mata and run the loop over trading days within Mata with one call.

Kit

Kit Baum, Boston College Economics and DIW Berlin

http://ideas.repec.org/e/pba1.html

An Introduction to Modern Econometrics Using Stata:

http://www.stata-press.com/books/imeus.html

*

* 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: re: beginning programming advice***From:*"Thomas Jacobs" <thomasjacobs@gmail.com>

- Prev by Date:
**Re: st: RE: Beginning Programming Advice** - Next by Date:
**RE: st: -heckman- and the identifying variable(s)** - Previous by thread:
**st: r-square 4-level-logit-regression xtmelogit** - Next by thread:
**Re: st: re: beginning programming advice** - Index(es):

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