Skip to content

Regression in fPortfolio? Sorting by date does not work...

4 messages · Andrew Ellis, Nicolas Chapados, Yohan Chalabi

#
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::
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::
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
#
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:
#
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::
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:
#
NC> Thanks for your quick reply.  I found a solution to the
   NC> problem: I
   NC> installed the latest versions of timeDate and timeSeries as were
   NC> present on R-Forge (NOT CRAN).  It appears that the following
   NC> bit of
   NC> code was added relatively recently in methods-is.R (in the
   NC> timeSeries) package:
   NC>
   NC> if (getRversion() < 2.8.0) {
   NC> setMethod(is.unsorted, timeSeries, function(x, na.rm = FALSE)
   NC> callGeneric(x at positions, na.rm = na.rm))
   NC> } else {
   NC> setMethod(is.unsorted, timeSeries, function(x, na.rm = FALSE,
   NC> strictly = FALSE)
   NC> callGeneric(x at positions, na.rm = na.rm, strictly = strictly))
   NC> }
   NC>
   NC> The problem I was experiencing previously appeared to be due
   NC> to the
   NC> first form of the callCaneric being made, without the strictly=
   NC> argument.

Hi Nicolas,

This code has been in timeSeries since the introduction of
is.unsorted,timeSeries method. It used to be in "is.R" since
version 2100.81. The current version is 2100.83. 

I do not understand why it does not work for you with the current
packages on CRAN. We are unable to reproduce your error using
different versions of R and packages from CRAN.

We would be very grateful if you could try again using the packages
from CRAN so that we can try to reproduce any potential errors.

You do not need the dev-packages from R-Forge to run the examples of
the ebook.

regards,
Yohan