Estimating standard deviation of residuals by using Loop

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

muenzmax
Posts: 4
Joined: Tue Sep 05, 2017 10:15 am

Estimating standard deviation of residuals by using Loop

Postby muenzmax » Tue Sep 05, 2017 10:47 am

Hi there,
I'm new of programming and this is the first time to write a Eviews code.
I was trying to get the standard deviation of residuals to estimate the idiosyncratic risk of my portfolios. I used daily returns (y1 to y11) as my dependent variables, X1 X2 represents indexes returns and X3 represents currency returns. I have a daily data from 02/02/2009 to 11/03/2016, but I was trying to get the quarterly standard deviation of residuals to run the cross-sectional regression. I was managed to run this daily data 1865 times to get residuals, however, my data was not sorted by quarters and not following logic order, that is , sample periods between 1 to 42 represent 2009Q1, 43 to 107 represent 2009Q2 and so on. So I have to manually set up my testing periods.( this may sounds stupid)
Now I'm trying find alternative ways to write this codes to make it looks better and don't have to manually change the series name. Please see the attachment for my codes.

Any help would be highly appreciated!
Attachments
loop.prg
(2.11 KiB) Downloaded 10 times

EViews Matt
EViews Developer
Posts: 154
Joined: Thu Apr 25, 2013 7:48 pm

Re: Estimating standard deviation of residuals by using Loop

Postby EViews Matt » Wed Sep 06, 2017 10:02 am

Hello,

First, you're needlessly performing the exact same regression 1856 times, it doesn't need to be inside a loop. The regression will automatically cover all the observations (or the current sample). Second, you can calculate the quarterly standard deviations much more compactly via @stdevsby, e.g.: @stdevsby(e11, @quarter, @year).

muenzmax
Posts: 4
Joined: Tue Sep 05, 2017 10:15 am

Re: Estimating standard deviation of residuals by using Loop

Postby muenzmax » Wed Sep 20, 2017 4:14 pm

Hello Matt,

Thank you for your replay. Your code worked perfectly.
Now I've got a new question regarding the structure of my data. I have 11 firms, 7 variables, 29 firm-quarters. However, only 3 variables contain 11 cross-sectional data (11 series in one company), the other 4 only have time-series data(one series in one company) . Therefore, this cannot be structured as panel or pool and will lead to "Near singular matrix ". Should I create an unbalanced panel for that? I have read though the forum but haven't able to find an answer for my question.

Thanks in advance!

EViews Matt
EViews Developer
Posts: 154
Joined: Thu Apr 25, 2013 7:48 pm

Re: Estimating standard deviation of residuals by using Loop

Postby EViews Matt » Thu Sep 21, 2017 10:30 am

Let me rephrase your description of your data to see if I understand you correctly. For 3 of your variables you have data for all 11 firms, but you also have 4 additional variables that each apply to 1 firm only? In other words, there are 7 firms for which you have 3 variables and 4 firms for which you have 4 variables?

muenzmax
Posts: 4
Joined: Tue Sep 05, 2017 10:15 am

Re: Estimating standard deviation of residuals by using Loop

Postby muenzmax » Thu Sep 21, 2017 11:22 pm

Hi Matt,

Thank you for your reply and sorry for misunderstanding.
I have 11 firms, 7 variables, 29 firm-quarters. Among these 7 variables:
1) 3 of them I considered as firm-specific proxy,these 3 variables have 11 series for each firms such as returns,dividend, residuals standard deviation.
2) other 4 variables for country proxy, but only have one series such as US volatility and UK volatility etc.
My question is that when I want to put them altogether in one pool, these 7 variables don't have same number of series.
Should I consider it as unbalanced panel? Or just analysing it as time-series data.

Thank you very much!

EViews Matt
EViews Developer
Posts: 154
Joined: Thu Apr 25, 2013 7:48 pm

Re: Estimating standard deviation of residuals by using Loop

Postby EViews Matt » Fri Sep 22, 2017 9:09 am

Hello,

If you have all 29 quarter observations for all series, it wouldn't be an unbalanced panel. It sounds more like a pooled data. Specifically, the 3 firm variables would be structured by a pool object and the remaining 4 country variables would be what the EViews documentation calls "ordinary series".

muenzmax
Posts: 4
Joined: Tue Sep 05, 2017 10:15 am

Re: Estimating standard deviation of residuals by using Loop

Postby muenzmax » Fri Sep 22, 2017 11:15 am

Hello Matt,

Thank you for your reply!
My regression equation will be something looks like this?
Y? C dividend? Residual? Volatility_us volatility_uk
Which simply add the non- pooled variables at the end of the equation?

Thank you in advance!

EViews Matt
EViews Developer
Posts: 154
Joined: Thu Apr 25, 2013 7:48 pm

Re: Estimating standard deviation of residuals by using Loop

Postby EViews Matt » Fri Sep 22, 2017 1:16 pm

Yes, I imagine something like that would work.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 4 guests