A movie to illustrate how the probability density function (p.d.f.) and cumulative distribution function (c.d.f.) of a continuous random variable depend on the values of its parameters.
Either a character string or a function to choose the continuous random variable.
Strings "beta"
, "cauchy"
, "chisq"
"chi-squared"
, "exponential"
, "f"
, "gamma"
,
"gev"
, "gp"
, "lognormal"
, "log-normal"
,
"normal"
, "t"
, "uniform"
and "weibull"
are
recognised, case being ignored. The relevant distributional functions
dxxx
and pxxx
in the stats-package
are used. The abbreviations xxx
are also recognised.
The "gev"
and "gp"
cases use the
gev
and gp
distributional functions in the revdbayes
package.
If distn = "gamma"
then the (shape, rate)
parameterisation is used, unless a value for scale
is provided
via the argument params
when the (shape, scale)
parameterisation is used.
Valid functions are set up like a standard distributional function
dxxx
, with first argument x
, last argument log
and with arguments to set the parameters of the distribution in between.
See the
CRAN task view on distributions.
If distn
is not supplied then distn = "normal"
is used.
A numeric vector of length 2. Can be used to set a fixed
range of values over which to plot the p.d.f. and c.d.f., in order better
to see the effects of changing the parameter values.
If var_range
is set then it overrides p_vec
(see below).
A named list of initial parameter values with which to start
the movie. If distn
is a string and a particular parameter value
is not supplied then the following values are used.
"beta"
: shape1 = 2, shape2 = 2, ncp = 0
;
"cauchy"
: location = 0, scale = 1
;
"chi-squared"
: df = 4, ncp = 0
;
"exponential"
: rate = 1
;
"f"
: df1 = 4, df2 = 8, ncp =0
;
"gamma"
: shape = 2, rate = 1
;
"gev"
: loc = 0, scale = 1, shape = 0.1
;
"gp"
: loc = 0, scale = 1, shape = 0.1
;
"lognormal"
: meanlog = 0, sdlog = 1
;
"normal"
: mean = 0, sd = 1
;
"t"
: df = 4, ncp = 0
;
"uniform"
: min = 0, max = 1
;
"weibull"
: shape = 2, scale = 1
.
If distn
is a function then params
must set any required
parameters.
If parameter value is outside the corresponding range specified by
param_range
then it is set to the closest limit of the range.
A named list of the amounts by which the respective
parameters in params
are increased/decreased after one click of
the +/- button. If distn
is a function then the default is 0.1
for all parameters. If distn
is a string then a sensible
distribution-specific default is set internally.
A named list of the ranges over which the respective
parameters in params
are allowed to vary. Each element of the list
should be a vector of length 2: the first element gives the lower limit
of the range, the second element the upper limit.
Use NA
to impose no limit.
If distn
is a function then all parameters are unconstrained.
A numeric vector of length 2. The p.d.f. and c.d.f. are
plotted between the 100p_vec[1]
% and 100p_vec[2]
%
quantiles of the distribution. If p_vec
is not supplied then
a sensible distribution-specific default is used. If distn
is
a function then the default is p_vec = c(0.001, 0.999)
.
A positive numeric scalar. The smallest value to be
used for any strictly positive parameters when distn
is a string.
A named list of graphical parameters
(see par
) to be passed to
plot
. This may be used to alter the
appearance of the plots of the p.m.f. and c.d.f.
A logical parameter that determines whether the plot
is placed inside the panel (TRUE
) or in the standard graphics
window (FALSE
). If the plot is to be placed inside the panel
then the tkrplot library is required.
Numeric scalars. Scaling parameters for the size
of the plot when panel_plot = TRUE
. The default values are 1.4 on
Unix platforms and 2 on Windows platforms.
Additional arguments to be passed to
rp.doublebutton
, not including panel
,
variable
, title
, step
, action
, initval
,
range
.
Nothing is returned, only the animation is produced.
The movie starts with a plot of the p.d.f. of the distribution for the initial values of the parameters. Buttons increase (+) or decrease (-) each parameter. There are radio buttons to switch the plot from the p.d.f. to the c.d.f. and back.
# Normal example
continuous()
# Fix the range of values over which to plot
continuous(var_range = c(-10, 10))
# The same example, but using a user-supplied function and setting manually
# the initial parameters, parameter step size and range
continuous(distn = dnorm, params = list(mean = 0, sd = 1),
param_step = list(mean = 1, sd = 1),
param_range = list(sd = c(0, NA)))
# Gamma distribution. Show the use of var_range
continuous(distn = "gamma", var_range = c(0, 15))