I have the following series of market data: date, ticker, price, volume. The data is sorted by sym and date. There are two tickers in my sample: IBM and MSFT.
I would like to run the following regression for each ticker separately: equation ls. price c price(-1) volume volume(-1).
I planned to run a loop where each in iteration I restrict the sample:
for %ticker_now "IBM" "MSFT"
smpl if ticker=%ticker_now
equation ls. price c price(-1) volume volume(-1)
...
next
My problem is that when the regression runs for MSFT, the first observation of the explanatory variables price(-1) and volume(-1) has data for IBM, instead of being missing values.
Is there a quick solution for this erroneous data handling?
Of course, the above description is a simplification of the actual problem. For example, in my actual problem the number of lags varies from one loop to another and the number of tickers are in the thousands.
I very much appreciate any help.
Best,
Basile
Controlling lag
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Controlling lag
Probably the easiest thing to do is set the page up as a panel, with date as the time ID and ticker as the cross-section ID. EViews will know not to allow lags to cross tickers then.
Re: Controlling lag
will follow your advice.
(1) will this work if I have a non-balanced panel (i.e., not all sym have data for all date)?
(2) can I push forward the start of the sample, some thing like: smpl (if ticker=%ticker_now)+1 ???
Thanks for all your help
(1) will this work if I have a non-balanced panel (i.e., not all sym have data for all date)?
(2) can I push forward the start of the sample, some thing like: smpl (if ticker=%ticker_now)+1 ???
Thanks for all your help
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Controlling lag
1) Yes.
2) Don't understand the question.
2) Don't understand the question.
Re: Controlling lag
you can do the following
smpl @first+1 @last
so, my question is whether I can do something similar, where I define my sample to be restricted to "smpl if ticker=%ticker_now" and then move the start of sample by one observation forward?
smpl @first+1 @last
so, my question is whether I can do something similar, where I define my sample to be restricted to "smpl if ticker=%ticker_now" and then move the start of sample by one observation forward?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Controlling lag
Code: Select all
smpl @first+1 @last if ticker=%ticker_nowRe: Controlling lag
The suggestion does not do the trick. It only offsets the beginning of the entire data by 1.
Assume IBM are observations 1 to 10, MSFT 11 to 20. Your suggestion will first restrict the data to observations 2 to 20, and then apply the "if" restriction. That means, "smpl @first+1 @last if ticker=%ticker_now" will give observations (2 to 10) and (11 to 20) for IBM and MSFT, respectively. I was looking to get observations (2 to 10) and (12 to 20) for IBM and MSFT, respectively. So, in essence, i would to first apply the "if" restriction, and then apply the offset by 1. Is that possible?
Thanks
Assume IBM are observations 1 to 10, MSFT 11 to 20. Your suggestion will first restrict the data to observations 2 to 20, and then apply the "if" restriction. That means, "smpl @first+1 @last if ticker=%ticker_now" will give observations (2 to 10) and (11 to 20) for IBM and MSFT, respectively. I was looking to get observations (2 to 10) and (12 to 20) for IBM and MSFT, respectively. So, in essence, i would to first apply the "if" restriction, and then apply the offset by 1. Is that possible?
Thanks
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Controlling lag
No, it doesn't do that. See for example:
Code: Select all
create a 1990 2000 10
smpl @first+1 @last if crossid=3
Re: Controlling lag
This definitely works for panel data, but not for non-panel stacked data.
thx
thx
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Controlling lag
Probably the easiest thing to do is set the page up as a panel, with date as the time ID and ticker as the cross-section ID. EViews will know not to allow lags to cross tickers then.
Who is online
Users browsing this forum: No registered users and 2 guests
