correlation  R Documentation 
A movie to illustrate how the sampling distribution of the product moment
sample correlation coefficient r
depends on the sample size n
and on the true correlation \rho
.
correlation(
n = 30,
rho = 0,
panel_plot = TRUE,
hscale = NA,
vscale = hscale,
delta_n = 1,
delta_rho = 0.1,
...
)
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

Random samples of size n
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 \rho
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 r
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 r
emerges. The exact p.d.f. of r
is
superimposed on this histogram, as is the value of \rho
.
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 \rho
to Fisher's
ztransformation F(\rho) = arctanh(\rho) = [ln(1+\rho)  ln(1\rho)]/2
.
For sufficiently large values of n
, F(\rho)
has approximately
a normal distribution with mean \rho
and variance
1 / (n  3)
.
The values of the sample size n
or true correlation coefficient
\rho
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 n
and \rho
.
Nothing is returned, only the animation is produced.
movies
: a userfriendly menu panel.
smovie
: general information about smovie.
correlation(rho = 0.8)
correlation(n = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.