Description Usage Arguments Details Value See Also Examples
View source: R/quantile_envelope.R
Calculate the pointwise quantile envelopes for comparison to observed data.
1 2 3 4 5 6 7 | quantile_envelope(
x,
upper = 0.975,
lower = 0.025,
n.eval.points,
type = "density"
)
|
x |
a dataframe with the observed values (column must be named "observed") and a column for each replicate to be used for quantile calculation |
upper |
a numeric value giving the desired upper quantile boundary (0 to 1) |
lower |
a numeric value giving the desired lower quantile boundary (0 to 1) |
n.eval.points |
integer giving the number of points at which to compute
pointwise quantiles. This is passed to |
type |
character vector indicating whether to produce envelope values as a density ("density") or expected value ("count") |
TODO: figure out difference b/t pointwise and complete envelopes
TODO: define a plot.env.envelope method
a data frame with three columns holding the observed values, the upper envelope values, and the lower envelope values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # make some example data
obs <- c(1:5, 7:8, 11:12, 19:25)
dat <- data.frame(observed = obs, s1 = sample(obs, replace = T),
s2 = sample(obs, replace = T),
s3 = sample(obs, replace = T),
s4 = sample(obs, replace = T),
s5 = sample(obs, replace = T))
# calculate the pointwise 95% quantile envelopes
result <- quantile_envelope(x = dat, n.eval.points = 20,
upper = 0.975, lower = 0.025)
plot(result$observed ~ result$x, type = "l", col = "black",
ylim = c(min(result$low_bnd), max(result$hi_bnd)),
main = "Quantile Envelope", ylab = "Density")
lines(result$low_bnd ~ result$x, col = "blue")
lines(result$hi_bnd ~ result$x, col = "blue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.