Title: | A psychological evaluation toolkit |
---|---|
Description: | Functions useful in psychological evaluations This package accompanies [*Individual Psychometrics*](https://individual-psychometrics.rbind.io/) online textbook. |
Authors: | W. Joel Schneider [aut, cre] |
Maintainer: | W. Joel Schneider <[email protected]> |
License: | CC0 |
Version: | 0.1.1 |
Built: | 2025-02-01 05:59:32 UTC |
Source: | https://github.com/wjschne/psycheval |
Computes covariances of composite scores given a covariance matrix and a weight matrix
composite_covariance(Sigma, w, correlation = FALSE)
composite_covariance(Sigma, w, correlation = FALSE)
Sigma |
Covariance matrix |
w |
Weight matrix. Must have the same number of rows as R |
correlation |
If TRUE, return correlations instead of covariances |
# Create variable names v_names <- c(paste0("A_", 1:3),paste0("B_", 1:3)) v_composites <- c("A", "B") # Create covariance matrix Sigma <- matrix(0.6, nrow = 6, ncol = 6, dimnames = list(v_names, v_names)) diag(Sigma) <- 1 # Create weight matrix w <- matrix(0, nrow = 6, ncol = 2, dimnames = list(v_names, v_composites)) w[v_names[1:3],"A"] <- 1 w[v_names[4:6],"B"] <- 1 w # covariance matrix of weighted sums composite_covariance(Sigma, w)
# Create variable names v_names <- c(paste0("A_", 1:3),paste0("B_", 1:3)) v_composites <- c("A", "B") # Create covariance matrix Sigma <- matrix(0.6, nrow = 6, ncol = 6, dimnames = list(v_names, v_names)) diag(Sigma) <- 1 # Create weight matrix w <- matrix(0, nrow = 6, ncol = 2, dimnames = list(v_names, v_composites)) w[v_names[1:3],"A"] <- 1 w[v_names[4:6],"B"] <- 1 w # covariance matrix of weighted sums composite_covariance(Sigma, w)
Compute composite score
composite_score( x, R, mu_x = 100, sigma_x = 15, mu_composite = 100, sigma_composite = 15, w = NULL )
composite_score( x, R, mu_x = 100, sigma_x = 15, mu_composite = 100, sigma_composite = 15, w = NULL )
x |
Vector of subtest scores |
R |
Subtest score correlation matrix |
mu_x |
Vector of subtest means |
sigma_x |
Vector of subtest standard deviations |
mu_composite |
Composite mean |
sigma_composite |
Composite standard deviation |
w |
Vector of weights |
composite score
# Subtest scores x <- c(12, 14) R <- matrix(c(1,.6, .6, 1), nrow = 2) composite_score(x = x, R = R, mu_x = 10, sigma_x = 3)
# Subtest scores x <- c(12, 14) R <- matrix(c(1,.6, .6, 1), nrow = 2) composite_score(x = x, R = R, mu_x = 10, sigma_x = 3)
Conditional Covariance
conditional_covariance(x, sigma, mu = 0)
conditional_covariance(x, sigma, mu = 0)
x |
named numeric vector of predictor scores |
sigma |
named covariance matrix of predictor and outcome variables |
mu |
a single numeric mean for all variables or a named vector of means of predictor and outcome variables |
list of conditional means and a covariance matrix
mu_conditional
- The means of the outcome variables conditioned on the values of the predictors in vector x.
mu_sigma
- The covariance matrix of the outcome variables conditioned on the values of the predictors in vector x.
descriptives_conditional
- A data frame of means and standard deviations of the outcome variables conditioned on the values of the predictors in vector x.
x
- The predictor scores from the x parameter
sigma
- The unconditional covariance matrix from the sigma parameter
mu
- Anamed vector of unconditional means
beta
- Regression Coefficients for finding mu_conditional
# Named vector of predictor scores x <- c(A = 1) # Named vector of unconditional means mu <- c(A = 0, B = 0, C = 0) # Unconditional covariance matrix with row and column names sigma <- matrix(c(1, .5, .5, .5, 1, .5, .5, .5, 1), nrow = 3, ncol = 3, dimnames = list(names(mu), names(mu))) # Conditoinal means and covariance matrix conditional_covariance(x = x, sigma = sigma, mu = mu)
# Named vector of predictor scores x <- c(A = 1) # Named vector of unconditional means mu <- c(A = 0, B = 0, C = 0) # Unconditional covariance matrix with row and column names sigma <- matrix(c(1, .5, .5, .5, 1, .5, .5, .5, 1), nrow = 3, ncol = 3, dimnames = list(names(mu), names(mu))) # Conditoinal means and covariance matrix conditional_covariance(x = x, sigma = sigma, mu = mu)
Difference score statistics
difference_score( x, y, r_xx = 0.9, r_yy = 0.9, r_xy = 0, mu = 100, sigma = 15, ci = 0.95, mu_x = mu, mu_y = mu, sigma_x = sigma, sigma_y = sigma, tails = 2 )
difference_score( x, y, r_xx = 0.9, r_yy = 0.9, r_xy = 0, mu = 100, sigma = 15, ci = 0.95, mu_x = mu, mu_y = mu, sigma_x = sigma, sigma_y = sigma, tails = 2 )
x |
first score |
y |
second score |
r_xx |
reliability of x |
r_yy |
reliability of y |
r_xy |
correlation between x and y |
mu |
population mean of both x and y |
sigma |
population standard deviation of both x and y |
ci |
confidence interval of difference score |
mu_x |
population mean of x (defaults to mu) |
mu_y |
population mean of y (defaults to mu) |
sigma_x |
population standard deviation of x (defaults to sigma) |
sigma_y |
population standard deviation of y (defaults to sigma) |
tails |
for significance and prevalence of difference scores |
list
difference_score( x = 120, y = 110, r_xx = .95, r_yy = .92, r_xy = .65, mu = 100, sigma = 15)
difference_score( x = 120, y = 110, r_xx = .95, r_yy = .92, r_xy = .65, mu = 100, sigma = 15)
Convert logits to W scores
logit2w(logit, refw = 500)
logit2w(logit, refw = 500)
logit |
numeric vector of logits |
refw |
numeric vector of reference W scores |
numeric vector of W scores
logit2w(2)
logit2w(2)
General a multivariate confidence interval for a set of scores
multivariate_ci(x, r_xx, mu, sigma, ci = 0.95, v_names = names(x))
multivariate_ci(x, r_xx, mu, sigma, ci = 0.95, v_names = names(x))
x |
a vector of scores |
r_xx |
a vector reliability coefficients |
mu |
a vector means |
sigma |
a covariance matrix |
ci |
confidence level |
v_names |
a vector of names |
A data frame with the following columns:
variable
- Variable names
x
- Variable scores
r_xx
- Reliability coefficients
mu_univariate
- Expected true score estimated from the corresponding observed score
see_univariate
- Standard error of the estimate computed from the corresponding reliability coefficient
mu_multivariate
- Expected true score estimated from all observed scores
see_multivariate
- Standard error of the estimate computed from the corresponding reliability coefficient
upper_univariate
- upper bound of univariate confidence interval
lower_univariate
- lower bound of univariate confidence interval
upper_multivariate
- upper bound of multivariate confidence interval
lower_multivariate
- lower bound of multivariate confidence interval
# Observed Scores x <- c( vci = 130, vsi = 130, fri = 70, wmi = 130, psi = 130 ) # Reliability Coefficients r_xx <- c( vci = .92, vsi = .92, fri = .93, wmi = .92, psi = .88 ) # Correlation matrix R <- (" index vci vsi fri wmi psi vci 1.00 0.59 0.59 0.53 0.30 vsi 0.59 1.00 0.62 0.50 0.36 fri 0.59 0.62 1.00 0.53 0.31 wmi 0.53 0.50 0.53 1.00 0.36 psi 0.30 0.36 0.31 0.36 1.00") |> readr::read_tsv() |> tibble::column_to_rownames("index") |> as.matrix() # Covariance matrix sigma <- R * 15 ^ 2 # Population means#' mu <- rep(100, 5) mci <- multivariate_ci( x = x, r_xx = r_xx, mu = mu, sigma = sigma ) mci # Conditional covariance of true score estimates attr(mci, "conditional_covariance")
# Observed Scores x <- c( vci = 130, vsi = 130, fri = 70, wmi = 130, psi = 130 ) # Reliability Coefficients r_xx <- c( vci = .92, vsi = .92, fri = .93, wmi = .92, psi = .88 ) # Correlation matrix R <- (" index vci vsi fri wmi psi vci 1.00 0.59 0.59 0.53 0.30 vsi 0.59 1.00 0.62 0.50 0.36 fri 0.59 0.62 1.00 0.53 0.31 wmi 0.53 0.50 0.53 1.00 0.36 psi 0.30 0.36 0.31 0.36 1.00") |> readr::read_tsv() |> tibble::column_to_rownames("index") |> as.matrix() # Covariance matrix sigma <- R * 15 ^ 2 # Population means#' mu <- rep(100, 5) mci <- multivariate_ci( x = x, r_xx = r_xx, mu = mu, sigma = sigma ) mci # Conditional covariance of true score estimates attr(mci, "conditional_covariance")
Assumes multivaraiate normality of true and observed scores
p_true_score_less_than_threshold(x, threshold, rxx, mu = 100, sigma = 15)
p_true_score_less_than_threshold(x, threshold, rxx, mu = 100, sigma = 15)
x |
observed score |
threshold |
threshold score |
rxx |
reliability coefficient (must be between 0 and 1, exclusively) |
mu |
population mean (default = 100) |
sigma |
population standard deviation (default = 15) |
a probability
# What is the probability that a true score is 70 or less when # the observed score is 65, the reliability coefficient is .95, # the population mean is 100, and the population standard # deviation is 15? p_true_score_less_than_threshold( x = 65, threshold = 70, rxx = .95, mu = 100, sigma = 15)
# What is the probability that a true score is 70 or less when # the observed score is 65, the reliability coefficient is .95, # the population mean is 100, and the population standard # deviation is 15? p_true_score_less_than_threshold( x = 65, threshold = 70, rxx = .95, mu = 100, sigma = 15)
Convert ability (in W scores by default) to relative proficiency index
rpi( x, mu = 500, scale = 20/log(9), criterion = 0.9, reverse = FALSE, interpretation = FALSE )
rpi( x, mu = 500, scale = 20/log(9), criterion = 0.9, reverse = FALSE, interpretation = FALSE )
x |
numeric vector of ability scores |
mu |
numeric vector of ability scores of reference group |
scale |
number vector of scaling factor. The default value ( |
criterion |
numeric proficiency criterion (between 0 and 1, exclusive) |
reverse |
boolean. If TRUE, the criterion refers to the proficiency of the person instead of the proficiency of the peer group. In other words, the role of the x and mu are reversed. |
interpretation |
If TRUE, the rpi's print method will provide an interpretation of the relative proficiency. |
numeric
# What is the probability a person with a W score of 540 can pass # an item that a person with a 500 W score can pass with a # probability of .90? rpi(x = 540, mu = 500, criterion = .9) # Same as above but with an interpretive statement rpi(x = 540, mu = 500, criterion = .9, interpretation = TRUE) # When a person with a W score of 540 has a .9 probability of # passing an item, what is the probability that a person with a W # score of 500 will pass it? rpi(x = 540, mu = 500, criterion = .9, reverse = TRUE, interpretation = TRUE)
# What is the probability a person with a W score of 540 can pass # an item that a person with a 500 W score can pass with a # probability of .90? rpi(x = 540, mu = 500, criterion = .9) # Same as above but with an interpretive statement rpi(x = 540, mu = 500, criterion = .9, interpretation = TRUE) # When a person with a W score of 540 has a .9 probability of # passing an item, what is the probability that a person with a W # score of 500 will pass it? rpi(x = 540, mu = 500, criterion = .9, reverse = TRUE, interpretation = TRUE)
Convert W scores to logits
w2logit(w, refw = 500)
w2logit(w, refw = 500)
w |
numeric vector of W scores |
refw |
numeric vector of reference W scores |
numeric vector of logits
w2logit(540)
w2logit(540)
Convert W scores to a probabilities
w2p(w = 500, refw = 500)
w2p(w = 500, refw = 500)
w |
person ability in w-score units |
refw |
item difficulty in w-score units |
numeric vector of probabilities
w2p(w = 520, refw = 500)
w2p(w = 520, refw = 500)
Convert x to a standard score
x2standard( x, mu_x = mean(x, na.rm = T), sigma_x = stats::sd(x, na.rm = T), mu_new = 100, sigma_new = 15, digits = ifelse(sigma_new == 1, 2, 0) )
x2standard( x, mu_x = mean(x, na.rm = T), sigma_x = stats::sd(x, na.rm = T), mu_new = 100, sigma_new = 15, digits = ifelse(sigma_new == 1, 2, 0) )
x |
a numeric vector |
mu_x |
mean of current scores |
sigma_x |
standard deviation of current scores |
mu_new |
mean of new scores |
sigma_new |
standard deviation of new scores |
digits |
rounding digits |
numeric vector
x2standard(13, mu_x = 10, sigma_x = 3)
x2standard(13, mu_x = 10, sigma_x = 3)