Skip to contents

This function will generate n random points from a rt distribution with a user provided, df, ncp, and number of random simulations to be produced. The function returns a tibble with the simulation number column the x column which corresponds to the n randomly generated points, the d_, p_ and q_ data points as well.

The data is returned un-grouped.

The columns that are output are:

  • sim_number The current simulation number.

  • x The current value of n for the current simulation.

  • y The randomly generated data point.

  • dx The x value from the stats::density() function.

  • dy The y value from the stats::density() function.

  • p The values from the resulting p_ function of the distribution family.

  • q The values from the resulting q_ function of the distribution family.

Usage

tidy_t(.n = 50, .df = 1, .ncp = 0, .num_sims = 1)

Arguments

.n

The number of randomly generated points you want.

.df

Degrees of freedom, Inf is allowed.

.ncp

Non-centrality parameter.

.num_sims

The number of randomly generated simulations you want.

Value

A tibble of randomly generated data.

Details

This function uses the underlying stats::rt(), and its underlying p, d, and q functions. For more information please see stats::rt()

Author

Steven P. Sanderson II, MPH

Examples

tidy_t()
#> # A tibble: 50 × 7
#>    sim_number     x       y     dx       dy     p       q
#>    <fct>      <int>   <dbl>  <dbl>    <dbl> <dbl>   <dbl>
#>  1 1              1 -1.03   -24.5  1.47e- 4 0.245 -1.03  
#>  2 1              2  0.510  -22.1  9.75e- 3 0.650  0.510 
#>  3 1              3  1.75   -19.7  1.73e- 6 0.835  1.75  
#>  4 1              4  1.60   -17.3  6.88e- 8 0.822  1.60  
#>  5 1              5 -0.959  -14.9  4.84e- 3 0.257 -0.959 
#>  6 1              6  0.287  -12.5  1.00e- 3 0.589  0.287 
#>  7 1              7 -0.850  -10.1  7.17e-10 0.276 -0.850 
#>  8 1              8 -0.356   -7.69 3.43e- 4 0.391 -0.356 
#>  9 1              9  0.0557  -5.29 8.68e- 3 0.518  0.0557
#> 10 1             10 10.7     -2.89 2.82e- 2 0.970 10.7   
#> # ℹ 40 more rows