Generate variable with matrix (event study)
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Generate variable with matrix (event study)
Hi,
many posts on this forum allready helped me with conducting my event study, however I still have some questions. I grouped returns on 96 companies over a period of a year and estimated alpha and beta coefficients via the following program:
matrix(2,96) coefs
equation eq
for !i=1 to 96
%sname = prices.@seriesname(!i)
eq.ls {%sname} c msci
colplace(coefs, eq.@coefs, !i)
next
I now have alpha en beta estimates in a coefs file in my workfile. In my next step I would like to estimate expected returns. For all companies I want to use the company specific alpha en beta estimate and a particular day market return(single object in the market returns) in order to calculate expected return. I figured I could use the genr button, but I don't exactly know how to do it.
E(R)1 = a company1 + b company1 * market return on t=0
E(R)2 = a company2 + b company2 * market return on t=0
........
Then, I would like to create a new variable with abnormal returns. So again I have to generate and calculate Expected Return (hopefully computed via the above mentioned problem) and Actual returns (single object in the grouped returns).
AR 1= Actual Return company1 - E(R)company1
AR2 = Actual Return company2 - E(R)company2
Could someone help me create expected returns and abnormal returns?
Moreover I have to test the abnormal returns for statistical significance. If someone has an idea how to do that, please let me know also!
Regards,
Rob
many posts on this forum allready helped me with conducting my event study, however I still have some questions. I grouped returns on 96 companies over a period of a year and estimated alpha and beta coefficients via the following program:
matrix(2,96) coefs
equation eq
for !i=1 to 96
%sname = prices.@seriesname(!i)
eq.ls {%sname} c msci
colplace(coefs, eq.@coefs, !i)
next
I now have alpha en beta estimates in a coefs file in my workfile. In my next step I would like to estimate expected returns. For all companies I want to use the company specific alpha en beta estimate and a particular day market return(single object in the market returns) in order to calculate expected return. I figured I could use the genr button, but I don't exactly know how to do it.
E(R)1 = a company1 + b company1 * market return on t=0
E(R)2 = a company2 + b company2 * market return on t=0
........
Then, I would like to create a new variable with abnormal returns. So again I have to generate and calculate Expected Return (hopefully computed via the above mentioned problem) and Actual returns (single object in the grouped returns).
AR 1= Actual Return company1 - E(R)company1
AR2 = Actual Return company2 - E(R)company2
Could someone help me create expected returns and abnormal returns?
Moreover I have to test the abnormal returns for statistical significance. If someone has an idea how to do that, please let me know also!
Regards,
Rob
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
Not entirely sure I follow, but something like:
Where mrktreturn is the name of your series containing the market return.
Code: Select all
For !i=1 to 96
series er!i = coefs(1, !i) + coefs(2, !i)*mrktreturn
next
Re: Generate variable with matrix (event study)
Perfect, thank you.
I try to figure out how to do all the (very basic) programming in Eviews, instead of moving back and forward between Eviews and Excell.
I now have 96 series of expected returns. I have grouped those returns manually: however I have two more datasets that also need event study analysis, so if you have a program code to group those series at once, that would be very helpfull.
I have two groups now, for about 250 trading days, I have one group with actual returns and one group with the computed expected returns. I want to create a new group, that contains values for all trading days with abnormal returns (so actual returns - expected returns). How to do that?
Thank you in advance!
Rob
I try to figure out how to do all the (very basic) programming in Eviews, instead of moving back and forward between Eviews and Excell.
I now have 96 series of expected returns. I have grouped those returns manually: however I have two more datasets that also need event study analysis, so if you have a program code to group those series at once, that would be very helpfull.
I have two groups now, for about 250 trading days, I have one group with actual returns and one group with the computed expected returns. I want to create a new group, that contains values for all trading days with abnormal returns (so actual returns - expected returns). How to do that?
Thank you in advance!
Rob
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
You have to loop through the series one at a time. You can't do a group subtract.
Re: Generate variable with matrix (event study)
Two more questions I would like to post here on this helpfull Forum:
1) I have daily stock returns for a period of 5 years. In those years I have 1 event date per year (all companies have the samen event date, and I have have 97 companies in sample). I manualy programmed to calculate t-test statistic. Now I want to filter the test-statistic in such a way that it is only displayed for the actual event dates. The main question here is: how to create a series with 5 event dates (one per year) and the t-test statistic for that particulair day for every company?
2) I want to assess those t-statistics. Therefore I would like to count for how many companies the test statistic is significant. What I want to do is count in case the statistic is higher then a certain number (if statement?)?
1) I have daily stock returns for a period of 5 years. In those years I have 1 event date per year (all companies have the samen event date, and I have have 97 companies in sample). I manualy programmed to calculate t-test statistic. Now I want to filter the test-statistic in such a way that it is only displayed for the actual event dates. The main question here is: how to create a series with 5 event dates (one per year) and the t-test statistic for that particulair day for every company?
2) I want to assess those t-statistics. Therefore I would like to count for how many companies the test statistic is significant. What I want to do is count in case the statistic is higher then a certain number (if statement?)?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
If your workfile is daily for 5 years, then each series has around 1300 observations. You cannot create a 5 observation series. You might want to put it in a vector or table instead.
If statement seems to be what you want.
If statement seems to be what you want.
Re: Generate variable with matrix (event study)
So,
can I make a row vector for every event date? Can I work with @sample or @date? I dont really understand how to substract for every company (97) the computed t-statistic for day x...
can I make a row vector for every event date? Can I work with @sample or @date? I dont really understand how to substract for every company (97) the computed t-statistic for day x...
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
To be honest, I'm don't understand enough of what you're doing. You said that you have manually programmed the t-stat. If so, I assume you have a scalar value. You can then put that scalar value into a vector, or matrix, or table.
Re: Generate variable with matrix (event study)
Dear Gareth,
I don't get the event study done, so I post again here, since you seem to know how it all works. I also attached a sample eviews workfile, that hopefully makes it easier for me to explain my problems.
The sample workfile contains:
Daily stock returns on 9 companies for two years
Daily returns on the MSCI index
Via the following program I derive at the attached workfile:
? I make the group returns_log by clicking, what is the command to program this group? I tried:
group returns_log logr (1 to 9) but It did not work
matrix(2,9) coefs
equation eq
for !i=1 to 9
%sname = returns_log.@seriesname(!i)
eq.ls {%sname} c msci
colplace(coefs, eq.@coefs, !i)
next
For !i=1 to 9
series er!i = coefs(1, !i) + coefs(2, !i)*msci
next
for !i=1 to 9
series ar!i = logr!i - er!i
next
for !i=1 to 9
scalar stdev_ar!i = @stdev (ar!i)
next
At this point I dont get any further. I want to compute a t-statistic with some kind of the following command:
for !i=1 to 97
series ???? t_statistic!i = ar!i/stdev_ar!i
next
However I only want to do that for the event window. How can I adjust the above computation for:
1) only check for event date (for example 26/11/2002), I want someting like:
company 1 company 2 company 3 ............ company 9
26/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
Next I want to count al the t-statistic that have a value larger than value x! How to program that?
2) check for event window (for example -1 - +1, with t=0 = 26/11/2002), I want something like:
company 1 company 2 company 3 ............ company 9
25/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
26/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
27/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
Thank you very much for your help and patience,
Rob
I don't get the event study done, so I post again here, since you seem to know how it all works. I also attached a sample eviews workfile, that hopefully makes it easier for me to explain my problems.
The sample workfile contains:
Daily stock returns on 9 companies for two years
Daily returns on the MSCI index
Via the following program I derive at the attached workfile:
? I make the group returns_log by clicking, what is the command to program this group? I tried:
group returns_log logr (1 to 9) but It did not work
matrix(2,9) coefs
equation eq
for !i=1 to 9
%sname = returns_log.@seriesname(!i)
eq.ls {%sname} c msci
colplace(coefs, eq.@coefs, !i)
next
For !i=1 to 9
series er!i = coefs(1, !i) + coefs(2, !i)*msci
next
for !i=1 to 9
series ar!i = logr!i - er!i
next
for !i=1 to 9
scalar stdev_ar!i = @stdev (ar!i)
next
At this point I dont get any further. I want to compute a t-statistic with some kind of the following command:
for !i=1 to 97
series ???? t_statistic!i = ar!i/stdev_ar!i
next
However I only want to do that for the event window. How can I adjust the above computation for:
1) only check for event date (for example 26/11/2002), I want someting like:
company 1 company 2 company 3 ............ company 9
26/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
Next I want to count al the t-statistic that have a value larger than value x! How to program that?
2) check for event window (for example -1 - +1, with t=0 = 26/11/2002), I want something like:
company 1 company 2 company 3 ............ company 9
25/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
26/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
27/11/2002 t-statisctic t-statisctic t-statisctic ........... t-statisctic
Thank you very much for your help and patience,
Rob
- Attachments
-
- eviews_forum.wf1
- (203.4 KiB) Downloaded 238 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
Still not sure I follow. Perhaps you should just use the smpl command to set the sample?
Also, I'll point out that I don't really see why you have four for loops. Why not just do everything in one loop?
Also, I'll point out that I don't really see why you have four for loops. Why not just do everything in one loop?
Re: Generate variable with matrix (event study)
You are right, it does not make sense to do so many loops, It was me trying to get all the steps one by one.
The sample command works just fine to "filter" values for certain dates.
I still have two questions:
I can not get it done to generate or create a group from series, I used the following command, what do I do wrong?
for !i=1 to 97
group areturns ar!i
next
I try to convert a group into a matrix and and get rid of all the NA (due to sample) and use the following command:
matrix matrixname = @convert (groupname)
The group contains 3 rows and 97 columns, the matrix I make contains 1 row and 97 columns. Any solution for that?
The sample command works just fine to "filter" values for certain dates.
I still have two questions:
I can not get it done to generate or create a group from series, I used the following command, what do I do wrong?
for !i=1 to 97
group areturns ar!i
next
I try to convert a group into a matrix and and get rid of all the NA (due to sample) and use the following command:
matrix matrixname = @convert (groupname)
The group contains 3 rows and 97 columns, the matrix I make contains 1 row and 97 columns. Any solution for that?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
I don't understand what you mean by "generate a group from a series".
@convert uses whatever the current sample is, so if the current sample only has one row, then resultant matrix will only have one row.
@convert uses whatever the current sample is, so if the current sample only has one row, then resultant matrix will only have one row.
Re: Generate variable with matrix (event study)
What I mean is that I have multiple series and I want to group them. I normaly do so by selecting the different series and open them as a group. But I would like to run this also by the program....
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate variable with matrix (event study)
The general syntax is:
You can add a series to an existing group by:
Code: Select all
group groupname series1 series2 series3 series4 ...
Code: Select all
groupname.add seriesname
Re: Generate variable with matrix (event study)
Ok, thank you again. That was what I also found in the Eviews Help Guide, but since I have 97 series, I thought there might have been a quicker way...
@convert uses whatever the current sample is, so if the current sample only has one row, then resultant matrix will only have one row.
I had three rows, but some of the rows had some missing values. I tried again with rows without any missing values and it worked, just like you posted.
Thanks again.
@convert uses whatever the current sample is, so if the current sample only has one row, then resultant matrix will only have one row.
I had three rows, but some of the rows had some missing values. I tried again with rows without any missing values and it worked, just like you posted.
Thanks again.
Who is online
Users browsing this forum: No registered users and 2 guests
