Am a newcomer to R and need advice on how to draw random numbers from a limited area of a Pareto Distribution with parameters s & beta. (System: Windows 7, R 2.15.2.)
(1) I have data in a vector data$t; each single data point I’ll call data&tx
For these data the parameters s & beta of a Pareto distribution are estimated following https://stats.stackexchange.com/questions/27426/how-do-i-fit-a-set-of-data-to-a-pareto-distribution-in-r
pareto.MLE <- function(X)
{
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
}
(2) Now I need to draw as many random numbers (RndNew) von this Pareto distribution (s, beta, see (1)) as there are observations (= data points: data$tx) . For the draw the area from which random numbers are drawn must be limited to the area where RndNewx >= data$tx; in other words: RndNewx must never be smaller than the corresponding data$tx.
Question: how to tell R to restrict the area of a Pareto distribution from which to draw a random number to be RndNewx >= data$tx?
Thanks a million for any help!
The standard approach to sampling from a truncated distribution has three steps. Here’s an example with the normal distribution so you can get the idea.
Apply the CDF to your lower and upper bounds to find the quantiles of the edges of your distribution.
Sample from a uniform distribution between those quantiles.
Apply the inverse CDF.
The CDF for the pareto distribution is
And the inverse is
We can rework the above example to use these Pareto functions.
To make it easier to reuse this code, we can wrap it into a function. The lower and upper bounds have default values that match the range of the distribution, so if you don’t pass values in, then you’ll get a non-truncated Pareto distribution.