Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ylog" is ignored in chart.CumReturns #91

Open
gp2x opened this issue Mar 18, 2018 · 7 comments
Open

"ylog" is ignored in chart.CumReturns #91

gp2x opened this issue Mar 18, 2018 · 7 comments

Comments

@gp2x
Copy link

gp2x commented Mar 18, 2018

I recently updated packages on my R installation and noticed that plots using a log-scale for the y-axis were no longer displaying correctly. Digging in, it looks like the "ylog" parameter for chart.CumReturns is now being ignored.

If I'm reading the code correctly, chart.CumReturns() calls chart.TimeSeries(), which calls chart.TimeSeries.base(), which has recently(?) been modified to call plot.xts(). However, looking at this commit: 7f66651

...it appears that since that modification there is now nothing done with the ylog parameter.

Basic example code:
test <- xts(rep(0.01,1000),seq.Date(from=as.Date("2000-01-01"),to=as.Date("2002-09-26"),by=1))
chart.CumReturns(test,ylog=TRUE)

This plot should show a straight line, but now shows an exponential curve.

I am running R 3.4.4 and PerformanceAnalytics 1.5.2 on Antergos (Arch) Linux 64-bit. If you need any more details about my configuration let me know. Thanks!

@gp2x
Copy link
Author

gp2x commented Mar 18, 2018

This may be related to this issue: #1

... feel free to move things around if needed for cleanliness.

@gp2x
Copy link
Author

gp2x commented Mar 24, 2018

For now, I've downgraded to 1.4.3541 using the instructions here: https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages

@mcbain
Copy link

mcbain commented Jul 7, 2021

Still an issue.
logaxis = "y" shouldn't that variable passed into plot ?

https://github.com/braverock/PerformanceAnalytics/blob/master/R/chart.TimeSeries.builtin.R#L73

@deaniceman
Copy link

Any plans to fix this? Really need a log chart here.

@joshuaulrich
Copy link
Collaborator

This is likely dependent on joshuaulrich/xts#103 being implemented.

@babbage9010
Copy link

xts 0.13.2 is now out, but doesn't seem to fix this issue, perhaps @joshuaulrich can find an easy-ish fix for this now? I wouldn't say ylog parameter is "ignored" per se, but certainly doesn't produce a real log scale, and adding wealth.index=TRUE (to get rid of the 0 on the y-axis) doesn't help.

@joshuaulrich
Copy link
Collaborator

Thanks for giving this a try @babbage9010!

I just verified this works with the development version of the PerformanceAnalytics package if you set log = TRUE and wealth.index = TRUE. You need the development version for this to work, specifically this change.

Here's the linear scale plot from chart.CumReturns() as part of charts.PerformanceSummary().

library(PerformanceAnalytics)
data(edhec)
### linear scale
charts.PerformanceSummary(edhec)

image

And here's the log scale plot. Note that the legend doesn't appear on the log-scale plot due to this bug in addLegend().

### log scale
charts.PerformanceSummary(edhec, log = TRUE, wealth.index = TRUE)

image


So, to fix this issue, we need to send log = TRUE to plot.xts() when ylog = TRUE in chart.TimeSeries(). I would have to think about and test the best way to go about that.

We also need to handle the case when wealth.index = FALSE and there are negative values in the cumulative return series, since the log of negative numbers isn't defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants