Building an array from the data to use in a loop
Posted: Thu Feb 06, 2014 1:09 pm
I'm working with panel data based upon FYQuarters and location. I am running an LS regression with 5 dependent variable, of which 2 have unique lags. I've created a loop to run the unique lags, but I can't seem to figure out how to build an array to restrict the sample for each location and run the LS regressions separately. I currently have it hard coded, but everytime I make changes to the LS model, I'm having to change it multiple times.
Is there a way to take the unique values determining the cross section and have it build an array of those values and then loop through the regression for each of those? Ideally, I would want it to determine that array from the data rather than having me hard code each location.
I'm using Eviews 7 and my code is:
Is there a way to take the unique values determining the cross section and have it build an array of those values and then loop through the regression for each of those? Ideally, I would want it to determine that array from the data rather than having me hard code each location.
I'm using Eviews 7 and my code is:
Code: Select all
!maxi=5 'max number of lags for CERP
!maxk=9 'mac number of lags for State
' The following section is setting the headings row for the Results output table
'******NOT DONE YET/INSERT HERE **********
'Regression for RC-Capital
smpl if rc="RC-CAPITAL"
table RCC ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCC!i!k
RCC!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
rcc(!r,1) = "RCC - " + @str(!i) + ", " + @str(!k)
rcc(!r,2) = rcc!i!k.@rbar2
!maxn = rcc!i!k.@ncoef
for !n = 1 to !maxn
rcc(!r,!n*2+1) = rcc!i!k.@coefs(!n)
!pval = @tdist(rcc!i!k.@tstats(!n), rcc!i!k.@regobs - rcc!i!k.@ncoef)
rcc(!r,!n*2+2) = !pval
next
!r = !r+1
next
next
'Regression for RC-EAST
smpl if rc="RC-EAST"
table RCE ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCE!i!k
RCE!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
RCE(!r,1) = "RCE - " + @str(!i) + ", " + @str(!k)
RCE(!r,2) = rce!i!k.@rbar2
!maxn = rce!i!k.@ncoef
for !n = 1 to !maxn
RCE(!r,!n*2+1) = rce!i!k.@coefs(!n)
!pval = @tdist(rce!i!k.@tstats(!n), rce!i!k.@regobs - rce!i!k.@ncoef)
RCE(!r,!n*2+2) = !pval
next
!r = !r+1
next
next
'Regression for RC-North
smpl if rc="RC-NORTH"
table RCN ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCN!i!k
RCN!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
RCN(!r,1) = "RCN - " + @str(!i) + ", " + @str(!k)
RCN(!r,2) = rcn!i!k.@rbar2
!maxn = rcn!i!k.@ncoef
for !n = 1 to !maxn
RCN(!r,!n*2+1) = rcn!i!k.@coefs(!n)
!pval = @tdist(rcn!i!k.@tstats(!n), rcn!i!k.@regobs - rcn!i!k.@ncoef)
RCN(!r,!n*2+2) = !pval
next
!r = !r+1
next
next
smpl if rc="RC-SOUTH"
table RCS ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCS!i!k
RCS!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
RCS(!r,1) = "RCS - " + @str(!i) + ", " + @str(!k)
RCS(!r,2) = rcs!i!k.@rbar2
!maxn = rcs!i!k.@ncoef
for !n = 1 to !maxn
RCS(!r,!n*2+1) = rcs!i!k.@coefs(!n)
!pval = @tdist(rcs!i!k.@tstats(!n), rcs!i!k.@regobs - rcs!i!k.@ncoef)
RCS(!r,!n*2+2) = !pval
next
!r = !r+1
next
next
smpl if rc="RC-SOUTHWEST"
table RCSW ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCSW!i!k
RCSW!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
RCSW(!r,1) = "RCSW - " + @str(!i) + ", " + @str(!k)
RCSW(!r,2) = rcsw!i!k.@rbar2
!maxn = rcs!i!k.@ncoef
for !n = 1 to !maxn
RCSW(!r,!n*2+1) = rcsw!i!k.@coefs(!n)
!pval = @tdist(rcsw!i!k.@tstats(!n), rcsw!i!k.@regobs - rcsw!i!k.@ncoef)
RCSW(!r,!n*2+2) = !pval
next
!r = !r+1
next
next
smpl if rc="RC-WEST"
table RCW ' Results table to store regression statistics
!r = 2 ' row for collecting each models data
for !i=0 to !maxi
for !k=4 to !maxk
equation RCW!i!k
RCW!i!k.ls cas cerpspnd_sa_ln(-!i) stspnd_sa_ln(-!k) time log(nato)
RCW(!r,1) = "RCW - " + @str(!i) + ", " + @str(!k)
RCW(!r,2) = rcw!i!k.@rbar2
!maxn = rcw!i!k.@ncoef
for !n = 1 to !maxn
RCW(!r,!n*2+1) = rcw!i!k.@coefs(!n)
!pval = @tdist(rcw!i!k.@tstats(!n), rcw!i!k.@regobs - rcw!i!k.@ncoef)
RCW(!r,!n*2+2) = !pval
next
!r = !r+1
next
next