Description Usage Arguments Value Author(s) References See Also Examples
It is desirable to check if a newly added random generator coded in C behaves correctly. To perform this operation, one can superimpose the theoretical density on a histogram of the generated values.
1 2 |
law.index |
index of the desired law, as given by |
sample.size |
number of observations to generate. |
law.pars |
vector of parameters for the law. The length of this
parameter should not exceed 4. If not provided, the default values
are used by means of |
density |
a function of two arguments |
trunc |
vector of left and right truncation thresholds for the generated sample values. Only those values in between will be kept to build the histogram. This can be useful for a distribution with extreme values. |
center |
Logical. Should we center the data. |
scale |
Should we scale the data. |
Returns invisibly the data generated and make a plot showing histogram and density superimposed.
P. Lafaye de Micheaux, V. A. Tran
Pierre Lafaye de Micheaux, Viet Anh Tran (2016). PoweR: A Reproducible Research Tool to Ease Monte Carlo Power Simulation Studies for Goodness-of-fit Tests in R. Journal of Statistical Software, 69(3), 1–42. doi:10.18637/jss.v069.i03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | dlaplace1 <- function(x, mu, b) {dexp(abs(x - mu), 1 / b) / 2}
checklaw(1, density = dlaplace1)
dlaplace2 <- function(x, pars) {dexp(abs(x - pars[1]), 1 / pars[2]) / 2}
checklaw(1, density = dlaplace2)
checklaw(law.index = 2, sample.size = 50000, law.pars = c(2, 3), density
= dnorm)
## We use the 'trunc' argument to display the density in a region where
## no extreme values are present.
checklaw(27, density = dlaw27, trunc = c(-Inf,10))
# This one (Tukey) does not have a closed form expression for
# the density. But we can use the stats::density() function as
# follows.
res <- checklaw(18)
lines(density(res$sample), col = "blue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.