Skip to contents

estim_corr determines point estimate, SD and SE, 95% Credibility Intervals, and interval width, for Pearson correlations for multiple sample sizes

Usage

estim_corr(data, vars_of_interest, sample_size, k = 50, name = "")

Arguments

data

Dataframe with the data to be analyzed

vars_of_interest

Vector containing the names of the variables to be correlated: c("var1", "var2")

sample_size

The range of sample size to be used: min:max

k

The number of permutations to be used for each sample size. Defaults to 50

name

The title of the dataset or variables to be displayed with the figure. Defaults to ""

Value

  • tbl_select returns a tibble::tibble() containing estimates of the Pearson correlation between two correlated variables with associated SD, SE, 95% CI, and width of the 95% CI (lower, upper) for five different sample sizes (starting with the minimum sample size, then 1/5th parts of the total dataset).

  • fig_corr returns a scatterplot where for the five different sample sizes, 10 out of the total number of HDCIs computed are displayed (in green). The average estimate with credible interval summarizing the total number of HDCIs for each sample size are plotted in orange

  • fig_corr_nozero returns a barplot where for each of the five sample sizes the proportion of permutations not containing zero is displayed

  • tbl_total returns a tibble::tibble() containing estimates of the Pearson correlation between two correlated variables with associated SD, SE, 95% CI, and width of the 95% CI (lower, upper) for all sample sizes, including the permutation number.

Examples

data_gambling <- gambling
estim_corr(data_gambling,
  c("lnacc_self_winvsloss", "age"), 20:221,
  10, "Gambling NAcc correlation with age")
#> $tbl_select
#> # A tibble: 55 × 6
#>    N     correlation  lower  upper permutation nozero
#>    <fct>       <dbl>  <dbl>  <dbl> <fct>        <dbl>
#>  1 20         0.0543 -0.398 0.485  1               NA
#>  2 60        -0.200  -0.432 0.0566 1               NA
#>  3 100        0.0536 -0.144 0.247  1               NA
#>  4 140        0.0230 -0.143 0.188  1               NA
#>  5 221       -0.0405 -0.172 0.0920 1               NA
#>  6 20         0.264  -0.202 0.632  2               NA
#>  7 60        -0.132  -0.373 0.126  2               NA
#>  8 100       -0.156  -0.342 0.0419 2               NA
#>  9 140       -0.0559 -0.220 0.111  2               NA
#> 10 221       -0.0405 -0.172 0.0920 2               NA
#> # ℹ 45 more rows
#> 
#> $fig_corr

#> 
#> $fig_corr_nozero

#> 
#> $tbl_total
#> # A tibble: 2,020 × 5
#>        N correlation  lower   upper permutation
#>    <int>       <dbl>  <dbl>   <dbl>       <int>
#>  1    20      0.0543 -0.398 0.485             1
#>  2    21     -0.166  -0.558 0.286             1
#>  3    22     -0.147  -0.536 0.292             1
#>  4    23     -0.173  -0.546 0.257             1
#>  5    24     -0.147  -0.519 0.273             1
#>  6    25      0.0139 -0.383 0.407             1
#>  7    26     -0.0248 -0.408 0.366             1
#>  8    27     -0.374  -0.660 0.00752           1
#>  9    28     -0.0317 -0.400 0.345             1
#> 10    29     -0.0683 -0.424 0.306             1
#> # ℹ 2,010 more rows
#>