s-news
[Top] [All Lists]

OLS Regression Every Month

To: <s-news@lists.biostat.wustl.edu>
Subject: OLS Regression Every Month
From: "Chen,Sichong" <sichong.chen@postgrad.manchester.ac.uk>
Date: Mon, 30 Oct 2006 00:47:05 +0800
Thread-index: Acb7edz5fmQLfZvcTV6erN1GyAGw+Q==
Dear Users

I have to do OLS every month for two series, which are both daily data. So I
am supposed to do the regression for 84 times for 7 years data. Since it is
supposed to do month, I can not use rollOLS function, which fix the rolling
window. So I refer to aggregateSeries function and use to use these script
to execute the program.

ols.month = function (x)
{

        tmp     = seriesData(x)
        tmp1    = tmp[,1]
        tmp2    = tmp[,2]
        tmp.ols= OLS(tmp1~tmp2)
        ols.beta = tmp.ols$coef[2]
        ols.r    = summary(tmp.ols)$rsq
        ans               = concat(ols.beta, ols.r)

}

tmp.result =
aggregateSeries(tmp,by="months",FUN=ols.month,colnames=c("beta","R-square"))

where x is a time series object and has two vectors. The ols.month runs well
for a time series object. But when it is used in aggregateSeries, it always
shows

"Problem in object@data: Class "matrix" has no "data" slot"


I don't know what is going on. Could someone help me with this?

Regards,

Sichong
SPLUS 7.0 and FinMetrics 2.0



<Prev in Thread] Current Thread [Next in Thread>
  • OLS Regression Every Month, Chen,Sichong <=