-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about a formula implementation and how to extract the term premium #1
Comments
Thank you for the code. It worked for fitted yields perfectly. I tried to calculate term premium setting lamda0 and lamda1 to zero but it didnt work. How do you calculate the term premium? Best |
Hi, i have the same problem as skienthu and vilelalucas. Both of you arealdy calculate de term premium? I tried a lof thing but nothing till now. Could you help me? |
hello, |
I believe there is an issue with scaling of the original raw yields. Should one add: rawYields=rawYields/100 just after uploading the xls file, everything is fine and the lambdas have good magnitude therefore the term premia are OK after zeroing out the lambdas |
Yes I think that is very well spotted it works !!!. |
Can you share the the update code for the term premia |
After dividing by 100, still don't work proper. The risk neutral yields are far more lower than public data from FED and that makes the term premium bigger. Anyone know what is the problem? |
Hi Arnab, I tried your modification but the issue still not fixed when I applied to Fed data, did you solve it when plotting term premium? Can you share your code if possible? Thank you very much! |
Yes I plotted the term premium , US FRED estimates the term premium using three factor model , The whole idea of the paper was using five factors one has more accuracy in pricing yields , Term premium estimates may be different by few basis points . The codes are same , and I have used NSS parameters from GSW paper . |
Would you mind sharing your whole code that estimate term premium, either publicly or privately, with me? Working a project of term premium and really need that part to estimate TP. I would really appreciate it if that works for you! |
Yeah the negative term premium issue I overlooked , I will post the corrected codes soon .
From: radaryl ***@***.***>
Sent: 21 July 2021 00:04
To: miabrahams/PricingTermStructure ***@***.***>
Cc: Arnab Biswas ***@***.***>; Comment ***@***.***>
Subject: Re: [miabrahams/PricingTermStructure] Question about a formula implementation and how to extract the term premium (#1)
Dear Team,
Hey , the yields obtained using NSS parameters has to be continuously compounded. I have been checking the code on Indian data ( by estimating ZCYC yields across maturities using NSS parameter. The NSS parameters can be obtained from CCIL website)
Without continuous compounding there is huge mismatch between model fitted yield and observed yield. However for US one will not find the same mismatch. But one gets an abnormal term premium for US markets.
When using continuous compounding the problem associated with term premium for US market is resolved and the mismatch observed in Indian market is also addressed.
In load_gsw file only one correction is to be done.
return np.log(1+ 0.01*(Beta0 + Beta1 * (1 - np.exp(-n / Tau1)) / (n / Tau1) +
Beta2 * ((1 - np.exp(-n/Tau1))/(n/Tau1) - np.exp(-n/Tau1)) +
Beta3 * ((1 - np.exp(-n/Tau2))/(n/Tau2) - np.exp(-n/Tau2))))
and small correction in lamda0 line : lambda0 = np.linalg.pinv(beta.T) @ (a + 1/2 * (BStar @ vec(Sigma) + sigmasq_ret))
0 was multiplied to the sigmasq_ret term.
Hope the same solves the problem for you all
Thanks Michael Abrahams for providing the replication codes.
Regards
Arnab Biswas
Hi Arnab,
I tried your modification but the issue still not fixed when I applied to Fed data, did you solve it when plotting term premium? Can you share your code if possible?
Thank you very much!
Yes I plotted the term premium , US FRED estimates the term premium using three factor model , The whole idea of the paper was using five factors one has more accuracy in pricing yields , Term premium estimates may be different by few basis points . The codes are same , and I have used NSS parameters from GSW paper .
Second , one will have to apply small sample bias correction as recommender by Baur et al 2012 for more robust results.
Would you mind sharing your whole code that estimate term premium, either publicly or privately, with me? Working a project of term premium and really need that part to estimate TP. I would really appreciate it if that works for you!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://secure-web.cisco.com/1kNQ3kkkmJvlOywtXrlkLOEawWecaRPY2dWNBORJ53pIv8CR8PeDC-lI6FSqSUdApyJAtqtTvsx3M27nfF51sn9Zzf9BEapzF7Jcohl9m7QKbsINDcEgYM6_we5FhgyhDulda5_ILVW7MJPAlxeiJHzku0uq70hosI-QYIaLf5dHMH6dH358jqalW9x68O1ksQyyKHSuNItOrK3-PHrmfkoMSZU09ir_cAaWdEO1LYWwIj0ww38kKPN1iqfYvjtBqVI9aCBcQLL5FDQ2rGTGkLcX5Z01vl8LmFKOk70g6Ga9JILQGy6KMQEA5aJrTAoAYfVZRuxQwz8B6zPBltrnUkQ/https%3A%2F%2Fgithub.com%2Fmiabrahams%2FPricingTermStructure%2Fissues%2F1%23issuecomment-883607784>, or unsubscribe<https://secure-web.cisco.com/1srmSPirAlwziNgLeSKJdqPxtSB8IAMvBcJQQTCHqyMAdMgnvnJLNO_FIEUqORsmYUqd6WMCjddVCzRAYtOe7gHp1si7FnT1P9m-70FWN1WIkngPXsQto8zdEYqui2j_qjw_69ryFUOQrWNg2CMhC1iu9qPbCOJYX4MveppeGkZLBTVVd3uUPixOAHyzy0kBfJNYHlC8EnMN9yigHkRftoCHDYZNBKN4JYIec5nz5GHvPMHV2hTa0BNLWQjkuX5IMBmTrQxbEo1ueZO_cmZBirJKYCf2UirxTFohfHXqmVPBoinGqz2Bi8yq8dsCDfS4GW5-94y4dAXVpXgtbElgLgw/https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUL4CB7HFWPGQAEZLEHZADTTYW6QVANCNFSM4FZOJZQQ>.
|
Hi Peter , Regards |
Yes , I didn't saw the same before , but I got the result after implementing the continuous compounding part which I had mentioned earlier.
Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Rukus888 ***@***.***>
Sent: Thursday, September 30, 2021 2:01:00 PM
To: miabrahams/PricingTermStructure ***@***.***>
Cc: Arnab Biswas ***@***.***>; Comment ***@***.***>
Subject: Re: [miabrahams/PricingTermStructure] Question about a formula implementation and how to extract the term premium (#1)
Hi Arnab,
I saw your comments on some errors in the ACM code.
May I know apart from that, do you use the exact code for implementation,
and get this result?
Thanks
arnab13061989 ***@***.***> 于2021年9月30日周四 上午9:25写道:
Hi Peter ,
I checked the output from the code using US nss parameters and compared
with Tobias Adrian result , little difference is coming because the
unconditional mean of the VAR equation is not taken zero , Tobias Adrian
has done the analysis on demeaned yields , so the unconditional mean of VAR
will be zero , so you will find around 2005 the TP touching zero and
negative post 2011 . This extra thing has to be implemented in the code ,
over and above the continuous compounding which I had mentioned earlier
I have attached the TP plot without setting unconditional mean to zero ,
you will find the difference due to the same between the result given in
the paper and the same.
[image: without unconditional mean to zero]
<https://user-images.githubusercontent.com/85442823/135415468-9482cfbf-fc3b-48ba-ae73-50fc09915df5.jpeg>
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOCS4TAJEYJCMHCSZVIBER3UEQNGFANCNFSM4FZOJZQQ>
.
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://secure-web.cisco.com/13Z2nkIN_VNaNEFQHOK56rbTuWY_u9Do1Z2sqWwypUnsjAERCWxDaY4ceCkaMEEP9Xm7mxWNjxyxIUZ6_jFk2gdIBJbfwE1mjHfa3Dmj0O0G2hQLpfwdMyjcNKf-awE7nYfO8-81GZV1eRRlOu3Q_NSiTdyTYc7sCPoD2Cjm3Uu5bKfWEs3tMJ6CZIvGfjs9f6tEVQH_pEr9C2gC4F78VqRuFWI_7YqPQiJkJHKTSoaDw9Azb1ULsWEFUKD4GMKUtywyuA8--z5mfS8zl4JP1cdOLB9s7iZhrh72hLygoEVuoIEaTa2WJgtFACV_iNcxC/https%3A%2F%2Fgithub.com%2Fmiabrahams%2FPricingTermStructure%2Fissues%2F1%23issuecomment-931032268>, or unsubscribe<https://secure-web.cisco.com/1rd56ed4_I2zteeRhfFSkvWBIRoCGK95tbmBj8nHs6pMloLGouJH7ivAEKky09ptu2qtN56A1LMVWPS8oy1WHw1vRD5yQJAP2kOYZ2qNcKgT4oCE4y7T0ktPMQRSDN3Q0G4ofw_4H4cUFDowJ95Gdeah3Xeytox_0h-iTz7KhGkSyxn3Kw5J5JCB27gnvCHKsF2nR2zHh_fgbiA7wRLvFTPoJgOBOZA3SUGgZf2Am_Z-qqCpuT-8KTJ13izzgmvwwrjeiqZLrOTZBBnZXtEgh6w2Nzxi2pnmLolrSpGdlAT29JbEh2uV-wUNeCG5gY4MS/https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUL4CB2CTV2E5MAUTY4IAJ3UEQN4JANCNFSM4FZOJZQQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
If one is using the cc yields from US FRED , please divide by 100 before proceeding . Second my initial comments were wrong, divide the yield using nss parameter by 100 , as nss also gives cc yield |
Hey thank you for your code, I experienced some technical problems in implementing your code in R, but I tried your code in Python but didnt get the same result. One problem I have when looking at your code is: Run Bond Pricing recursionA = rep(0,n_maturities) You calculate the A[i] without adding the 'mu' term, I think the correct version should be: A[i] = A[i-1]+ t(B[,i-1])%%(mu-lambda0) +0.5(t(B[,i-1])%% Sigma %% B[,i-1]+ sigmasq_ret)-delta0 Correct me if I am wrong, thank you very much. |
I have shared revised R code by creating a new repository, you can try that.The mu term will be zero , as the VAR is done on demeaned yields .
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Rukus8199 ***@***.***>
Sent: Tuesday, 12 October 2021, 04:24
To: miabrahams/PricingTermStructure
Cc: Arnab Biswas; Comment
Subject: Re: [miabrahams/PricingTermStructure] Question about a formula implementation and how to extract the term premium (#1)
If one is using the cc yields from US FRED , please divide by 100 before proceeding
Hey thank you for your code, I experienced some technical problems in implementing your code in R, but I tried your code in Python but didnt get the same result.
One problem I have when looking at your code is:
Run Bond Pricing recursion
A = rep(0,n_maturities)
B = matrix(rep(0,n_maturities),K,n_maturities)
mat =rbind(rep(1,ncol(v)),x[,1:(ncol(x)-1)])
delta = t(rf)%% pinv(mat)
delta0 = delta[1]
delta1 = delta[,2:ncol(delta)]
A[1]= -delta0
B[,1] = -delta1
for(i in 2:(n_maturities))
{
A[i] = A[i-1]+ t(B[,i-1])%%(-lambda0) +0.5*(t(B[,i-1])%% Sigma %% B[,i-1]+ sigmasq_ret)-delta0
B[,i] = t(B[,i-1])%*%(phi-lambda1)-t(delta1)
}
You calculate the A[i] without adding the 'mu' term, I think the correct version should be:
A[i] = A[i-1]+ t(B[,i-1])%%(mu-lambda0) +0.5(t(B[,i-1])%% Sigma %% B[,i-1]+ sigmasq_ret)-delta0
Correct me if I am wrong, thank you very much.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://secure-web.cisco.com/1J3ST_BwQKz_SbBqo_wmnqN0Zaj6hiHSY5QrzSAuCKFTr779RNcbnKAs7FSOl-Q0T6-qCkZTHz9KWSqKpz9c54z2vxLtwXpa9K76Un5VpZc5tY4RXabb1Gqd12RkuM1IK4pkX3Bkcdvoy0uXDHRc4lrIBCgZ3uX3Q_xQFtW00R_ZA8BVHML5pAp_AlUc544VDKA_hAKtTfTtvEIr9iwyRJfWiP742H3AcCiul3LEXtJ5l82QxKHk4khU00JDRVNL3ttvOuYhPYs5Vm7izUr3yKfGNrGy3JhlIIfZINRyl-opZl13EldleuX2zS_WqrQPy/https%3A%2F%2Fgithub.com%2Fmiabrahams%2FPricingTermStructure%2Fissues%2F1%23issuecomment-940501145>, or unsubscribe<https://secure-web.cisco.com/1Vx1GGYWnE_7qihhWOpYLc2D5QwzFN7rFF_d_DXiUke6D6UBKxkcX3dA2V0XnNw0vy_3z9KkdNcys7oQ-7XnTNQz8l7ILCOXHXWJJYkSvxw2wXontAVc1yzmo3UDOY3k8Fsc-uXBRh-Bf3Hjm5KoOT53fXLDe82rLZPWy1xvp91zqzT_AqpAX5VlrDnItJQMCWphqquEPWlGibbpMDsprUCZtq_rHSyXDfg9tJTZobTu1u7JQiQ-iyhbIPY21IsoEZgmmX9lZvvICg4EFbhi7dcZKqSWDcmx8o65KDCD_3RvjUhhlpgipm4O9lhaWr53-/https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUL4CB6LSIMEBWLNWL4K633UGNTJDANCNFSM4FZOJZQQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://secure-web.cisco.com/1hPPhQATtylRK2COeWD9Y8JR5Wynundt-ySwO9d3AX_b28fErQ7QHvugwInXSIgZYYpC-U9OmMgsdLqRPGEgc4EEdyycpHSHDb2hQwhLWeKcVTfE4G8wT5ermIF_WKZC3JY1P-sPg0HaetU4JuVAarM-cBNq1ax-Rfok0oEXMG7UmF6rfuadW_Y30A5NBJkZ347OuelvWrN-nr69ZH37nHtdDnMAw7ZppoMVreySVsPvEHB7M_m8qvRfll0XprkX4T635ygZ-A9p7ZhA8-vJa1YE3yw-2nWX3P9kqp5Ai8B0g7DADZhhHUHHkroNHplvC/https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub>.
|
Has anyone managed to rebuild the Abrahams and ACM model done on TIPS? |
I think the process will be same , One will get the expected real rates and real risk premium using the same set of codes from TIPS yields . One can referer "Pricing TIPS and Treasuries with Linear Regressions" by same authors for details |
I tried running this code with TIPS and was unable to recreate the authors output. I’ll have to look closer at their paper. Thank you for sharing your code btw, it is very helpful! |
Hi;
The fitted yield is quite good , have a question about this code snippet
for i in range(0, n_maturities - 1):
A[0, i+1] = A[0, i] + B[:, i].T @ (mu - lambda0) + 1/2 * (B[:, i].T @ Sigma @ B[:, i] + 0 * sigmasq_ret) - delta0
B[:, i+1] = B[:, i] @ (phi - lambda1) - delta1
why are we multiplying "sigmasq_ret" with 0 here, looking at the paper this should be 0.5 .
Als how would you go about calculating the term premium, with this code.
The text was updated successfully, but these errors were encountered: