Page 1 of 1
Adjusted Sample from Equation
Posted: Wed Jul 08, 2009 8:49 am
by tchaithonov
Hi,
Is there a way to get the Sample (adjusted) from an equation and save it as a smpl object? I have lags in the model so the model cuts the original sample period short. Please let me know. Thanks guys.
Tchaithonov
Re: Adjusted Sample from Equation
Posted: Wed Jul 08, 2009 8:52 am
by startz
You can come pretty close to this with
Code: Select all
series adjustedSampleDummy = resid<>NA
smpl if adjustedSampleDummy
Re: Adjusted Sample from Equation
Posted: Wed Jul 08, 2009 8:59 am
by tchaithonov
Looks like this would do the trick. Thanks.
Re: Adjusted Sample from Equation
Posted: Wed Jul 08, 2009 9:23 am
by EViews Glenn
This is the best way to do this, but one caution...using RESID as the test series only works if the equation was just estimated. It is safer in most cases to first make the residual from the equation using the makeresid proc, then to do the test using the newly created series.
Re: Adjusted Sample from Equation
Posted: Wed Aug 05, 2009 7:57 am
by tchaithonov
Hi, I just have a follow-up question.
if I want to generate the "if" part for smpl -- say I have a bunch of cross-sections that I want to deal with -- and I have the following code and a table containing the cx numbers:
Code: Select all
!i = 1
while tab1(!i,1) <> ""
if !i = 1 then
%filter = "cx = " + @str(!i)
else
%filter = %filter + " OR cx = " %str(!i)
endif
!i = !i + 1
wend
Neither "smpl if {%filter}" nor "smpl if %filter" does not work. Do you have any ideas what I should do about this? Please let me know. Thanks.
Tchaithonov
Re: Adjusted Sample from Equation
Posted: Wed Aug 05, 2009 8:07 am
by EViews Gareth
Your else part seems to be missing a plus sign.
Re: Adjusted Sample from Equation
Posted: Wed Aug 05, 2009 8:25 am
by tchaithonov
Oops. . that's just typo .. but after the correction, it's still not working. In fact, what I am trying to do is to create 3 sets of smpl's to run 3 panel data regressions with different combinations of cx's. So, my smpl statement is this (this is within a for loop from 1 to 3):
Code: Select all
!i = 1
while tab1(!i,1) <> ""
if !i = 1 then
%filter = "cx = " + @str(!i)
else
%filter = %filter + " OR cx = " %str(!i)
endif
!i = !i + 1
wend
sample sample{!i} 01/01/2004 12/31/2008 if adjustedsampledummy AND %filter
....
Eviews keeps saying this:
Error in Sample: ILTER is not defined in "SAMPLE SAMPLE{!I} 01/01/2004 12/31/2008 IF ADJUSTEDSAMPLEDUMMY AND ILTER"
If I use %filter, it reads as "ILTER", and complains that it is not defined; if I use {%filter}, it says that there is a syntax error and {%filter} shows up as empty; . So, here's where I am stuck. Should I just run the regression right underneath a simpler sample statement, or is there a different way to go around this issue? Please let me know. Thanks very much.
Re: Adjusted Sample from Equation
Posted: Wed Aug 05, 2009 8:35 am
by EViews Gareth
You need to put %filter in braces.
This works:
Code: Select all
create m 2004 2008
series adjustedsampledummy = nrnd>0
%filter = "nrnd>0"
sample s1 01/01/2004 12/31/2008 if adjustedsampledummy and {%filter}
Re: Adjusted Sample from Equation
Posted: Wed Aug 05, 2009 8:47 am
by tchaithonov
I found out that it's related to the codes I wrote in the prior part of the program. I guess you've helped solving my mystery. Thanks Gareth.