Norms_and_age_corrections: Create norms and adjust scores for age effects

make_normsR Documentation

Create norms and adjust scores for age effects

Description

This function adjusts for the effect of age on the mean and standard deviation of a score, and then creates norms for setting the resulting scores to follow the IQ scale of 100/15 for the chosen subgroup.

Usage

make_norms(score, age, norm_group = NULL, p_value = 0.01)

apply_norms(
  score,
  age,
  prior_norms = NULL,
  age_model_slope = 0,
  age_model_intercept = 0,
  age_model_abs_slope = 0,
  age_model_abs_intercept = 0,
  mean = NULL,
  sd = NULL
)

Arguments

score

A vector of scores to correct

age

A vector of ages to use

norm_group

A logical vector of the same length as the score vector, indicating the norm group. Default is all cases.

p_value

The p value threshold for model inclusion. Default is .01.

prior_norms

A list of prior norms to use from make_norms

age_model_slope

A manually supplied slope for the age model

age_model_intercept

A manually supplied intercept for the age model

age_model_abs_slope

A manually supplied slope for the age model

age_model_abs_intercept

A manually supplied intercept for the age model

mean

A manually supplied mean for the norm group

sd

A manually supplied standard deviation for the norm group

Value

A list of results, including corrected scores, age correction models used, and means and standard deviations for the norm group post-correction.

A vector of IQ scores

Examples

#simulate some data, mess up the norms, and get them back
set.seed(1)
data = tibble(
 true_IQ = c(rnorm(1000, mean = 100, sd = 15), rnorm(1000, mean = 90, sd = 15)),
 true_z = (true_IQ - 100 ) / 15,
 age = runif(2000, min = 18, max = 80),
 norm_group = c(rep(T, 1000), rep(F, 1000))
 ) %>% mutate(
 #add an effect of age on the mean and dispersion of scores
 age_mean_effect = age * 0.3 - 0.3 * 18,
 age_sd_effect = true_z * 15 * rescale(age, new_min = .80, new_max = 1.20),
 score = 100 + age_sd_effect + age_mean_effect
 )

 #restore the norms
 norms = make_norms(data$score, data$age, data$norm_group)
 data$IQ = norms$data$IQ
 #manually apply norms
 data$IQ2 = apply_norms(data$score, data$age, prior_norms = norms)
 data$IQ3 = apply_norms(data$score, data$age,
 age_model_slope = norms$age_model$coefficients[2],
 age_model_intercept = norms$age_model$coefficients[1],
 age_model_abs_slope = norms$age_model_abs$coefficients[2],
 age_model_abs_intercept = norms$age_model_abs$coefficients[1],
 mean = norms$norm_desc$mean,
 sd = norms$norm_desc$sd
 )

 #verify that scores were made correct
 cor(data)
 GG_scatter(data, "age", "score")
 #can we detect the age heteroscedasticity too?
 test_HS(resid = resid(lm(score ~ age, data = data)), x = data$age)
 #plot the results
 GG_scatter(data, "true_IQ", "score") + geom_abline(slope = 1, intercept = 0, linetype = 2)
 GG_scatter(data, "true_IQ", "IQ") + geom_abline(slope = 1, intercept = 0, linetype = 2)

Deleetdk/kirkegaard documentation built on May 2, 2024, 7:12 p.m.