I do know that Harrell's Quantile function in the Hmisc package will
allow quantile estimates from models. Whether it is general enough to
extend to time series, I have no experience and cannot say.
--
David Winsemius
On Feb 17, 2009, at 11:57 AM, Brigid Mooney wrote:
Hi All,
I am looking at applications of percentiles to time sequenced data.
I had
just been using the quantile function to get percentiles over various
periods, but am more interested in if there is an accepted (and/or
R-implemented) method to apply weighting to the data so as to weigh
recent
data more heavily.
I wrote the following function, but it seems quite inefficient, and
not
really very flexible in its applications - so if anyone has any
suggestions
on how to look at quantiles/percentiles within R while also using a
weighting schema, I would be very interested.
Note - this function supposes the data in X is time-sequenced, with
the most
recent (and thus heaviest weighted) data at the end of the vector
WtPercentile <- function(X=rnorm(100), pctile=seq(.1,1,.1))
{
Xprime <- NA
for(i in 1:length(X))
{
Xprime <- c(Xprime, rep(X[i], times=i))
}
print("Percentiles:")
print(quantile(X, pctile))
print("Weighted:")
print(Xprime)
print("Weighted Percentiles:")
print(quantile(Xprime, pctile, na.rm=TRUE))
}
WtPercentile(1:10)
WtPercentile(rnorm(10))
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.