correlation {smovie} | R Documentation |
Sampling distribution of the correlation coefficient movie
Description
A movie to illustrate how the sampling distribution of the product moment
sample correlation coefficient depends on the sample size
and on the true correlation
.
Usage
correlation(
n = 30,
rho = 0,
panel_plot = TRUE,
hscale = NA,
vscale = hscale,
delta_n = 1,
delta_rho = 0.1,
...
)
Arguments
n |
An integer scalar. The initial value of the sample size. Must not be less than 2. |
rho |
A numeric scalar. The initial value of the true correlation
|
panel_plot |
A logical parameter that determines whether the plot
is placed inside the panel ( |
hscale , vscale |
Numeric scalars. Scaling parameters for the size
of the plot when |
delta_n |
An integer scalar. The amount by which the value of the sample size is increased/decreased after one click of the +/- button. |
delta_rho |
A numeric scalar. The amount by which the value of rho is increased/decreased after one click of the +/- button. |
... |
Additional arguments to the rpanel functions
|
Details
Random samples of size are simulated from a
bivariate normal distribution
in which each of the variables has a mean of 0 and a variance of 1 and
the correlation
between the variables is chosen by the user.
The movie contains two plots. On the top is a scatter plot of the
simulated sample, illustrating the strength of the association between
the simulated values of the variables.
A new sample is produced by clicking "simulate another sample.
For each simulated sample the sample (product moment) correlation
coefficient is calculated and displayed in the title of the top
plot.
The values of the sample correlation coefficients are stored and are
plotted in a histogram in the bottom plot. A rug displays the individual
values, with the most recent value coloured red. As we accumulate a large
number of values in this histogram the shape of the sampling
distribution of emerges. The exact p.d.f. of
is
superimposed on this histogram, as is the value of
.
The bottom plot can be changed in two ways:
(i) a radio button can be pressed to replace the histogram and pdf with
a plot of the empirical c.d.f. and exact cdf;
(ii) the variable can be changed from to Fisher's
z-transformation
.
For sufficiently large values of
,
has approximately
a normal distribution with mean
and variance
.
The values of the sample size or true correlation coefficient
can be changed using the respective +/- buttons.
If one of these is changed then the bottom plot is
reset using the sample correlation coefficient of the first sample
simulated using the new combination of
and
.
Value
Nothing is returned, only the animation is produced.
See Also
movies
: a user-friendly menu panel.
smovie
: general information about smovie.
Examples
correlation(rho = 0.8)
correlation(n = 10)