Calculate confidence intervals and percentile ranks
Source:R/sem_to_percentiles.R
sem_to_percentiles.RdThis function calculates the confidence intervals for test scores and their percentile ranks.
Usage
sem_to_percentiles(
x,
R = NULL,
sem,
dp = 2,
names = NULL,
conf.level = 0.9,
threshold = -1.645,
abnormality = TRUE
)Arguments
- x
A numeric vector of test scores.
- R
A correlation matrix for the test scores.
- sem
A numeric vector of standard error of measurement (SEM) values.
- dp
Number of decimal places for rounding in the results. Default is 2.
- names
Optional character vector of names for the test scores. If not provided, default names will be used.
- conf.level
Confidence level for the confidence interval. Default is 0.90.
- threshold
Z-score threshold for classifying abnormal scores. Default is -1.645.
- abnormality
Logical, whether to calculate abnormality statistics. Default is TRUE.
Value
A list containing various statistics including:
- tests
Names of the test scores.
- x
Original test scores.
- ci.lb
Lower bound of the confidence interval.
- ci.ub
Upper bound of the confidence interval.
- rank
Percentile rank of the test scores.
- rank.ci.lb
Percentile rank of the lower bound of the confidence interval.
- rank.ci.ub
Percentile rank of the upper bound of the confidence interval.
Examples
# Example usage with test scores and SEM values
R <- diag(4)
sem <- c(3.000000, 3.354102, 3.674235, 4.743416)
scores <- c(118, 107, 77, 68)
sem_to_percentiles(scores, R = R, sem = sem, conf.level = 0.90)
#> Confidence Intervals as Percentile Ranks
#>
#> INPUTS:
#>
#>
#> Test Score
#> ----- ------
#> 1 118
#> 2 107
#> 3 77
#> 4 68
#>
#> OUTPUTS:
#>
#> Test Score 90% CI Rank 90% CI
#> ----- ------- ---------------- ------ --------------
#> 1 118.00 113.07 - 122.93 88.49 80.81 - 93.69
#> 2 107.00 101.48 - 112.52 67.96 53.94 - 79.80
#> 3 77.00 70.96 - 83.04 6.26 2.64 - 12.91
#> 4 68.00 60.20 - 75.80 1.64 0.40 - 5.34
#>
#> ABNORMALITY:
#>
#> Value Population Abnormality (%)
#> -------------------------------- ------ ---------------------------
#> Number of abnormally low scores 1 18.563 %
#>