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.
Arguments
- distn
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 functionsdxxxandpxxxin thestats-packageare used. The abbreviationsxxxare also recognised. The"gev"and"gp"cases use thegevandgpdistributional functions in therevdbayespackage. Ifdistn = "gamma"then the(shape, rate)parameterisation is used, unless a value forscaleis provided via the argumentparamswhen the(shape, scale)parameterisation is used.Valid functions are set up like a standard distributional function
dxxx, with first argumentx, last argumentlogand with arguments to set the parameters of the distribution in between. See the CRAN task view on distributions.If
distnis not supplied thendistn = "normal"is used.- var_range
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_rangeis set then it overridesp_vec(see below).- params
A named list of initial parameter values with which to start the movie. If
distnis 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
distnis a function thenparamsmust set any required parameters.If parameter value is outside the corresponding range specified by
param_rangethen it is set to the closest limit of the range.- param_step
A named list of the amounts by which the respective parameters in
paramsare increased/decreased after one click of the +/- button. Ifdistnis a function then the default is 0.1 for all parameters. Ifdistnis a string then a sensible distribution-specific default is set internally.- param_range
A named list of the ranges over which the respective parameters in
paramsare 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. UseNAto impose no limit. Ifdistnis a function then all parameters are unconstrained.- p_vec
A numeric vector of length 2. The p.d.f. and c.d.f. are plotted between the 100
p_vec[1]% and 100p_vec[2]% quantiles of the distribution. Ifp_vecis not supplied then a sensible distribution-specific default is used. Ifdistnis a function then the default isp_vec = c(0.001, 0.999).- smallest
A positive numeric scalar. The smallest value to be used for any strictly positive parameters when
distnis a string.- plot_par
A named list of graphical parameters (see
par) to be passed toplot. This may be used to alter the appearance of the plots of the p.m.f. and c.d.f.- panel_plot
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.- hscale, vscale
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 includingpanel,variable,title,step,action,initval,range.
Details
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.
Examples
# 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))