**announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Aljar Meesters <aljar.meesters@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Solving simultaneous equations |

Date |
Fri, 3 May 2013 19:54:48 +0200 |

Dear Rohit, Your program works for me after some minor adjustments but I am using Stata 12.1 so you may need to update (see -help update-). The adjustments that I need to make are replacing set obs 10000 with set obs 2 and add scalar n = 1. You have two equations that you want to solve and thus you only need two observations, one for each equation. The scalar n = 1 is needed since you multiply by n by generating your a variable. Best, Aljar Best, Aljar 2013/5/3 Rohit Sonika <net@rsonika.me>: > Hi, > > I have never programmed in Stata, so I am reaching out to the community for some help. Here is my problem: > > I have two equations, with two unknowns as follows: > > 1. price = val - (a/b)*(val*normal(price/strike) - strike*normal(price/strike)) > 2. sd = vol * (val/price) * (1-(a/b)*strike*normal(price/strike)) > > The two unknowns in the above equations are 'val' and 'vol' while the other variables are observed. > > I am taking a numerical approach to trying to solve for above equations. Since, I create a dataset and declare variables as follows: > > set obs 10000 > gen double price = (100-1)*runiform()+1 > gen double strike = (100-1)*runiform()+1 > gen rate = 0.0025*int(60*runiform()) > gen double b = 100 > gen double a = (0.15-0.0001)*runiform()*n > gen double sd = (0.30-0.05)*runiform()+0.05 > > The program I created to populate values of 'val' and 'vol' is as follows: > > program nlwar > syntax varlist(min=1 max=1) [if], at(name) > > tempname val vol > scalar `val' = `at'[1,1] > scalar `vol' = `at'[1,2] > > tempvar abc > gen double `abc' = `val' - (a/b)*(`val'*normal(`val'/strike * `vol') - strike*normal(`val'/strike)) - price + 1 in 1 > replace `abc' = (`vol'/sd) * (`val'/price) * (1-(a/b)*strike*normal(`val'/strike)) - 1 in 2 > > replace `varlist' = `abc' > end > > gen y = 0 > replace y = 1 in 1 > nl war @ y, parameters(val vol) initial(val 1 vol 1) > > When I run the above program, Stata gives me an error stating 'verify that nlwar is a function evaluator program'. > > Any help on this query would be appreciated. I am using Stata version 12. > > Thanks! > Rohit > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Solving simultaneous equations***From:*Rohit Sonika <net@rsonika.me>

**References**:**st: Solving simultaneous equations***From:*Rohit Sonika <net@rsonika.me>

- Prev by Date:
**Re: st: xtoverid error: internal reestimation of eqn differs from original?** - Next by Date:
**Re: st: Solving simultaneous equations** - Previous by thread:
**st: Solving simultaneous equations** - Next by thread:
**Re: st: Solving simultaneous equations** - Index(es):