This function wraps jtools::svycor() so that it works in a srvyr-pipeline, runs bootstrapped significance-tests and calculates weighted summary statistics. Only numeric variables are included in the result.

svy_cor_matrix(svy_data, var_names = NULL, ci_level = 0.95)

Arguments

svy_data

A survey object created with the survey or srvyr package. Only numeric variables will be included in the result.

var_names

A named character vector with new variable names or a tibble as provided by get_rename_tribbles() for variables. If NULL, then the variables are not renamed. If names are provided, only the variables included here are retained. This is most helpful when the results are passed to some print function, such as report_cor_table()

ci_level

Confidence level for confidence intervals (default = 0.95)

Value

A correlation matrix list in the format provided by jtools::svycor() with the addition of a desc-element with means and standard deviations of the variables, plus ci.low and ci.high matrices.

Examples

if (FALSE) { # \dontrun{
if (requireNamespace("survey") & requireNamespace("srvyr")) {
 library(survey)
 library(srvyr)
 data(api)
 # Create survey design object
 dstrat <- apistrat %>% as_survey_design(1, strata = stype, fpc = fpc, weight = pw)

var_names <- c(meals = "Share subsidized meals", ell = "English language learners",
              growth = "Performance Change")

 # Print correlation matrix with confidence intervals
 result <- svy_cor_matrix(dstrat, var_names)
 print(result$ci.low)  # Lower confidence bounds
 print(result$ci.high) # Upper confidence bounds
}
} # }