[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: Avoiding loops (the while loop)
> 1) Yes, there are 21 variables. Sorry, it was a typo on my part.
> 2) I want to avoid loops because this is part of a simulation
> exercise, and
> loops in stata (as in any other statistical package) is very
> slow. First, I
> have to do month by month regression for 1000 months. Second,
> I have to
> repeat this exercise for 1000 simulation rounds. Now, even with 1500MB
> memory I am allocating, the whole exercise takes 8-10
> hours... And I have
> variations of these tests.
This is a misconception on your part, I think.
Looping over observations can be very slow in Stata, but
we are not doing that.
In this kind of example, the interpretative overhead of
a loop should be minor. Sure, you have a substantial
amount of work to do, but avoiding loops is not an
answer, I think. There is some overhead in the
fact that -regress- is giving more results than
you want to use. I guess you could reduce that
by writing a plugin in C or C++. The time overhead
on that might not be great, especially in the
possible extreme case that you have to learn C first.
> 3) Let me try the code you are suggesting.
> 4) I am attaching my code below for perusal if necessary.
> Variables Nobs
> month 1000
> ret1 1000
> ret2 1000
> ret3 1000
> ret4 1000
> ret5 1000
> ret6 1000
> ret7 1000
> ret8 1000
> ret9 1000
> ret10 1000
> pbeta1 1000
> pbeta2 1000
> pbeta3 1000
> pbeta4 1000
> pbeta5 1000
> pbeta6 1000
> pbeta7 1000
> pbeta8 1000
> pbeta9 1000
> pbeta10 1000
So you have data on 10 asset portfolios over 1000/12 months
= 83 years ??? I guess some economic historians would
be interested in such data.
These t-tests look wrong to me. There is
no adjustment for serial correlation in
intercepts or slopes.
* For searches and help try: