[R-SIG-Finance] Regression in fPortfolio? Sorting by date does not work...

Nicolas Chapados nicolas.chapados at gmail.com
Tue Sep 1 18:02:18 CEST 2009


Hi Andrew,

Thanks for your quick reply.  I found a solution to the problem: I
installed the latest versions of timeDate and timeSeries as were
present on R-Forge (NOT CRAN).  It appears that the following bit of
code was added relatively recently in "methods-is.R" (in the
timeSeries) package:

if (getRversion() < "2.8.0") {
    setMethod("is.unsorted", "timeSeries", function(x, na.rm = FALSE)
        callGeneric(x at positions, na.rm = na.rm))
} else {
    setMethod("is.unsorted", "timeSeries", function(x, na.rm = FALSE,
strictly = FALSE)
         callGeneric(x at positions, na.rm = na.rm, strictly = strictly))
}

The problem I was experiencing previously appeared to be due to the
first form of the callCaneric being made, without the strictly=
argument.

Although this would be unnecessary, here is sessionInfo() now that the
new version is installed::

> sessionInfo()
R version 2.9.1 (2009-06-26)
i486-pc-linux-gnu

locale:
C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] timeSeries_2100.84 timeDate_2100.86


The problem appears solved for me right now, but there may remain sync
issues between CRAN packages and R versions...  Thanks again for
writing so quickly.

Best regards,
+ Nicolas Chapados



On Tue, Sep 1, 2009 at 11:32 AM, Andrew Ellis<andrew.ellis at rmetrics.org> wrote:
> Hi Nicholas,
>
> we are unable to reproduce this. Could you please give me the output from
>
> sessionInfo()
>
> Thanks,
> Andrew
>
> PS. Btw, R 2.9.2 should be available for Ubuntu as Sep 1
>
> On Tue, Sep 1, 2009 at 4:35 PM, Nicolas
> Chapados<nicolas.chapados at gmail.com> wrote:
>> I am currently following the examples in the ebook "Portfolio
>> Optimization with R/RMetrics" (by Würtz et al.) and the example on p.
>> 16 simply does not work.  Here is what I get::
>>
>>> set.seed(1953)
>>> charvec <- format(timeCalendar(2008, sample(12,6)))
>>> data <- matrix(round(rnorm(6), 3))
>>> t1 <- sort(timeSeries(data, charvec, units="A"))
>> Error in is.unsorted(x at positions, na.rm = na.rm) :
>>  1 argument passed to .Internal(is.unsorted) which requires 2
>>
>> I'm using the latest binary R from CRAN (2.9.1) on Ubuntu 9.04, and
>> all RMetrics packages installed from scratch yesterday.  I just did an
>> update.packages() as suggested on p. xiii of the ebook.  So everything
>> should be fresh as on CRAN (as of August 31st, 2009).  For the record,
>> here is the transcript I obtain after loading library(fPortfolio)
>> immediately after starting R::
>>
>>> library(fPortfolio)
>> Loading required package: MASS
>> Loading required package: timeDate
>> Loading required package: timeSeries
>> Loading required package: fBasics
>> Loading required package: fCopulae
>> Loading required package: sn
>> Loading required package: mnormt
>> Package 'sn', 0.4-12 (2009-03-21). Type 'help(SN)' for summary information
>> Loading required package: adapt
>> Loading required package: fAssets
>> Loading required package: robustbase
>>
>> Attaching package: 'fAssets'
>>
>>
>>        The following object(s) are masked from package:fCopulae :
>>
>>         .mvstFit
>>
>> Loading required package: quadprog
>> Loading required package: Rglpk
>> Loading required package: slam
>>
>> Attaching package: 'slam'
>>
>>
>>        The following object(s) are masked from package:timeSeries :
>>
>>         colMeans,
>>         colSums
>>
>>
>>        The following object(s) are masked from package:base :
>>
>>         colMeans,
>>         colSums,
>>         rowMeans,
>>         rowSums
>>
>> Using the GLPK callable library version 4.37
>> Loading required package: Rsymphony
>> Warning message:
>> 'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
>>
>>
>>
>> This error is somewhat bothersome, since the sorting functions are
>> used in many places within RMetrics...
>>
>> Any help is greatly appreciated!
>>
>> Many thanks,
>> + Nicolas Chapados
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>>
>



More information about the R-SIG-Finance mailing list