Commit 5b55383e authored by Martin Maechler's avatar Martin Maechler

Add simple plot() method based on Shi's MS_plot()

parent b4bb679c
Package: CLA
Version: 0.90-0
Date: 2017-09-25
Version: 0.90-1
Date: 2018-01-25
Title: Critical Line Algorithm in Pure R
Author: Yanhao Shi <syhelena@163.com>,
Martin Maechler <maechler@stat.math.ethz.ch>
......
......@@ -3,9 +3,12 @@
importFrom("stats",
cor, predict, uniroot)
## importFrom(, ..)
importFrom("graphics", plot)# including the plot.default() method
## not yet on CRAN : importFrom("sfsmisc", funEnv)
## -------------- CLA Exports -----------------------
export(CLA
, MS
, findSig, findMu
......@@ -13,3 +16,4 @@ export(CLA
)
S3method(print, CLA)
S3method(plot, CLA)
......@@ -194,4 +194,34 @@ print.CLA <- function(x, ...) {
invisible(x)
}
## TODO: plot method -- efficient frontier
### TODO: plot method -- efficient frontier
## As basically from .../YanhaoShi/R/Functions/Plot.R :
MS_plot <- function(ms, type = "o",
main = "Efficient Frontier",
xlab = expression(sigma(w)),
ylab = expression(mu(w)),
col = adjustcolor("blue", alpha.f = 0.5),
pch = 16, ...) {
## list of weights_set, legend...
stopifnot(is.matrix(ms), ncol(ms) == 2)
plot(ms[,"Sig"], ms[,"Mu"], type=type, pch=pch, col=col,
xlab = xlab, ylab=ylab, main=main, ...)
}
## FIXME:
## 1) Learn from Tobias Setz to plot the lower part of the feasible region
## 2) Better title, using 'call'
## 3) mark some critical points particularly
## 4) give information about the *number* critical points / weights sets
## 5) consider using a 'add = FALSE' argument and then use 'lines()'
plot.CLA <- function(x, type = "o", main = "Efficient Frontier",
xlab = expression(sigma(w)),
ylab = expression(mu(w)),
col = adjustcolor("blue", alpha.f = 0.5),
pch = 16, ...) {
stopifnot(is.matrix(ms <- x$MSweights))
plot(ms[,"Sig"], ms[,"Mu"], type=type, pch=pch, col=col,
xlab=xlab, ylab=ylab, main=main, ...)
}
......@@ -2,5 +2,9 @@
* Before release of package
** DONE CLA() should return a (S3) class, "CLA"
*** TODO --> print() and plot() (S3) methods**** plot(): plot efficient frontier
*** TODO --> print() and plot() (S3) methods
**** plot(): plot efficient frontier
** check arguments e.g., lB <= uB, sum upper Bounds >= 1
** TODO References -->
*** 1) Master thesis: I'd like the thesis to be on our web page
*** 2) References from the thesis, including the "buried" python-paper with *WRONG* algo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment