Bay Area useR Group (R Programming Language) Message Board › Bay Area useR Group (R Programming Language) Discussion Forum › random number from truncated pareto distribution
|A former member||
Dear R professionals,
am a newcomer to R, and greatful for any advice and help concerning the following problem:
(1) I have data in a vector data$T; each single data point I'll call data&tx
(2) for these data I estimate the parameters s & beta of an pareto distribution following >http://stats.stackexc...
pareto.MLE <- function(X)
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
par.eto.par <- c(s=pareto.MLE(data$T), beta=pareto.MLE(data$T))
(3) Currently I created a loop to iterate the random draw from the total area of the Pareto distribution
random <- rpareto(l, location=beta, shape=s)
until all randomly drawn numbers (i.e. random) >= data$tx
because this is the only line I found to draw random samples from a Pareto distribution.
This loop however is inefficient and needs a lot of time to complete.
(4) Hence, what I need is to restrict the area of the Pareto Distribution with parameters estimated in (2) such that the random numbers >= data$tx .
But I cannot find any possibility how to tell R to do the random draw from a somehow truncated area of the Pareto distribution.
Below I give arbitrary, few values, just to provide an 'image' what I need.
(a) Let say data$T is (1;4;10;100;12000)
(b) random numbers to be drawn from truncated Pareto distribution with Parameter s & beta could then look like random$T(1;6;120;100;130023).
But: there must never occur a number in random$T that is smaller than the value in data$T (1;4;10;100;12000) at the corresponding location.
Does anyone know how to program in R a "restriction" to a distribution e.g. Pareto from where to draw random numbers?
Thanks for any ideas and advice!!
PS: versions/system used are R 2.15.1 running on Windows 7, 64 bit
Edited by User 77,352,312 on Jan 22, 2013 8:10 AM
|A former member||