Hi!
I am a new user of this user group. Apologies if this is question has an obvious
answer.
While I ran the below function from PerformanceAnalytics (edhec is a matrix
provided with the library), this is the error I get
chart.Correlation(edhec[,1],edhec[,3])
Error in pairs.default(x, y, gap = 0, lower.panel = panel.smooth, upper.panel =
panel.cor, :
only one column in the argument to 'pairs'
When I run the below, things work
chart.Correlation(edhec[,1:3],edhec[,1:3])
Any idea?
MAB
R - Error Question for chart.Correlation (PerformanceAnalytics)
7 messages · MAB, Brian G. Peterson, Guy Yollin +1 more
5 days later
Hi Michel,
I defer to the original authors of this very useful package, but I
believe it is simply a coding error.
In the last few lines of the chart.Correlation function there are a
couple of calls to the pairs function:
pairs(x, y, gap = 0, lower.panel = ...
I believe x and y should be bound together in the call as follows:
pairs(cbind(x,y), gap = 0, lower.panel = ...
Essentially, that was what you were doing with your 1:3.
Also, it appears that a couple of the datasets (managers and edhec) have
what should really be the rownames as the first column of data in the
dataframe. I did the following to get some of the examples to work:
rn <- edhec[,1]
edhec <- edhec[,-1]
rownames(edhec) <- rn
rn <- managers[,1]
managers <- managers[,-1]
rownames(mananagers) <- rn
Hope this is helpful.
Best,
-- G
-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of MAB
Sent: Wednesday, January 02, 2008 9:27 AM
To: r-sig-finance at stat.math.ethz.ch
Subject: [R-SIG-Finance] R - Error Question for
chart.Correlation(PerformanceAnalytics)
Hi!
I am a new user of this user group. Apologies if this is question has an
obvious
answer.
While I ran the below function from PerformanceAnalytics (edhec is a
matrix
provided with the library), this is the error I get
chart.Correlation(edhec[,1],edhec[,3])
Error in pairs.default(x, y, gap = 0, lower.panel = panel.smooth,
upper.panel =
panel.cor, :
only one column in the argument to 'pairs'
When I run the below, things work
chart.Correlation(edhec[,1:3],edhec[,1:3])
Any idea?
MAB
_______________________________________________
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.
On Tuesday 08 January 2008 10:08:06 am Guy Yollin wrote:
Also, it appears that a couple of the datasets (managers and edhec) have what should really be the rownames as the first column of data in the dataframe.
Can you clarify this? How are you loading the data? The examples, which are all run (tested) as part of the submission to CRAN, simply load the data using:
data(managers) head(managers)
HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC.LS.EQ SP500.TR US.10Y.TR
Jan 1996 0.0100 NA 0.0359 0.0208 NA NA NA 0.0340 0.00380
Feb 1996 0.0215 NA 0.0295 0.0231 NA NA NA 0.0093 -0.03532
Mar 1996 0.0226 NA 0.0253 -0.0053 NA NA NA 0.0096 -0.01057
Apr 1996 0.0008 NA 0.0478 0.0200 NA NA NA 0.0147 -0.01739
May 1996 0.0158 NA 0.0337 0.0122 NA NA NA 0.0258 -0.00543
Jun 1996 -0.0086 NA -0.0293 -0.0089 NA NA NA 0.0038 0.01507
US.3m.TR
Jan 1996 0.00456
Feb 1996 0.00398
Mar 1996 0.00371
Apr 1996 0.00428
May 1996 0.00443
Jun 1996 0.00412
If you use read.csv, you'll want to set row.names=1 so to capture the
appropriate label.
Also, these data objects are now zoo objects and degrade nicely with as.matrix
and other similar functions.
pcc
Peter Carl 145 Scottswood Rd Riverside, IL 60546 708 447 6465
Guy, Thanks for your constructive comments on chart.Correlation and the data sets included with PerformanceAnalytics.
Guy Yollin wrote:
<... snip chart.Correlation bits ...> I'll defer to Peter to comment on (fixing) the coding in chart.Correlation, as I am admittedly a novice on graphics in R (I focus on the analytical functions in PerformanceAnalytics). I wanted to address this point from Guy:
Also, it appears that a couple of the datasets (managers and edhec) have what should really be the rownames as the first column of data in the dataframe. I did the following to get some of the examples to work:
I'm a little confused by this, as
rownames(edhec)
or
rownames(managers)
returns the rownames correctly:
> data(edhec)
> rownames(edhec)
[1] "1997-01-31" "1997-02-28" "1997-03-31" "1997-04-30" "1997-05-31"
[6] "1997-06-30" "1997-07-31" "1997-08-31" "1997-09-30" "1997-10-31"
<...>
So, can you give an example of something that fails for you, which R
version you're using, etc.?
Thanks,
- Brian
Interesting, I wasn't calling data(managers), I was just calling library(PerformanceAnalytics) and then accessing the dataframe:
head(managers)
X.Y..m..d HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC.LS.EQ SP500.TR 1 1996-01-31 0.0074 NA 0.0349 0.0222 NA NA NA 0.0340 2 1996-02-29 0.0193 NA 0.0351 0.0195 NA NA NA 0.0093 3 1996-03-31 0.0155 NA 0.0258 -0.0098 NA NA NA 0.0096 4 1996-04-30 -0.0091 NA 0.0449 0.0236 NA NA NA 0.0147 5 1996-05-31 0.0076 NA 0.0353 0.0028 NA NA NA 0.0258 6 1996-06-30 -0.0039 NA -0.0303 -0.0019 NA NA NA 0.0038 US.10Y.TR US.3m.TR 1 0.00380 0.00456 2 -0.03532 0.00398 3 -0.01057 0.00371 4 -0.01739 0.00428 5 -0.00543 0.00443 6 0.01507 0.00412 I see that calling data(managers) first supplies the dataframe with the expected format; thanks for the clarification. I don't know enough about building packages to know if this is the expected behavior or not. Best, -- G -----Original Message----- From: Peter Carl [mailto:peter at braverock.com] Sent: Tuesday, January 08, 2008 9:40 AM To: r-sig-finance at stat.math.ethz.ch Cc: Guy Yollin; MAB Subject: Re: [R-SIG-Finance] R - Error Question for chart.Correlation(PerformanceAnalytics)
On Tuesday 08 January 2008 10:08:06 am Guy Yollin wrote:
Also, it appears that a couple of the datasets (managers and edhec)
have
what should really be the rownames as the first column of data in the dataframe.
Can you clarify this? How are you loading the data? The examples, which are all run (tested) as part of the submission to CRAN, simply load the data using:
data(managers) head(managers)
HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC.LS.EQ SP500.TR
US.10Y.TR
Jan 1996 0.0100 NA 0.0359 0.0208 NA NA NA 0.0340
0.00380
Feb 1996 0.0215 NA 0.0295 0.0231 NA NA NA 0.0093
-0.03532
Mar 1996 0.0226 NA 0.0253 -0.0053 NA NA NA 0.0096
-0.01057
Apr 1996 0.0008 NA 0.0478 0.0200 NA NA NA 0.0147
-0.01739
May 1996 0.0158 NA 0.0337 0.0122 NA NA NA 0.0258
-0.00543
Jun 1996 -0.0086 NA -0.0293 -0.0089 NA NA NA 0.0038
0.01507
US.3m.TR
Jan 1996 0.00456
Feb 1996 0.00398
Mar 1996 0.00371
Apr 1996 0.00428
May 1996 0.00443
Jun 1996 0.00412
If you use read.csv, you'll want to set row.names=1 so to capture the
appropriate label.
Also, these data objects are now zoo objects and degrade nicely with
as.matrix
and other similar functions.
pcc
Peter Carl 145 Scottswood Rd Riverside, IL 60546 708 447 6465
On Tuesday 08 January 2008 1:04:01 pm Guy Yollin wrote:
?I don't know enough about building packages to know if this is the expected behavior or not.
Well, it isn't and it shouldn't work that way (although I've verified that, in fact, it does work as you say). The issue seems to be some namespace confusion. fEcofin, which is a "required" package for fBasics or some of the other RMetrics packages (which we in turn require), has recently added an older version of our data objects to its list. Spencer has recently pointed out the namespace collision and I'm sure we'll work with Diethelm to figure out a way around it in the next version.
head(fEcofin::managers)
X.Y..m..d HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC.LS.EQ SP500.TR 1 1996-01-31 0.0074 NA 0.0349 0.0222 NA NA NA 0.0340 2 1996-02-29 0.0193 NA 0.0351 0.0195 NA NA NA 0.0093 3 1996-03-31 0.0155 NA 0.0258 -0.0098 NA NA NA 0.0096 4 1996-04-30 -0.0091 NA 0.0449 0.0236 NA NA NA 0.0147 5 1996-05-31 0.0076 NA 0.0353 0.0028 NA NA NA 0.0258 6 1996-06-30 -0.0039 NA -0.0303 -0.0019 NA NA NA 0.0038 US.10Y.TR US.3m.TR 1 0.00380 0.00456 2 -0.03532 0.00398 3 -0.01057 0.00371 4 -0.01739 0.00428 5 -0.00543 0.00443 6 0.01507 0.00412 At this point, the best way to make sure you're working with the correct data is to load it explicitly after loading PerformanceAnalytics. (RMetrics loads in all of the data when the package loads.)
library(PerformanceAnalytics) data(managers) head(managers)
HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC.LS.EQ SP500.TR US.10Y.TR
Jan 1996 0.0100 NA 0.0359 0.0208 NA NA NA 0.0340 0.00380
Feb 1996 0.0215 NA 0.0295 0.0231 NA NA NA 0.0093 -0.03532
Mar 1996 0.0226 NA 0.0253 -0.0053 NA NA NA 0.0096 -0.01057
Apr 1996 0.0008 NA 0.0478 0.0200 NA NA NA 0.0147 -0.01739
May 1996 0.0158 NA 0.0337 0.0122 NA NA NA 0.0258 -0.00543
Jun 1996 -0.0086 NA -0.0293 -0.0089 NA NA NA 0.0038 0.01507
US.3m.TR
Jan 1996 0.00456
Feb 1996 0.00398
Mar 1996 0.00371
Apr 1996 0.00428
May 1996 0.00443
Jun 1996 0.00412
Thanks very much for pointing out the issue, and I apologize for the
confusion.
pcc
Peter Carl 145 Scottswood Rd Riverside, IL 60546 708 447 6465
5 days later