Duarte Viana

2011-Sep-21 09:53 UTC

### [R] problem with function "Truncate" in package "distr"

Hello all, Can someone tell me why the following mixture of two log-normal distributions does not get truncated? What puzzles me is that the function works almost always, but for certain combinations (like the one below), it does not. # R code example library(distr) mix<-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) mix.trunc<-Truncate(mix,lower=0.001,upper=3000) distr.sample<-r(mix.trunc)(1000000) range(distr.sample) Why do I get values over 3000 (which was the defoned upper limit)? Some help would be greatly appreciated. Duarte Viana

On 21.09.2011 11:53, Duarte Viana wrote:> Hello all, > > Can someone tell me why the following mixture of two log-normal > distributions does not get truncated? What puzzles me is that the > function works almost always, but for certain combinations (like the > one below), it does not. > > # R code example > library(distr) > mix<-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) > mix.trunc<-Truncate(mix,lower=0.001,upper=3000) > distr.sample<-r(mix.trunc)(1000000) > range(distr.sample) > > Why do I get values over 3000 (which was the defoned upper limit)? > > Some help would be greatly appreciated.Some question for the author of package distr, I believe. Uwe Ligges> Duarte Viana > > ______________________________________________ > R-help at r-project.org 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.

Peter Ruckdeschel

2011-Sep-23 18:02 UTC

### [R] problem with function "Truncate" in package "distr"

Am 21.09.2011 17:05, schrieb Uwe Ligges:> > > On 21.09.2011 11:53, Duarte Viana wrote: >> Hello all, >> >> Can someone tell me why the following mixture of two log-normal >> distributions does not get truncated? What puzzles me is that the >> function works almost always, but for certain combinations (like the >> one below), it does not. >> >> # R code example >> library(distr) >> mix<-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) >> >> mix.trunc<-Truncate(mix,lower=0.001,upper=3000) >> distr.sample<-r(mix.trunc)(1000000) >> range(distr.sample) >> >> Why do I get values over 3000 (which was the defoned upper limit)? >> >> Some help would be greatly appreciated. > > > Some question for the author of package distr, I believe. > > Uwe Ligges >seconded, Uwe, and settled off-line [BTW was an issue of the globally set accuracy]. Best, Peter (one of the authors of distr)