[RsR] Data generation from Laplace distribution in R
Martin Maechler
maechler at stat.math.ethz.ch
Mon Nov 17 23:43:05 CET 2008
>>>>> "DK" == khanx131 <khanx131 at umn.edu>
>>>>> on 15 Nov 2008 20:45:52 -0600 writes:
DK> Hi, Everyone, I have problem in data generation using
DK> Laplace distribution. i tried "rlaplace()" in VGAM
DK> package but when i install this package then
DK> predict(lm(...)) and resid(lm(...)) etc does not
DK> work. please let me know if anyone who know how to deal
DK> with it, and generate Laplace data. it would be greatly
DK> appreciated. thanks in advance,
Hmm, yes, I see
> library(VGAM)
Loading required package: splines
Loading required package: stats4
Attaching package: 'VGAM'
The following object(s) are masked from package:splines :
bs,
ns
The following object(s) are masked from package:graphics :
persp
The following object(s) are masked from package:stats :
biplot,
coefficients,
deviance,
df.residual,
effects,
fitted,
fitted.values,
poly,
predict,
resid,
residuals,
weights
The following object(s) are masked from package:base :
identity,
scale.default
>
----------------------
This indeed a pretty startling sign, and I would indeed be
reluctant to use VGAM for the time being, myself.
I got acquainted with Thomas Yee, the VGAM author, and have
known him as a very smart person. But these maskings of
standard R functions are really not a good idea.
[Thomas: We should communicate privately in order to get a
better solution for VGAM]
But for rlaplace(), as Murray has just replied I see,
that is really just an exponential with a random sign.
Thomas' rlaplace() is just a "better" insofar as it nicely computes one
Laplace variate from one uniform.
So you can do something like :
library(VGAM)
Rlaplace <- rlaplace
detach("package:VGAM")
rlaplace <- Rlaplace
A slightly more interesting problem is the generalization of
yours:
Generate Huber_c distributed variates ...
Martin
More information about the R-SIG-Robust
mailing list