Dear all,
I have two splus questions that I would appreciate some advice on:
1) I am trying to run a function on a rolling window basis, and have
constructed 2 loops; unfortunately, the start dates of my time series
all vary; as such, I am trying to do an "if is.na" then skip to the next
month with the loop.
- I can't use Aggregate / Roll to help with this, as my function return
more than one object
2) my second problem is that for my function "SolveStyleAnalysis" - the
X and y needs to be numerical matrix and vector respectively.
Unfortunately, if I feed in a time series, splus tells me that it
"Cannot coerce mode list to double". I only have this issue if I feed in
time series as I have tried feeding in dataframe directly, and it works
just fine. Unfortunately I need to do this in times series so that my
data is properly indexed.
- does anyone have any suggestions on how I can handle these two issues?
- SolveStyleAnalysis is a function that runs a constrained regression
(using NuOpt)
Here is my little code so far:
fofid <- colIds(fof.ts) #create list of fofids to loop thru
dt <- timeSequence("1/31/1978" ,"12/31/2005" , by = "months")
for (fofid in fofid) {
for (dtcount in length(dt)) {
m <- dt[dtcount]
if(is.na(fof.ts[m-36:m, fofid])) NA
else
y <- as.numeric(fof.ts[m-36:m, fofid]) #set y as vector of rtn
data for 36 mths
X <- numerical.matrix(hfstyle.ts[m-36:m,],) #set x as matrix of
style rtn data for 36 mths
SolveStyleAnalysis(X,y)
}
}
Thank you for your help in advance!
Wingee
--
This message and any attachments are confidential, proprietary, and may be
privileged. If this message was misdirected, Barclays Global Investors (BGI)
does not waive any confidentiality or privilege. If you are not the intended
recipient, please notify us immediately and destroy the message without
disclosing its contents to anyone. Any distribution, use or copying of this
e-mail or the information it contains by other than an intended recipient is
unauthorized. The views and opinions expressed in this e-mail message are the
author's own and may not reflect the views and opinions of BGI, unless the
author is authorized by BGI to express such views or opinions on its behalf.
All email sent to or from this address is subject to electronic storage and
review by BGI. Although BGI operates anti-virus programs, it does not accept
responsibility for any damage whatsoever caused by viruses being passed.
|