Bv_Egarch code conversion.

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

bilal
Posts: 8
Joined: Sat Jun 16, 2012 1:32 am

Bv_Egarch code conversion.

Postby bilal » Wed Sep 05, 2012 2:34 pm

Hello.
i was searching for the Bivarite Egarch codes for simple time Series Data with 2 variables in this forum but i found the code OF "EGARCH OF Panel DATA" its brilliant work done . i tried my level best to understand it fully and reduce it to the Bi-variate Egarch Version but every time i got new error. can any one please Edit it so that i can estimate volatility spillover b/w Stock and foreign Exchange.
my variables are 1Stock indices 2Exchange Rate

THE AUTHOR used 17 countries in the panel and i guess two Variables
The code is given below
{%X} is used for different countries
i will be obliged for this help

Code: Select all

'change path to program path %path=@runpath cd %path 'load workfile containing the return series load unstacked.wf1 smpl @all %x ="us" !p = 4 !q = 2 'Estimate the conditional mean using VAR var {%x}_var.ls 1 !p e_{%x} s_{%x} @ show {%x}_var.output 'Generate residual series form var {%x}_var.makeresids() {%x}_e {%x}_s ' set sample ' first observation of s1 need to be one or two periods after the first observation of s0 sample s0 2/5/1999 8/26/2011 sample s1 2/19/1999 8/26/2011 ' initialization of parameters and starting values smpl s0 'get starting values from univariate GARCH equation {%x}_egarch1.ARCH(1,!q,EGARCH,H,BACKCAST=0.7,DERIV=AA) {%x}_e equation {%x}_egarch2.ARCH(1,!q,EGARCH,H,BACKCAST=0.7,DERIV=AA) {%x}_s ' declare coef vectors to use in bi-variate Panel EGARCH model coef(2) {%x}_alpha0 {%x}_alpha0(1)= {%x}_var.c(1,1+2*!p) {%x}_alpha0(2)= {%x}_var.c(2,1+2*!p) for !n=1 to !p coef(4) {%x}_alpha!n {%x}_alpha!n(1)= {%x}_var.c(1,!n) {%x}_alpha!n(2)= {%x}_var.c(1,!n+!p) {%x}_alpha!n(3)= {%x}_var.c(2,!n) {%x}_alpha!n(4)= {%x}_var.c(2,!n+!p) next coef(2) {%x}_beta0 {%x}_beta0(1)= {%x}_egarch1.c(1) {%x}_beta0(2)= {%x}_egarch2.c(1) coef(4) {%x}_beta1 {%x}_beta1(1)={%x}_egarch1.c(2) {%x}_beta1(2)=0 {%x}_beta1(3)=0 {%x}_beta1(4)={%x}_egarch2.c(2) coef(2) {%x}_delta {%x}_delta(1) = {%x}_egarch1.c(3)/{%x}_egarch1.c(2) {%x}_delta(2) = {%x}_egarch2.c(3)/{%x}_egarch2.c(2) for !m=1 to !q coef(2) {%x}_gamma!m {%x}_gamma!m(1)= {%x}_egarch1.c(!m+3) {%x}_gamma!m(2)= {%x}_egarch2.c(!m+3) next coef(3) {%x}_eta {%x}_eta(1) = 0.5 {%x}_eta(2) = 0.05 {%x}_eta(3) = 0.9 ' use var-cov of sample in "s0" as starting value of variance-covariance matrix series {%x}_var_e = @var({%x}_e) series {%x}_var_s = @var({%x}_s) series {%x}_z_e = {%x}_e/@sqrt(@var({%x}_e)) series {%x}_z_s = {%x}_s/@sqrt(@var({%x}_s)) series {%x}_xi = -log((1-@cor({%x}_e,{%x}_s))/(1+@cor({%x}_e,{%x}_s))) series {%x}_cor=2/(1+@exp(-{%x}_xi))-1 series {%x}_cov={%x}_cor*@sqrt(@var({%x}_e)*@var({%x}_s)) scalar E_z=@sqrt(2/@acos(-1)) ' ........................................................... ' LOG LIKELIHOOD ' set up the likelihood ' 1) open a new blank likelihood object (L.O.) name bvegarch ' 2) specify the log likelihood model by append ' ........................................................... logl {%x}_bvegarch {%x}_bvegarch.append @logl logl {%x}_bvegarch.append {%x}_e = E_{%x} - ({%x}_alpha0(1) + {%x}_alpha1(1)*E_{%x}(-1) + {%x}_alpha2(1)*E_{%x}(-2) + {%x}_alpha3(1)*E_{%x}(-3) + {%x}_alpha4(1)*E_{%x}(-4) + {%x}_alpha1(2)*S_{%x}(-1) + {%x}_alpha2(2)*S_{%x}(-2) + {%x}_alpha3(2)*S_{%x}(-3) + {%x}_alpha4(2)*S_{%x}(-4)) {%x}_bvegarch.append {%x}_s = S_{%x} - ({%x}_alpha0(2) + {%x}_alpha1(3)*E_{%x}(-1) + {%x}_alpha2(3)*E_{%x}(-2) + {%x}_alpha3(3)*E_{%x}(-3) + {%x}_alpha4(3)*E_{%x}(-4) + {%x}_alpha1(4)*S_{%x}(-1) + {%x}_alpha2(4)*S_{%x}(-2) + {%x}_alpha3(4)*S_{%x}(-3) + {%x}_alpha4(4)*S_{%x}(-4)) {%x}_bvegarch.append {%x}_z_e = {%x}_e/@sqrt(@var({%x}_e)) {%x}_bvegarch.append {%x}_z_s = {%x}_s/@sqrt(@var({%x}_s)) ' calculate the variance and covariance series {%x}_bvegarch.append log({%x}_var_e) = {%x}_beta0(1) + {%x}_beta1(1)*(abs({%x}_z_e(-1))-E_z+{%x}_delta(1)*{%x}_z_e(-1)) + {%x}_beta1(2)*(abs({%x}_z_s(-1))-E_z+{%x}_delta(2)*{%x}_z_s(-1)) + {%x}_gamma1(1)*log({%x}_var_e(-1)) + {%x}_gamma2(1)*log({%x}_var_e(-2)) {%x}_bvegarch.append log({%x}_var_s) = {%x}_beta0(2) + {%x}_beta1(3)*(abs({%x}_z_e(-1))-E_z+{%x}_delta(1)*{%x}_z_e(-1)) + {%x}_beta1(4)*(abs({%x}_z_s(-1))-E_z+{%x}_delta(2)*{%x}_z_s(-1)) + {%x}_gamma1(2)*log({%x}_var_s(-1)) + {%x}_gamma2(2)*log({%x}_var_s(-2)) {%x}_bvegarch.append {%x}_z_e = {%x}_e/@sqrt({%x}_var_e) {%x}_bvegarch.append {%x}_z_s = {%x}_s/@sqrt({%x}_var_s) {%x}_bvegarch.append {%x}_xi = {%x}_eta(1) + {%x}_eta(2)*{%x}_z_e(-1)*{%x}_z_s(-1) + {%x}_eta(3)*{%x}_xi(-1) {%x}_bvegarch.append {%x}_cor=2/(1+@exp(-{%x}_xi))-1 {%x}_bvegarch.append {%x}_cov={%x}_cor*@sqrt({%x}_var_e*{%x}_var_s) ' determinant of the variance-covariance matrix {%x}_bvegarch.append {%x}_deth = {%x}_var_e*{%x}_var_s - {%x}_cov^2 ' log-likelihood series {%x}_bvegarch.append logl =-0.5*(2*1*(660-!p)*log(2*@acos(-1)) + log({%x}_deth) + ({%x}_e^2*{%x}_var_s + {%x}_s^2*{%x}_var_e - 2*{%x}_cov*{%x}_e*{%x}_s)/{%x}_deth) ' estimate the model smpl s1 {%x}_bvegarch.ml(showopts, m=500, c=1e-6) ' change below to display different output show {%x}_bvegarch.output graph {%x}_vare.line {%x}_var_e graph {%x}_vars.line {%x}_var_s graph {%x}_coves.line {%x}_cov graph {%x}_cores.line {%x}_cor show {%x}_vare show {%x}_vars show {%x}_coves show {%x}_cores
Attachments
unstacked.wf1
work file for the given Code
(286.9 KiB) Downloaded 293 times
Last edited by bilal on Tue Sep 11, 2012 1:30 pm, edited 1 time in total.

bilal
Posts: 8
Joined: Sat Jun 16, 2012 1:32 am

Re: Bv_Egarch code conversion.

Postby bilal » Mon Sep 10, 2012 3:48 pm

Isn't this possible for the helping moderators? from the very first day i didn't get any kind of help form this forum. its very disappointing

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Bv_Egarch code conversion.

Postby startz » Mon Sep 10, 2012 4:30 pm

You want someone to program for you and you're disappointed when no one will do your work for you?

bilal
Posts: 8
Joined: Sat Jun 16, 2012 1:32 am

Re: Bv_Egarch code conversion.

Postby bilal » Tue Sep 11, 2012 9:37 am

You want someone to program for you and you're disappointed when no one will do your work for you?
it looks as if you didn't read above!....
no one is needed to program .... it is done by someone already .... the only thing needed was truncation only :wink:


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest