| To: | <s-news@wubios.wustl.edu> |
|---|---|
| Subject: | previous email |
| From: | "Leeds, Mark" <mleeds@mlp.com> |
| Date: | Fri, 18 Jul 2003 00:07:03 -0400 |
| Thread-index: | AcNM4gsgwYgNcXJ8R5mS99NcvL5Zow== |
| Thread-topic: | previous email |
|
anyone who read my previous email can disregard A because I found it in adrian trapletti's tseries package. the function is below in case anyone is interested. I don't know why this message is skipping lines. he loops at the end but that's just in case, the same drawdown occurs more than once. usually, i will be 1 so looping is very minimal. i was not familar with the function cummax but even then, it' still very clever.
maxdrawdown <- function(x) { if(NCOL(x) > 1) stop("x is not a vector or univariate time series") if(any(is.na(x))) stop("NAs in x") cmaxx <- cummax(x)-x mdd <- max(cmaxx) to <- which(mdd == cmaxx) from <- double(NROW(to)) for (i in 1:NROW(to)) from[i] <- max(which(cmaxx[1:to[i]] == 0)) return(list(maxdrawdown = mdd, from = from, to = to)) } |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [no subject], Leeds, Mark |
|---|---|
| Next by Date: | statistician from turkey, Hayal Boyacioglu |
| Previous by Thread: | [no subject], Leeds, Mark |
| Next by Thread: | statistician from turkey, Hayal Boyacioglu |
| Indexes: | [Date] [Thread] [Top] [All Lists] |