View source: R/02_data_preparation.R
uni.simudistrib | R Documentation |
The uni.simudistrib
function automatically generates 5 Cleveland dotplots of random
samples from different distributions (either normal
, log-normal
, or poisson
) based on the
parameters of the variables in the input data.frame
or matrix
(see Details).
This function is useful to see whether variables' extreme values are actual outliers or whether they
lie in a range of values possible for a random sample drawn from a normal
, log-normal
, or a poisson
distribution. In fine, it may help determine if the original variable can be approximated by
these distribution with or without a transformation.
uni.simudistrib(simu.var, distribution)
simu.var |
A |
distribution |
Either |
The uni.simudistrib
function extracts some key parameters from the input variables (sample
size, mean and standard deviation) and generates random samples based on these parameters. For instance,
if simu.var
contains i variables X1
, X2
, ... Xi
and if distribution = "normal"
, the
function will return a panel of ix5 plots:
The 1st row will contain five dotplots for five random samples with n = length(X1)
and drawn
from a Normal distribution with the same mean and standard deviation as X1
.
The 2nd row will contain five dotplots for five random samples with n = length(X2)
and drawn
from a Normal distribution with the same mean and standard deviation as X2
.
Etc.
Warning: the function may fail for log-normal
and poisson
distributions if input
variables contain negative values (because these distributions are by definition positive). Additionally,
if distribution = "poisson"
, the resulting plots will return integer values as Poisson
is a discrete probability distribution.
A panel of p
*5 plots, where p
is the number of variables in simu.var
.
uni.simudistrib(simu.var = iris[,1:4], distribution = "normal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.