Statalist


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

st: RE: Beginning Programming Advice


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Beginning Programming Advice
Date   Mon, 15 Oct 2007 13:39:10 +0100

You want definite advice on a fuzzily-stated problem. 

That's difficult. 

No one except Stata developers can write 
functions that can be called in -generate-
statements. 

I get the impression that you want to produce 
a new variable. Each value of the new variable
is a function of existing variables. The basic
calculation is iterative. 

It is likely that such a calculation would
have to be done observation by observation 
(but to me by no means certain). 

Whether you write a program to do this 
for individual observations, and then 
loop over observations calling this program
repeatedly, or whether your program does
everything, is very difficult to advise on 
without details. 

If you say precisely what you want, someone
may have programmed it already. 

Nick 
n.j.cox@durham.ac.uk 

Thomas Jacobs
 
> I have the following problem that I am attempting to program in Stata
> and I am a newbie:
> 
> I have a collection of companies with trading day data composed of
> accounting information, market equity values, and equity volatility
> values which I currently insheet into Stata.  I need to write a
> routine to perform a 2 variable in 2 unknown newton-raphson or
> equivalent procedure to iteratively solve for asset value and
> volatility using non-linear equations.  I know how to produce the
> routine to do so in a pseudo-code sense, where I am stuck is how to
> proceed in Stata.
> 
> Should I be attempting to write a function that I will then call in a
> generate command so that every company-tradeday instance will have
> populated values?  If so, do I need to use a function to produce a
> matrix to bring back multiple values from the function (the target
> asset value and volatility as well as any other information such as
> remaining error or iterations completed)?   If so would I then
> generate a matrix variable which I would set equal to the output of
> this function?
> 
> Is there a better way to proceed?  Can this be done in a do file as I
> bring the raw data in rather than operating on the data in memory
> after using the insheet command?  Any suggestions would be greatly
> appreciated.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index