[R-SIG-Finance] Error in QRMlib

Yohan Chalabi chalabi at phys.ethz.ch
Thu Jun 26 13:46:24 CEST 2008


>>>> "HX" == "Hongchuan Xia" <hongchux at gmail.com>
>>>> on Thu, 26 Jun 2008 13:23:07 +0200

   HX> Hi,
   HX> 
   HX> I can not get the desired result if I running the example code from QRMlib
   HX> user manual:
   HX> 
   HX> -------------------------------------------
   HX> 
   HX> data(nasdaq);
   HX> > nreturns <- -mk.returns(nasdaq);
   HX> > monthly.maxima <- aggregateMonthlySeries(nreturns,FUN=max);  
   HX> Error in aggregateMonthlySeries(nreturns, FUN = max) :
   HX>   no slot of name "Dim" for this object of class "timeDate"
   HX> > monthly.maxima <- seriesData(monthly.maxima)  
   HX> Error in seriesData(monthly.maxima) : object "monthly.maxima" not found
   HX> > mod1 <- fit.GEV(monthly.maxima);  
   HX> Error in var(maxima) : object "monthly.maxima" not found
   HX> 
   HX> --------------------------------------------
   HX> 
   HX> The following content is the prompt message after I running debug
   HX> (ggregateMonthlySeries)
   HX> 
   HX> ----------------------------------------------
   HX> > monthly.maxima <- aggregateMonthlySeries(nreturns,FUN=max);  
   HX> debugging in: aggregateMonthlySeries(nreturns, FUN = max)
   HX> debug: {
   HX>   if (!is.timeSeries(timeseries))
   HX>   stop("timeseries must be of the timeSeries class from fCalendar package")
   HX>   charvecStartDate <- timeseries at positions[1]
   HX>   charvecLastDate <- timeseries at positions[length(timeseries at positions)]
   HX>   dateFormat = "%Y-%m-%d"
   HX>   test1 <- as.character(timeFirstDayInMonth(charvecStartDate))
   HX>   test2 <- as.character(timeFirstDayInMonth(charvecLastDate))
   HX>   from3 = timeSequence(from = test1, to = test2, by = "month",
   HX>   format = dateFormat)
   HX>   test3 <- as.character(timeLastDayInMonth(charvecStartDate))
   HX>   test4 <- as.character(timeLastDayInMonth(charvecLastDate))
   HX>   to3 = timeSequence(from = test3, to = test4, by = "month",
   HX>   format = dateFormat)
   HX>   monthsLength <- to3 at Dim
   HX>   repetitions <- as.integer(monthsLength/12)
   HX>   remainder <- monthsLength - 12 * repetitions
   HX>   firstDayInMonthYr <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
   HX>   monthNumbers <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
   HX>   lastMonthDayStdYr <- c(31, 28, 31, 30, 31, 30, 31, 31, 30,
   HX>   31, 30, 31)
   HX>   lastDayVector <- rep(lastMonthDayStdYr, time = repetitions)
   HX>   if (remainder > 0)
   HX>   lastDayVector <- c(lastDayVector, lastMonthDayStdYr[1:remainder])
   HX>   monthVector <- rep(monthNumbers, times = repetitions)
   HX>   if (remainder > 0)
   HX>   monthVector <- c(monthVector, monthNumbers[1:remainder])
   HX>   ltest <- strptime(to3 at Data, "%Y-%m-%d")
   HX>   ltest$mday <- lastDayVector
   HX>   ltest$mon <- monthVector
   HX>   for (iter in 1:monthsLength) {
   HX>   if (leap.year(ltest$year[iter] + 1900) && (ltest$mon[iter] ==
   HX>   1))
   HX>   ltest$mday[iter] <- 29
   HX>   }
   HX>   to3 at Data[] <- ltest
   HX>   applySeries(timeseries, from3, to3, by = "monthly", FUN = FUNC)
   HX> }
   HX> Browse[1]> monthly.maxima <- seriesData(monthly.maxima)  
   HX> Error in seriesData(monthly.maxima) : object "monthly.maxima" not found
   HX> Browse[1]> mod1 <- fit.GEV(monthly.maxima);  
   HX> ------------------------------------------------------
   HX> 
   HX> How can we get the desired result?
   HX> 
   HX> Appreciate a lot!
   HX> 
   HX> Best,
   HX> 
   HX> Hong


This is due to a change in timeDate class where the slot @Dim was
removed. One should use length("timeDate") instead of accessing directly
the slot.

I CC the maintainer of QRMlib.

regards,
Yohan

-- 
PhD student
Swiss Federal Institute of Technology
Zurich

www.ethz.ch
www.rmetrics.org

NOTE:
Rmetrics Workshop: http://www.rmetrics.org/meielisalp.htm
June 29th - July 3rd Meielisalp, Lake Thune, Switzerland



More information about the R-SIG-Finance mailing list