[Numpy-discussion] Is there a function to calculate ecnomic beta coefficient in numpy given two time series data.
Vineet Jain (gmail)
vinjvinj@gmail....
Sun Jun 8 09:02:36 CDT 2008
Currently my code handles market returns and stocks as 1d arrays. While the
function below expects a matrix. Is there an equivalent of the function
below which works with numpy arrays?
I'd like to do:
beta, resids, rank, s = mp.linalg.lstsq(mrkt_1d_array, stock_1d_array)
If not, how do:
1. create an empty matrix object and then keep adding arrays objects to it
in a loop?
Thanks,
Vineet
>> import numpy.matlib as mp
>> mrkt = mp.randn(250,1) # <----- 250 days of returns
>> stocks = mp.randn(250, 4) # <---- 4 stocks
>> beta, resids, rank, s = mp.linalg.lstsq(mrkt, stocks)
>> matrix([[-0.01701467, 0.11242168, 0.00207398, 0.03920687]])
More information about the Numpy-discussion
mailing list