On Wed, 10 Mar 2010, Riccardo (Jack) Lucchetti wrote:
On Wed, 10 Mar 2010, Peter Bl�meke wrote:
> So far I have I have developed my problem as follows:
>
> My data consists of monthly stockreturns of 612 companies and corresponding
> indexreturns of two stock indices. My data is organized as "stacked cross
> section": All return of the first month of all 612 companies among each
> other and then of the second month below that and so on. It is
> 110160x3-matrix.
>
> Gretl should run 612 times one regression. So it would look roughly like
> this: stockreturn = beta0 + beta1*indexreturn1 + beta2*indexreturn2 +
> errorterm
>
> In the end I need a 612x2-matrix with all beta1 and beta 2 coefficients.
If the index returns are the same in all regressions, you may want to
reshape your dataset like this
date company1 company2 ... company611 company612 index1 index2
... your data here ...
and then do
list Y = company*
list X = const index1 index2
matrix B = mols({Y}, {X})
matrix B = B[2:3,]'
of course, you'd have to reshape your data to a pure time-series format
(as opposed to panel), which is probabily going to be tedious, but having
done that, the rest should take you just a few seconds.
Good idea, but not too tedious to reorganize a panel into distinct
time series. Here's an illustration, using one of the supplied
datasets.
<script>
# 6-firm panel, 15 time periods, 4 relevant variables
open greene14_1.gdt
# list the (4, in this case) variables we want
list X = 3 4 5 6
scalar nvars = 4
scalar nunits = 6
scalar T = 15
matrix M = mshape({X}, T, nvars*nunits)
nulldata T --preserve
k = 1
loop i=1..nvars -q
loop j=1..nunits -q
series x$i$j = M[,k]
k++
endloop
endloop
print --byobs
</script>
Now series x11 to x12 contain the separate time series for the
first original variable, series x21 to x26 contain the time series
for the second original variable, and so on.
Allin Cottrell