SAS中文论坛
标题:
十万火急,请各位大虾帮忙。
[打印本页]
作者:
shiyiming
时间:
2004-11-12 01:16
标题:
十万火急,请各位大虾帮忙。
万分着急,请各位大侠帮助。
现在要做一个极大似然估计,具体情况如下:
logf=sigma1[-1/2*log(2*pi*theta)]-sigma1[(r+alpha1-beta1*dr-beta2*ds)**2/2*pi**2]
+sigma2[-1/2*log(2*pi*theta)]-sigma2[(r+alpha2-beta1*dr-beta2*ds)**2/2*pi**2]
+sigma0{log[probnorm((alp2-beta1*d*rf-beta2*d*sz)/sig)-probnorm((alp1-beta1*d*rf-beta2*d*sz)/sig)]}
不好意思,不知道怎么表达求和符号。只好用sigma表示,这个式子比较复杂。解释如下:
给定一列某债券的收益率,即式中的r,r的取值肯定有正有负也有0,那么sigma1就表示对所有收益率为正的那些求和;sigma2表示对所有
收益率为负的求和;而sigma0则表示对所有收益率为零的求和。
式子中的其他变量解释如下:
pi即圆周率;theta,alpha1,alpha2,beta1,beta2是待估参数;dr和ds则是两列其他变量(例如无风险利率和上证指数)的收益率,是已知
的。
函数logf即似然函数,现在要估计theta,alpha1,alpha2,beta1,beta2,只能用最大似然估计,可是我不会编这个程序,还请哪位大虾帮忙
。多谢。
这个周末就要交毕业论文了,可是估计还没有结果,十万火急呀。
附上一列数据备大虾估计。
r dr ds
0.00086 0.011819507 0.003612378
-0.00134 0.003570198 -0.001617382
-0.00038 -0.053580902 0.009298623
0.00038 0.003132419 -0.003952386
-0.00279 0.007198501 -0.016151718
0.00067 -0.00587429 -0.004260436
0.00019 -0.003840851 -0.008215036
0.00193 -3.29544E-05 -0.007286044
-0.00087 0.004943317 -0.01288279
0.00087 -0.009214928 0.008012523
-0.00231 0.004468275 0.002426384
-0.0026 0.001911164 -0.000251733
0.00203 -0.004275472 0.000125898
-0.0027 0.003534152 0.006807332
-0.00116 -0.000131653 -0.00539558
-0.00039 0.003324665 0.000937987
0.00039 -0.009383202 -0.006443822
-0.00029 -0.000629264 -0.012086384
0.00077 0.002916321 0.005511811
0.00019 -0.00036348 -0.001722788
-0.00097 -0.00076028 -0.001431597
0.00039 -0.004697476 -0.004624993
-0.00155 -0.008841028 0.003008869
0.00029 -0.03091781 0.003422771
0.00097 0.002941278 -0.003411096
0.00029 -0.011109578 0.005380046
0.00097 0.003523829 -0.000450014
-0.00048 0.001147307 0.008700929
0.00019 0.00093763 -0.003124333
-0.00077 0.004128647 -0.004126922
0.00077 -0.002556838 -0.00410493
-0.00077 -0.003671886 -0.003287666
-0.00097 -0.001321188 0.001811719
0.00165 -0.003098454 0.004049339
-0.00039 -0.00136197 -0.000401343
-0.00029 0.003986572 0.010869991
-0.00097 0.007279693 -0.004688741
-0.00039 0.002213078 8.75981E-05
-0.0001 -0.001483628 0.008574126
0.00184 0.010850035 0.000260537
-0.00048 0.001435701 -0.004061394
-0.00068 -0.000512015 -0.001210794
-0.00078 0.009323452 -0.00015517
0.00155 -0.003451309 0.00440362
-0.00097 0.00679071 -0.002250099
0 0.01568191 0.004597456
-0.00048 0.005777468 -0.000693688
-0.00126 -0.004060612 -0.000684529
0.0001 -0.002916998 0.005759768
0.00146 0.005518617 0.012067494
-0.00165 0.006314885 -0.002758163
-0.00107 -0.008016559 0.00736594
-0.00136 0.001523532 -0.001217107
0.00185 0.000992096 0.000151143
-0.00194 0.004856454 -0.00015112
0.00282 -0.001479484 -0.003353486
0.00097 -0.002996279 -0.003980854
-0.00136 -0.00336856 0.004149022
0.00243 -0.015176619 0.004122402
0.00136 0.002893674 -0.002736985
0.00097 0.011373549 -0.008545795
-0.00377 0.00530768 0.000610903
0.0001 -0.00323379 0.004464499
0.00184 -0.005031946 0
-0.00039 -0.00455831 -0.000151954
0.00019 -0.002573701 0.013241007
-0.00087 0.003284072 0.02307988
0.00058 0.003139717 -0.003546067
0.0001 -0.007624946 -0.005554125
0.00029 -0.009797343 -0.003291907
0.00087 -0.001558688 0.006039633
0.00058 -0.003393742 0.003135403
0.00058 0.004631206 0.001139926
0 0.001796488 0.002130336
0.00329 0.002402301 0.012205067
0.0001 -0.005029366 -0.00602895
-0.00096 0.00071242 0.001411645
0.00135 0.000203404 0.000427444
-0.00039 0 -0.002254484
-0.00058 0 -0.00409093
-0.00039 -0.002382654 -0.000997201
-0.00029 0.00433314 -0.011483832
-0.00116 0.000781356 0.008467432
0 0.006110187 0.005833341
0.00019 0.002058099 0.01286852
0.00174 -0.005993266 0.011451655
0.00145 0.00511483 0.018222179
0.00212 -0.004616992 -0.004745436
-0.00086 -0.00145585 0.001636272
0.0001 0.004407826 -0.004488007
-0.00048 -0.004861088 -0.006149204
0 0.005766817 0.006320406
0.0025 -0.002360957 0.008203735
0.0001 0.004158356 -0.004479714
0.00115 0.002693421 0.00081736
0.00077 -0.001275938 -0.022841035
-0.00038 0.009077461 0.000835782
0.00278 0.002365563 -0.004319092
0.00076 -0.001861393 0.016341254
-0.0021 0.001498551 0.007835169
-0.00038 -0.006051739 -0.017045254
0.00086 -0.011073197 -0.001388342
-0.00038 -0.012415006 -0.005274063
-0.00048 0.003117079 -0.013543611
0.00163 -0.003892778 -0.000283366
0.00048 -0.001028419 0.001417234
0.00086 0.005902337 0
-0.00267 -0.005560673 0.000136958
0.00182 -0.01135506 -0.005797075
0 -0.000763385 -0.000707051
0.00038 -0.000277807 0.008536563
-0.00029 -0.000208413 -0.002259578
0.00038 -0.019525414 -0.008200389
0.00238 -0.009886255 0.000285428
0.00095 -0.003256746 0.006268409
0.00276 -0.003123766 0.005808582
-0.0018 -0.002377179 0.008030485
0.00009 -0.001516355 -0.001533756
0.00038 -0.02881834 0.00951486
0.00427 0.007669682 0.008037808
-0.00028 -0.006724552 0.007565264
0.00189 -0.003422237 -0.000141004
0 -0.002202232 -0.004777182
0.00028 -0.009314679 0.002063517
0.00094 0.013442586 0.001361061
-0.00085 -0.002011997 -0.003000856
0 -0.006682845 -0.00233709
0 -0.008682252 0.003300886
0 -0.002578199 0.006986884
0.00132 -0.0071844 -0.001089066
-0.00094 0.009342216 0.007763661
0.00141 -0.018170093 0.002024115
0 -0.009156589 0.013077928
0.00217 0.00448413 0.003463628
-0.00075 -0.001086914 -0.008753372
-0.00301 -0.000932655 0.014179188
0.00075 0.000388969 0.000928655
0 -0.003382713 -0.003166416
0.00368 0.002145755 -0.000922202
-0.00366 -0.007202087 0.015486782
0.00179 -0.035761901 0.011336952
0.00075 0.006303375 -0.005409364
-0.00019 0.000444534 -0.012961042
-0.00113 -0.022378413 0.01155447
-0.00009 0.012478308 0.027294973
0.0016 -0.012936663 -0.000318152
0.00094 0.002067226 -0.012542434
0.00263 -0.01716384 0.008305305
0.00131 -0.004072037 0.00371275
0.0043 0.005943349 0.005479116
0.00251 0.017096166 0.017923272
-0.00297 0.00881638 0.007076582
-0.00075 -0.000980112 -0.008904381
0.00037 0.000327024 -0.002358
-0.0013 0.00608884 -0.006794273
-0.00019 -0.003777417 -0.001113235
0.00205 -0.007134994 0.001275994
0.00149 -0.005215177 -0.008581822
0.00084 -0.00255934 0.003042654
-0.00019 -0.000165542 0.00511789
0 0.001407343 0.000476098
0.0013 0.018476419 0.001113056
0.00306 0.00588474 0.00031421
-0.00046 0.000161388 0.000161082
-0.00093 0.007947073 0.00777903
0 0.005963339 0.018266665
-0.00019 0.032981898 0.001082931
-0.00704 0.003427823 0.007572313
-0.00112 -0.008559475 0.01088411
0.0028 -0.008788231 0.024112056
-0.00093 -0.016755849 -0.000293083
0.00084 -0.000397235 -0.006818062
-0.00084 -0.003059927 -0.002830717
0.00056 0.001355284 0.000447825
0.00084 -0.0059711 0.000447624
-0.00028 -0.010892635 -0.006279102
0.00168 -0.007328232 0.000908134
0.00158 0.005750877 0.014570324
-0.00158 0.00141936 0.001187363
0.00186 0.013120596 0.004736313
0.00158 -0.015348949 0.012954123
-0.00158 0.009945604 -0.00639423
-0.00046 0.017605209 0.004238295
0 -0.017103132 0.000443475
0.00046 0.034640733 -0.000443279
0 -0.007302105 -0.005240401
-0.0026 -0.008177479 -0.001612352
0.00168 0.00666693 0.004696024
0.00093 0.00317423 -0.010511111
-0.00046 0.004140787 0.000733637
-0.00084 0.003812488 -0.015626987
-0.00205 -0.012091617 0.003898473
0.00056 0 -0.002240676
0.00214 0 0.013701852
-0.00111 0.005628667 0.000119749
-0.00009 -0.000157667 0.002873628
0.00121 -0.000157691 0.000156701
0.00019 -0.004061194 -0.002402376
0.00046 0.000712617 -0.000553428
0.00046 0.006171618 0.011508703
0.00037 0.006605591 -0.00175327
-0.03702 -0.009257451 0.012005425
-0.00183 -0.00370604 -0.006942054
-0.00106 0.002651365 -0.003355185
0.00068 0.001223507 -0.00686614
0.00251 0.000591296 -0.001467652
-0.00067 -0.027104755 0.004125911
0.00116 0 -0.005431552
-0.00106 0.012310184 0.000889035
0.00096 -0.004280171 -0.005605649
-0.00183 -0.008315925 -0.004000871
0.00039 0.016973871 -0.001492222
0.00029 -0.001354366 -0.002083176
0.00087 -0.00259274 0.00746517
-0.00019 0.014197161 0.009339269
0 -0.014392744 -0.006456172
0 -0.012722545 -0.00488108
0.00029 0.018721887 -0.005055482
0.0001 -0.008791121 -0.006419514
-0.00048 0.025965166 -0.009314785
0.00077 0.002542539 -0.027738516
-0.00019 -0.01658213 0.000339736
0.00116 0.020591153 0.010472941
0 0.007619344 -0.000695649
0 0.000308642 -0.007031733
0.0001 0.005862388 -0.025490351
0.00048 0.012308282 0.00125289
-0.00048 -0.00715882 -0.005150603
-0.00038 0.017320311 0.01381146
-0.0001 0.000375009 0.012062465
-0.00029 -0.005060729 -0.001763682
0.00029 0.011378622 -0.00448434
0.00048 -0.029095109 0.001742923
-0.00135 0.035300437 -0.00363073
0.00019 0.005633385 0.003739644
-0.00019 -0.006523181 -0.001088321
-0.00125 -0.007270839 0.001693904
-0.00058 -0.067037854 -0.002604043
-0.00019 0.006488565 -0.005301282
0.0001 0.002984599 -0.004561314
0.0027 0.013172512 -0.013039214
0.0001 -0.008302005 -0.000407259
-0.0025 0.010819776 0.000782256
0.00135 -0.001250098 0.004641014
0.00067 0.016858327 0.003906377
-0.00019 0.009924222 -0.005529991
-0.00039 -0.001599695 0.013280838
-0.00039 0.034105215 0.000416597
0 0.003689084 0.007103217
0.00048 0.003749035 -0.01259542
-0.00193 0.011644513 0.00934158
0 -0.015057733 0.004236612
0 0.019955165 -0.003241517
0.0001 0.005080349 -0.000820985
0.00019 -0.020003585 -0.009197805
0.00106 0.002743534 -0.006940251
-0.00039 -0.012914052 0.004418644
-0.00019 0.006245842 0.002478085
-0.00067 0.000293826 0.002496115
-0.00029 -0.005067009 -0.002754954
0.00068 -0.004096394 -0.002198776
-0.00087 0.004076188 -0.004068223
0 0.008156185 -0.003444559
0.00048 0.001208039 -0.000984076
-0.00039 -0.012577697 0.00608937
0 -0.011738132 -0.009847473
0.00029 -0.000936716 0.006488624
-0.00058 0.007050705 -0.00742112
0.0001 0.004729629 -0.013317191
0 -0.004003114 0.006789919
-0.00087 0.000186074 -0.009832097
-0.00048 0.009153148 -0.010254065
0.00039 0.001511688 -0.010570363
0 -0.008651474 -0.008916895
0 0.007427213 -0.030950096
0.00048 0.015482159 -0.03936618
-0.00048 0.003085523 0.100073638
0 -0.001664676 -0.012233081
0 -0.010657194 -0.015569674
0.00048 -0.009159858 0.001368189
-0.00116 0.012498613 0.010320441
0.00039 -0.002958256 -0.000816521
-0.00019 -0.018058608 0.000272396
-0.00058 0.007759167 0.005514518
-0.00087 -0.002146955 -0.001167947
-0.00048 0.015580369 -0.002728397
0.00048 -0.00489462 -0.005148858
-0.00126 0.006240135 -0.031240926
0.00087 -0.009265677 0.006338599
0.00165 0.002061932 0.010048094
-0.00029 -0.0006614 -0.007554337
0.00019 -0.00029415 -0.003626766
-0.00058 -0.000183898 0.001341964
-0.00029 0.002832549 0.002391276
-0.00077 -0.006089285 0.00844999
0.0001 -0.0071969 0.01181058
-0.0001 -0.005687732 0.013436901
0 0.008038285 -0.002247818
0.0001 0.003708924 -0.00194798
作者:
shiyiming
时间:
2004-11-12 01:22
标题:
附上我自己编的一段程序
肯定是错误百出,请别见笑。
data par1(type=est);
keep _type_ sig alp1 alp2 beta1 beta2;
_type_='parms'; sig = .5;
alp1 = .5; alp2 = 0.5;beta1=.5;beta2=.5; output;
proc nlp data=paper.qz tech=tr inest=par1 outest=opar1
outmodel=model cov=2 vardef=n pcov phes;
max f;
parms sig alp1 alp2 beta1 beta2;
profile sig alp1 alp2 beta1 beta2 / alpha = .9 to .1 by -.1 .09 to .01 by -.01;
x1_th = (r+alp1-beta1*d*rf-beta2*d*sz)**2;
s1 = - x1_th / 2*sig**2;
if r<0 then s1 + (-.5)*log(2*3.14*sig);
f1 = s1;
x2_th=(r+alp2-beta1*d*rf-beta2*d*sz)**2;
s2 = - x2_th / 2*sig**2;
if r>0 then s2 + (-.5)*log(2*3.14*sig);
f2 = s2;
x3_th=log(probnorm((alp2-beta1*d*rf-beta2*d*sz)/sig)-probnorm((alp1-beta1*d*rf-beta2*d*sz)/sig));
s3=x3_th;
if r=0 then sums3+s3;
f3=s3;
f=f1+f2+f3;
f=f1;
run;
欢迎光临 SAS中文论坛 (http://mysas.net/forum/)
Powered by Discuz! X3.2