mean_vs_median_t_movie: Sample mean vs sample median: Student's t distributed data

View source: R/mean_vs_median_t_movie.R

mean_vs_median_t_movieR Documentation

Sample mean vs sample median: Student's t distributed data

Description

A movie to compare the sampling distributions of the sample mean and sample median based on a random sample of size n from a (central) Student's t distribution. This movie can also be opened using smovie::movies() and selecting Mean vs median, Student t(2) from the Sampling distributions menu. This is based on the lev_inf function. (If you have not installed the smovie package then use install.packages("smovie") to install it.)

Usage

mean_vs_median_t_movie(
  n = 10,
  t_df = 2,
  delta_n = 1,
  pos = 1,
  envir = as.environment(pos)
)

Arguments

n

An integer scalar. The size of the samples drawn from a Student's t distribution.

t_df

A positive scalar. The degrees of freedom of the Student's t distribution (see TDist).

delta_n

A numeric scalar. The amount by which the value of the sample size is increased/decreased after one click of the +/- button.

pos

A numeric integer. Used in calls to assign to make information available across successive frames of a movie. By default, uses the current environment.

envir

An alternative way (to pos) of specifying the environment. See environment.

Details

The movie is based on simulating repeatedly samples of size n from a central Student's t distribution with degrees of freedom t_df. It contains three plots. The top plot contains a histogram of the most recently simulated dataset, with the probability density function (p.d.f.) of the Student's t distribution with t_df degrees of freedom superimposed.

Each time a sample is simulated the sample mean and sample median are calculated. These values are indicated on the top plot as a filled circle: a red circle for the sample mean and a blue circle for the sample median; and are added to the values plotted in the middle and bottom plots.

The plot in the middle contains a histogram of the sample means of all the simulated samples.

The plot on the bottom contains a histogram of the sample medians of all the simulated samples.

An extra sample is produced by clicking the + button next to "number of samples of size n". [Ignore the - button.] The value of the sample size can be changed using the +/- buttons in the panel.

Value

Nothing is returned, only the animation is produced.

See Also

stat0002movies: general information about the movies.

mean_vs_median_normal_movie: compares the sampling distributions of the sample mean and sample median based on a random sample of size n from a standard normal distribution.

Examples

mean_vs_median_t_movie(t_df = 2)

paulnorthrop/stat0002 documentation built on Oct. 10, 2024, 1:27 p.m.