Skip to content
Prev 5819 / 15274 Next

style.fit by month

Hi all,

thank you Julien for your thougts. I working with R 2.10.0 on Windows XP.
I remembered the function applySeries and fapply respectively. I tried 
to calculate
a variance covariance matrix over different periods. When this works I 
could go on with solve.QP which needs the Dmat.

Here is an example:
require(timeSeries)
btime <- timeSequence(from="1999-01-01", to="1999-03-31", by = "month")
etime <- timeLastDayInMonth(btime[-1])
btime <- btime[-length(btime)]
data1 <- rnorm(1:90)
data2 <- matrix(rnorm(270), ncol = 3)
colnames(data2) <- LETTERS[1:3]
datats <- timeSequence(from="1999-01-01", to="1999-03-31", by = "day")
S <- timeSeries(data2, datats)
applySeries(S, btime, etime, FUN = function(x) cov(x, 
use="pairwise.complete.obs"))
cov(window(S, start="1999-01-01", end="1999-02-28"))

The result is a matrix which contains the varcov matrices for 2 
subperiods which is fine,
but when I am using my real Data I receive this Message:
Fehler in midnightStandard2(charvec, format) :  'charvec' has non-NA 
entries of different number of characters
I don't understand this error message, can anyone help?


I read my datafile from a spreadsheet via readSeries(), the head looks 
like this:
                    R2G          R2V           R1G           R1V    
MSCIWexUS
1999-01-04 -0.006477506  0.004066846 -0.0026417776 -0.0009521722  
0.018939565
1999-01-05  0.001725935  0.002339151  0.0128278433  0.0116685255  
0.006108505
1999-01-06  0.018860732  0.007514636  0.0211913231  0.0215123444  
0.019311270
1999-01-07  0.005040827 -0.004752986 -0.0028397673  0.0013254882 
-0.005757679
1999-01-08  0.011525972  0.003911511 -0.0006109632  0.0101291838  
0.001059926
1999-01-11  0.013880501 -0.005775207 -0.0039712968 -0.0108176871 
-0.011788948

Thanks in advance
Ren?


julien cuisinier schrieb: