Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Solving simultaneous equations


From   Rohit Sonika <[email protected]>
To   Statalist <[email protected]>
Subject   st: Solving simultaneous equations
Date   Fri, 3 May 2013 15:13:28 +0100

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index