Dear Tom,
I'm really thankful for your previous help.
Now, I develop the model into a more complicated one and encounter a problem.
I attached the model in the word and following is my code.
Code: Select all
open data TD3monthc2.xls
CALENDAR(irregular)
data(format=xls,org=columns) / TT r S A X
********************************************************************
dec real L k o sigx miu N
nonlin L K o sigx miu
function opvalue p
type real opvalue
type integer p
local real ii M SS rp TTT integral F ppp TTTT pppp F
compute TTT=TT(p)
compute ppp = TTT*360
compute XX=X(p)
***************************************************
**using if function to separate pre- or in-period**
**pppp is the calculation for summation F(t,Ti) **
***************************************************
if TTT <= 1.0 / 12
compute pppp = ppp
else
compute pppp = 30
*****************
**set F initial**
*****************
compute F =0
******************
**set loop for F**
******************
while pppp > 0 {
compute TTTT = ppp / 360
*************************
**set loop for integral**
*************************
compute M = 100
compute ii = 0
compute integral = 0
while ii<M {
compute integral = integral + $
(1.0/M)*exp(2.0*o*sin(2.0*%pi*(ii*TTTT/M+L)))*exp(-2.0*k*(TTTT*(1.0-ii/M)))
compute ii = ii + 1
}
*************************
**end loop for integral**
*************************
compute F = F + $
exp(XX*exp(-k*TTTT)+miu*(1-exp(-k*TTTT))+(0.5)*sigx*sigx*integral)*exp(-k*TTTT)
compute ppp = ppp - 1
compute pppp = pppp - 1
}
******************
**end loop for F**
******************
*********************************************
**obtain sigmaF, d1, d2,and finally opvalue**
*********************************************
compute SS=S(p)
compute sigf = (sigx*exp(o*sin(2*%pi*(L)))/N/SS)*F
compute d1 = (log(SS/SS)+0.5*sigf^(2))/(sigf)
compute d2 = d1-(sigf)
compute rp=r(p)
compute opvalue = exp(-rp*TTT)*(SS*(%cdf(d1)-SS*%cdf(d2)))
end
************
**set frml**
************
frml optionprice A = opvalue(t)
********************************************
**set the initial value for each parameter**
********************************************
compute N=30,L=-0.1,k=0.1,o=0.1,sigx=0.1,miu=0.1
**********************************
**using least square to estimate**
**********************************
nlls(frml=optionprice,piters=10,iters=500,trace) A
Indeed, there is no error message but it only shows the result like the following.
---------------------------------------------------------------------------------------------------
Non-Linear Optimization, Iteration 1. Function Calls 281.
Cosine of Angle between Direction and Gradient 0.0000000. Alpha used was 0.000000
Adjusted squared norm of gradient 0
Diagnostic measure (0=perfect) 0.3000
Subiterations 0. Distance scale 0.000000000
Old Function = 633700.642178 New Function = 633700.642178
New Coefficients:
-0.090000 0.100000 0.100000 0.100000 0.100000
Nonlinear Least Squares - Estimation by Gauss-Newton
Convergence in 1 Iterations. Final criterion was 0.0000000 <= 0.0000100
Dependent Variable A
Usable Observations 197 Degrees of Freedom 192
Total Observations 198 Skipped/Missing 1
Centered R**2 -704.178541 R Bar **2 -718.869761
Uncentered R**2 -149.076410 T x R**2 -29368.053
Mean of Dependent Variable 4.107614213
Std Error of Dependent Variable 2.141235790
Standard Error of Estimate 57.450188668
Sum of Squared Residuals 633700.64218
Log Likelihood -1075.02952
Durbin-Watson Statistic 0.012088
Variable Coeff Std Error T-Stat Signif
*******************************************************************************
1. L -0.090000000 0.000000000 0.00000 0.00000000
2. K 0.100000000 0.000000000 0.00000 0.00000000
3. O 0.100000000 0.000000000 0.00000 0.00000000
4. SIGX 0.100000000 0.000000000 0.00000 0.00000000
5. MIU 0.100000000 0.000000000 0.00000 0.00000000
---------------------------------------------------------------------------------------------------
I think it's unusual, because I've set the pre-iteration and one data is missed from the sample.
Could you help me with this ?
I hope this may not be too annoying for you.
Thanks.