|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Error in QRMlibHi,
I can not get the desired result if I running the example code from QRMlib user manual: ------------------------------------------- data(nasdaq); > nreturns <- -mk.returns(nasdaq); > monthly.maxima <- aggregateMonthlySeries(nreturns,FUN=max); Error in aggregateMonthlySeries(nreturns, FUN = max) : no slot of name "Dim" for this object of class "timeDate" > monthly.maxima <- seriesData(monthly.maxima) Error in seriesData(monthly.maxima) : object "monthly.maxima" not found > mod1 <- fit.GEV(monthly.maxima); Error in var(maxima) : object "monthly.maxima" not found -------------------------------------------- The following content is the prompt message after I running debug (ggregateMonthlySeries) ---------------------------------------------- > monthly.maxima <- aggregateMonthlySeries(nreturns,FUN=max); debugging in: aggregateMonthlySeries(nreturns, FUN = max) debug: { if (!is.timeSeries(timeseries)) stop("timeseries must be of the timeSeries class from fCalendar package") charvecStartDate <- timeseries@positions[1] charvecLastDate <- timeseries@positions[length(timeseries@positions)] dateFormat = "%Y-%m-%d" test1 <- as.character(timeFirstDayInMonth(charvecStartDate)) test2 <- as.character(timeFirstDayInMonth(charvecLastDate)) from3 = timeSequence(from = test1, to = test2, by = "month", format = dateFormat) test3 <- as.character(timeLastDayInMonth(charvecStartDate)) test4 <- as.character(timeLastDayInMonth(charvecLastDate)) to3 = timeSequence(from = test3, to = test4, by = "month", format = dateFormat) monthsLength <- to3@Dim repetitions <- as.integer(monthsLength/12) remainder <- monthsLength - 12 * repetitions firstDayInMonthYr <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) monthNumbers <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) lastMonthDayStdYr <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) lastDayVector <- rep(lastMonthDayStdYr, time = repetitions) if (remainder > 0) lastDayVector <- c(lastDayVector, lastMonthDayStdYr[1:remainder]) monthVector <- rep(monthNumbers, times = repetitions) if (remainder > 0) monthVector <- c(monthVector, monthNumbers[1:remainder]) ltest <- strptime(to3@Data, "%Y-%m-%d") ltest$mday <- lastDayVector ltest$mon <- monthVector for (iter in 1:monthsLength) { if (leap.year(ltest$year[iter] + 1900) && (ltest$mon[iter] == 1)) ltest$mday[iter] <- 29 } to3@Data[] <- ltest applySeries(timeseries, from3, to3, by = "monthly", FUN = FUNC) } Browse[1]> monthly.maxima <- seriesData(monthly.maxima) Error in seriesData(monthly.maxima) : object "monthly.maxima" not found Browse[1]> mod1 <- fit.GEV(monthly.maxima); ------------------------------------------------------ How can we get the desired result? Appreciate a lot! Best, Hong [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance@... mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first. |
|
|
Re: Error in QRMlib>>>> "HX" == "Hongchuan Xia" <hongchux@...>
>>>> 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@positions[1] HX> charvecLastDate <- timeseries@positions[length(timeseries@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@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@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@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 _______________________________________________ R-SIG-Finance@... mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first. |
| Free Forum Powered by Nabble | Forum Help |