Title: | Calculate Results from WHO Model Disability Survey Data |
---|---|
Description: | The Model Disability Survey (MDS) <https://www.who.int/activities/collection-of-data-on-disability> is a World Health Organization (WHO) general population survey instrument to assess the distribution of disability within a country or region, grounded in the International Classification of Functioning, Disability and Health <https://www.who.int/standards/classifications/international-classification-of-functioning-disability-and-health>. This package provides fit-for-purpose functions for calculating and presenting the results from this survey, as used by the WHO. The package primarily provides functions for implementing Rasch Analysis (see Andrich (2011) <doi:10.1586/erp.11.59>) to calculate a metric scale for disability. |
Authors: | Lindsay Lee [aut, cre], Carolina Fellinghauer [ctb], World Health Organization [cph] |
Maintainer: | Lindsay Lee <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1.9000 |
Built: | 2024-11-19 05:59:35 UTC |
Source: | https://github.com/lindsayevanslee/whomds |
An dummy data set of data from the WHO Model Disability Survey. All survey variables and demographic characteristics (except work status) are randomly generated. Responses to the survey questions and work status are from randomly selected rows of the 2014 Chilean implementation of the MDS, ENDIS II (2014).
df_adults
df_adults
A tibble with 2500 rows and 90 variables:
household number
survey strata
PSU id
survey weights
sex, Male or Female
age in years
age catgory, one of "18-24", "25-39", "40-64", or "64-100"
highest level of education attained
whether respondent is currently working, binary
metric scale of performance, from Rasch analysis
performance level, as definted by WHO cutoffs of disability_score
Functioning section: On a scale from 1 (none) to 5 (extreme), in the last 30 days, taking into account any help or support you receive, how much has of a problem has it been for you to...
...stand up from sitting?
...stand for long periods of time, for example 30 minutes?
...leave the house?
...walk short distances, such as a street block or 100 meters?
...walk 10 blocks or a kilometer?
...do vigorous activities, such as play footbal, lift heavy objects, ride a bike or run?
...get where you want to go?
...manipulate small objects or opening a container?
...lift a 2L full bottle of water from your waist to eye level?
...wash or dress yourself?
...feed yourself?
...use the bathroom?
...cut your toenails?
...take care of your health, for example exercise, eat well or take your medications?
...see objects at a distance?
...see objects at arms length?
...hear a conversation in a quiet room?
...hear a conversation in a loud room?
...feel pain?
...sleep?
...feel tired or not have enough energy?
...feel short of breath?
...cough or wheeze?
...feel sad, down or depressed?
...feel worried, nervous or anxious?
...get along with people close to you, including your family and friends?
...get along with people you don't know?
...make new friends or maintain your friendships?
...have intimiate relationships?
...manage stress?
...cope with everything you have to do?
...be understood in your usual language?
...understand others in your usual language?
...forget things?
...remember the important things you have to do day-to-day?
...find solutions to your day-to-day problems?
...complete household tasks, like sweeping, cooking, arranging the house or taking our the trash?
...manage the money you have?
...do things for relaxation?
...participate in community activities?
...participate in local or national policitics or civil society?
...take care of others?
...get a job?
...obtain a higher education?
...use public transportation?
...get things done in your job (if not currently working, NA)?
...get things done at your school (if not currently studying, NA)?
Capacity section: On a scale from 1 (none) to 5 (extreme), in the last 30 days, withing taking into account any type of help or support, due to your health how much difficulty have you had with...
...seeing, without contact lenses or glasses?
...hearing, without hearing aids?
...walking or climbing steps?
...remembering or concentrating?
...washing or dressing?
...communicating in your usual language?
...feeding yourself?
...using the bathroom?
...waking up and getting out of bed?
...going out to the street?
...doing shopping or going to the doctor?
...manipulating small objects or opening a container?
...sleeping?
...breathing?
...doing household tasks like sweeping, cooking, arranging the house or taking out the trash?
...taking care of others?
...participating in community activities?
...feeling sad, down or depressed?
...feeling worried, nervous or anxious?
...getting along with people close to you, including your family and friends?
...coping with everything you have to do?
...feeling pain?
...getting things done in your job (if not currently working, NA)?
...getting things done at your school (if not currently studying, NA)?
Environmental factors section: On a scale from 1 (very easy) to 5 (very hard), to what extent...
...do health facilities you need regularly make it easy or hard for you to use them?
...do places where you socialize and engage in community activities make it easy or hard for you to do this?
...do the shops, banks and post office in your neighbourhood make it easy or hard for you to use them?
...do your regular places of worship make it easy or hard for you to worship?
...does the transportation you need or want to use make it easy or hard for you to use it?
...does your dwelling (including the toilet and all rooms) make it easy or hard for you to live there?
...do the temperature, terrain, and climate of the place you usually live make it easy or hard for you to live there?
...does the lighting in your surroundings make it easy or hard for you to live there?
...does the noise in your surroundings make it easy or hard for you to live there?
...do the crowds in your surroundings make it easy or hard for you to live there?
...does your workplace make it easy or hard for you to work or learn (if not currently working, NA)?
...does your educational institution make it easy or hard for you to work or learn (if not currently studying, NA)?
An dummy data set of data from the WHO Model Disability Survey for children. All survey variables and demographic characterstics (except age variables) are randomly generated. Responses to the survey questions and age variables are from randomly selected rows of the 2014 Chilean implementation of the MDS, ENDIS II (2014).
df_children
df_children
A tibble with 2500 rows and 42 variables:
household number
survey strata
PSU id
survey weights
sex, Male or Female
age in years
age catgory, one of "Age2to4", "Age5to9", or "Age10to17"
Functioning section: On a scale from 1 (none) to 5 (extreme), in the last 30 days, taking into account any help or support the child receives, compared with children of the same age, how much has of a problem it been for the child to...
...walk?
...manipulat small objects or opening a container?
...see things from a long distance?
...hear?
...feel pain?
...not have enough energy?
...have too much energy
...feel short of breath?
...feel sad, down or depressed?
...feel worried, nervous or anxious?
...(for children aged 5 to 17) wash or dress him- or herself?
...(for children aged 2 to 4) bite or hit other children or adults?
...(for children aged 5 to 17) control his or her own behavior?
...(for children aged 5 to 17) get along with children of the same age?
...(for children aged 2 to 4) understand what you say to him or her?
(for children aged 2 to 4) How much of a problem has it been for you to understand what the child says?
...(for children aged 5 to 17) understand other people?
...(for children aged 5 to 17) be understood?
...(for children aged 2 to 3) learn the names of household objects?
...(for children aged 3 to 17) learn to do new things?
...(for children aged 5 to 17) complete a task?
...(for children aged 5 to 17) make changes to his or her routine?
...(for children aged 5 to 17) do homework as requested at school?
...(for children aged 2 to 5) play with toys or domestic objects?
...(for children aged 2 to 12) play with other children?
...(for children aged 13 to 17) do activities with other children?
...(for children aged 5 to 17) participate in community activities?
Capacity section: On a scale from 1 (none) to 5 (extreme), in the last 30 days, without taking into account any help or support the child receives, how much has difficulty has the child had with...
...seeing without glasses?
...hearing without hearing aids?
...walking?
...understanding you or others?
...learning?
...controling his or her behavior?
...completing a task?
...getting along with other children?
Plot a density of a score
fig_density( df, score, var_color = NULL, var_facet = NULL, cutoffs = NULL, x_lab = "Score", pal = "Paired", adjust = 2, size = 1.5 )
fig_density( df, score, var_color = NULL, var_facet = NULL, cutoffs = NULL, x_lab = "Score", pal = "Paired", adjust = 2, size = 1.5 )
df |
a data frame where each row is an individual, containing at least a score column (between 0 and 100) |
score |
a string (length 1) of the column name for the score variable to print the distribution of |
var_color |
a string (length 1) of the column name for the variable to set color of density lines by. Default is NULL. |
var_facet |
a string (length 1) of the column name for the variable to create a |
cutoffs |
a numeric vector of the cut-offs for the score categorization. Default is NULL. |
x_lab |
a string (length 1) of x-axis label. Default is "Score". |
pal |
a string specifying either a manual color to use for the color aesthetic, a character vector explictly specifying the colors to use for the color scale, or as the name of a palette to pass to |
adjust |
a numeric value to pass to |
size |
a numeric value to pass to |
Plots a histogram of a score that ranges between 0 and 100, with the fill determined by some set categorization of the score. This is the function used to plot the distributions of disability scores resulting from the WHO Model Disability Survey.
A density figure
Other figure functions:
fig_LID()
,
fig_dist()
,
fig_poppyramid()
fig_density(df_adults, score = "disability_score", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_density(df_adults, score = "disability_score", var_color = "sex", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_density(df_adults, score = "disability_score", var_color = "sex", var_facet = "age_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score")
fig_density(df_adults, score = "disability_score", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_density(df_adults, score = "disability_score", var_color = "sex", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_density(df_adults, score = "disability_score", var_color = "sex", var_facet = "age_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score")
Plot a distribution of a score
fig_dist( df, score, score_cat, cutoffs, x_lab = "Score", y_max = NULL, pcent = FALSE, pal = "Blues", binwidth = 5 )
fig_dist( df, score, score_cat, cutoffs, x_lab = "Score", y_max = NULL, pcent = FALSE, pal = "Blues", binwidth = 5 )
df |
a data frame where each row is an individual, containing at least a score column (between 0 and 100) and a categorization of that score |
score |
a string (length 1) of the column name for the score variable to print the distribution of |
score_cat |
a string (length 1) of the column name for the categorization of the score variable |
cutoffs |
a numeric vector of the cut-offs for the score categorization |
x_lab |
a string (length 1) of x-axis label. Default is "Score". |
y_max |
a numeric value of the maximum limit on the y-axis. Default is NULL to use default value from |
pcent |
a logical value determining whether or not to display the distribution as percentages or frequency. Default is FALSE, to display as frequency. |
pal |
a string to pass to |
binwidth |
a numeric value giving the width of the bins in the histograph. Default is 5. |
Plots a histogram of a score that ranges between 0 and 100, with the fill determined by some set categorization of the score. This is the function used to plot the distributions of disability scores resulting from the WHO Model Disability Survey.
A score distribution figure with fill based on categorization of the score
Other figure functions:
fig_LID()
,
fig_density()
,
fig_poppyramid()
fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score", y_max = 2000) fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score", y_max = 0.2, pcent=TRUE)
fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score") fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score", y_max = 2000) fig_dist(df_adults, score = "disability_score", score_cat = "disability_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score", y_max = 0.2, pcent=TRUE)
Print a graph showing significant correlations between survey items
fig_LID( LIDforgraph, LIDcutoff = 0.2, path_output, extra_file_label = NULL, vertex_print_grey = NULL )
fig_LID( LIDforgraph, LIDcutoff = 0.2, path_output, extra_file_label = NULL, vertex_print_grey = NULL )
LIDforgraph |
a square matrix of item correlations |
LIDcutoff |
a numeric value between 0 and 1 for the cut-off for significant correlation |
path_output |
a string with the path to the output folder |
extra_file_label |
a string to tack on to the end of names of files outputted and the title of the plot. Default is NULL. |
vertex_print_grey |
a character vector with the names of vertices to print in |
This function could be applied to visualize any kind of correlations. But within the context of the Rasch Analysis used for the WHO Model Disability Survey, the residual correlations are used when analyzing item dependence.
Returns a ggplot graph showing the items with correlation >= LIDcutoff
and prints a csv of the corresponding correlations
Other figure functions:
fig_density()
,
fig_dist()
,
fig_poppyramid()
Print a population pyramid
fig_poppyramid( df, var_age, var_sex, x_axis = c("n", "pct"), age_plus = 100, age_by = 5 )
fig_poppyramid( df, var_age, var_sex, x_axis = c("n", "pct"), age_plus = 100, age_by = 5 )
df |
a data frame of individual survey data, where each row is an individual |
var_age |
a string (length 1) of the name of the age column |
var_sex |
a string (length 1) of the name of the sex column |
x_axis |
a string (length 1) indicating whether to use absolute numbers or sample percentage on the x-axis. Choices are |
age_plus |
a numeric value (length 1) indicating the age that is the first value of the oldest age group. Default is 100, for the last age group to be 100+ |
age_by |
a numeric value (length 1) indicating the width of each age group, in years. Default is 5. |
A population pyramid gives an image of the age and sex distribution of a population.
The function divides the var_age
variable into intervals of width age_by
.
A population pyramid figure
Other figure functions:
fig_LID()
,
fig_density()
,
fig_dist()
fig_poppyramid(df_adults, "age", "sex")
fig_poppyramid(df_adults, "age", "sex")
Check a vector for particular values
helper_checkrow( row, check_type = c("all_equal", "all_not_equal", "any_in"), check_value, na_rm = TRUE )
helper_checkrow( row, check_type = c("all_equal", "all_not_equal", "any_in"), check_value, na_rm = TRUE )
row |
a vector of data |
check_type |
a string indicating the type of check to do on |
check_value |
a vector of values to check against |
na_rm |
logical indicating whether or not to perform check after removing NAs, passed to argument |
If all values of row
are NA, then an NA is returned.
a logical vector with the result of the check
Other helper functions:
helper_palette()
,
helper_varslist()
Create indicators from data frame
helper_indicator( df, vars_indicators, mapvalues_from, mapvalues_to, make_factor = TRUE )
helper_indicator( df, vars_indicators, mapvalues_from, mapvalues_to, make_factor = TRUE )
df |
a data frame |
vars_indicators |
a character vector of the variables from |
mapvalues_from |
vector to pass to |
mapvalues_to |
vector to pass to |
make_factor |
a logical indicating whether resulting indicators should be factors. Default is |
a data frame with new columns that are the indicators from vars_indicators
, with the same names pasted with "_ind"
.
helper_indicator(df = df_adults, vars_indicators = c("EF1", "EF2", "EF3"), mapvalues_from = 1:5, mapvalues_to = c(0,0,0,1,1))
helper_indicator(df = df_adults, vars_indicators = c("EF1", "EF2", "EF3"), mapvalues_from = 1:5, mapvalues_to = c(0,0,0,1,1))
Compares build date of installed package against the date of the last commit from GitHub (https://github.com/lindsayevanslee/whomds)
helper_installation()
helper_installation()
Prints a message stating whether or not installed package is same as most updated version from Github
Color palette for the MDS
helper_palette( n, h = c(-100, 100), c. = c(60, 100), l = c(15, 95), power = c(2, 0.9), fixup = TRUE, gamma = NULL, alpha = 1, ... )
helper_palette( n, h = c(-100, 100), c. = c(60, 100), l = c(15, 95), power = c(2, 0.9), fixup = TRUE, gamma = NULL, alpha = 1, ... )
n |
the number of colors ( |
h |
hue value in the HCL or HSV color description, has to be in [0, 360] for HCL and in [0, 1] for HSV colors. |
c. |
chroma value in the HCL color description. |
l |
luminance value in the HCL color description. |
power |
control parameter determining how chroma and luminance should be increased (1 = linear, 2 = quadratic, etc.). |
fixup |
logical. Should the color be corrected to a valid RGB value before correction? |
gamma |
Deprecated. |
alpha |
numeric vector of values in the range |
... |
Other arguments passed to |
Generated with colorspace::choose_palette()
n
hex codes from the color palette
Other helper functions:
helper_checkrow()
,
helper_varslist()
Perform row sum
helper_rowSums(x, allNA0 = TRUE, ...)
helper_rowSums(x, allNA0 = TRUE, ...)
x |
an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame |
allNA0 |
logical indicating that if a whole row is NA to give the row sum as NA. Only works for two dimensional |
... |
other arguments to pass to |
Essentially equivalent to base::rowSums()
except with the addition of the allNA0
argument.
A numeric or complex array of suitable size, or a vector if the result is one-dimensional.
x <- data.frame(v1 = c(NA,1:4), v2 = c(NA, 2:5), v3 = c(NA, 1:2, NA, 3)) helper_rowSums(x, na.rm = TRUE, allNA0 = TRUE) helper_rowSums(x, na.rm = TRUE, allNA0 = FALSE)
x <- data.frame(v1 = c(NA,1:4), v2 = c(NA, 2:5), v3 = c(NA, 1:2, NA, 3)) helper_rowSums(x, na.rm = TRUE, allNA0 = TRUE) helper_rowSums(x, na.rm = TRUE, allNA0 = FALSE)
Convert list to vector with unique elements
helper_varslist(vars_list)
helper_varslist(vars_list)
vars_list |
a list of character vectors |
a character vector of all unique items from vars_list
Other helper functions:
helper_checkrow()
,
helper_palette()
Nest data by age group
rasch_df_nest(df, vars_group, vars_id)
rasch_df_nest(df, vars_group, vars_id)
df |
a data frame of individual survey data, where each row is an individual |
vars_group |
a string with the column name identifying grouping variable |
vars_id |
a string with column name uniquely identifying individuals |
nested tibble with two columns: the age group given by vars_group
and df_split
with the split data
Other rasch functions:
rasch_DIF()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Perform analysis of Differential Item Functioning (DIF) for Rasch Model
rasch_DIF( df, vars_metric, vars_DIF, residuals_PCM, split_strategy = NULL, print_results = FALSE, path_output = NULL, breaks = 6 )
rasch_DIF( df, vars_metric, vars_DIF, residuals_PCM, split_strategy = NULL, print_results = FALSE, path_output = NULL, breaks = 6 )
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_DIF |
a string with the column names to use for analyzing differential item functioning (DIF). Default is NULL, to skip analysis of DIF. |
residuals_PCM |
a matrix giving the residuals of the person parameters from the Rasch Model. Row names are the numbers of the people and the columns are for each variable. |
split_strategy |
a named list giving the strategy to take for splitting variables by categories, passed to |
print_results |
a logical value indicating whether or not to print various files displaying results from the Rasch Model. Default is FALSE, to not print the files. |
path_output |
a string with the path to the output folder. Default is NULL. |
breaks |
a numeric value giving the number if class intervals. Default is 6. |
Differential Item Functioning (DIF) refers to the circumstance when different groups in a sample respond to items in different ways. For instance, DIF would be observed if men and women had different patterns of responses to a set of survey questions. DIF can cause poor fit for the Rasch Model, and therefore should be analyzed. This function uses ANOVA to find DIF by the variables supplied and by a generated class interval.
a list with results from the DIF analysis:
df_DIF_class |
the person residuals from the Rasch Model, the assigned class intervals, and the variables used for DIF analysis |
tab_aov_DIF |
the results of the ANOVA used to analyze DIF |
DIF_results |
string of various that exhibit some form of DIF |
Currently the calculation of the class intervals is quite slow. Reducing the number of breaks can improve speed.
Other rasch functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Drop items from a Rasch Analysis
rasch_drop(vars_metric, drop_vars, max_values)
rasch_drop(vars_metric, drop_vars, max_values)
vars_metric |
a character vector of items to use in the Rasch Analysis |
drop_vars |
a character vector of column names to drop from the Rasch Analysis. Default is NULL, to not drop items. |
max_values |
a tibble with two columns, |
Dropping variables might be desirable if one finds that particular items are causing a lot of problems for the fit of a Rasch Model.
a named list with:
vars_metric |
new |
max_values |
new |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Calculate a factor analysis for a Rasch Model
rasch_factor(df, vars_metric, print_results = FALSE, path_output = NULL)
rasch_factor(df, vars_metric, print_results = FALSE, path_output = NULL)
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
print_results |
a logical value indicating whether or not to print various files displaying results from the Rasch Model. Default is FALSE, to not print the files. |
path_output |
a string with the path to the output folder. Default is NULL. |
Unidimensionality of the data is one of the core assumptions of the Rasch Model. This function performs the factor analysis to assess the unidimensionality of the data.
a named list with results from the factor analysis for a Rasch Model:
cor_poly |
the matrix of polychoric correlations |
eigenvalues |
the eigenvalues |
parallel_analysis |
permutation parallel analysis distribution |
results_scree |
results of a scree analysis |
n_group_factors |
number of factors from the parallel analysis in the scree analysis |
fa_onefactor |
results from factor analysis with one factor |
fa_resid |
local dependency based on polychoric correlations of the items |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Top-level function to perform Rasch Analysis on WHO Model Disability Survey data
rasch_mds( df, vars_metric, vars_id, vars_DIF = NULL, resp_opts = 1:5, max_NA = 2, print_results = FALSE, path_parent = NULL, model_name = NULL, testlet_strategy = NULL, recode_strategy = NULL, drop_vars = NULL, split_strategy = NULL, comment = NULL )
rasch_mds( df, vars_metric, vars_id, vars_DIF = NULL, resp_opts = 1:5, max_NA = 2, print_results = FALSE, path_parent = NULL, model_name = NULL, testlet_strategy = NULL, recode_strategy = NULL, drop_vars = NULL, split_strategy = NULL, comment = NULL )
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_id |
a string with column name uniquely identifying individuals |
vars_DIF |
a string with the column names to use for analyzing differential item functioning (DIF). Default is NULL, to skip analysis of DIF. |
resp_opts |
a numeric vector of possible response options for |
max_NA |
a numeric value for the maximum number of NAs allowed per individual among |
print_results |
a logical value indicating whether or not to print various files displaying results from the Rasch Model. Default is FALSE, to not print the files. |
path_parent |
a string with the path to the folder where results from multiple models will be outputted. Default is NULL |
model_name |
a string with a name for the model, which is used to create a new folder for model output. Default is NULL. |
testlet_strategy |
a list giving the strategy to take for creating testlets, passed to |
recode_strategy |
a named list giving the strategy to take for recoding variables, passed to |
drop_vars |
a character vector of column names to drop from the Rasch Analysis. Default is NULL, to not drop items. |
split_strategy |
a named list giving the strategy to take for splitting variables by categories, passed to |
comment |
a string giving a comment describing the analysis, printed to a txt file. Default is NULL, to not print a comment. |
This function combines all of the separate analyses of model fit necessary to assess the quality of the Rasch Model. It is designed to require minimal intervention from the user. Users wishing to have more control over the analysis can use the other Rasch functions in this package separately.
a named list with:
df |
a tibble with new columns representing the original person abilities ( |
vars_metric |
a character vector with the variables used in the metric after all adjustments |
df_results |
a tibble of one row with key results of the model |
If print_results
is TRUE, prints files to the working directory with the results of the Rasch Model.
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Top-level function to perform Rasch Analysis on WHO Model Disability Survey data for children
rasch_mds_children( df, vars_id, vars_group, vars_metric_common, vars_metric_grouped = NULL, TAM_model = "PCM2", vars_DIF = NULL, resp_opts = 1:5, has_at_least_one = 4:5, max_NA = 2, print_results = FALSE, path_parent = NULL, model_name = NULL, testlet_strategy = NULL, recode_strategy = NULL, drop_vars = NULL, split_strategy = NULL, comment = NULL )
rasch_mds_children( df, vars_id, vars_group, vars_metric_common, vars_metric_grouped = NULL, TAM_model = "PCM2", vars_DIF = NULL, resp_opts = 1:5, has_at_least_one = 4:5, max_NA = 2, print_results = FALSE, path_parent = NULL, model_name = NULL, testlet_strategy = NULL, recode_strategy = NULL, drop_vars = NULL, split_strategy = NULL, comment = NULL )
df |
a data frame of individual survey data, where each row is an individual |
vars_id |
a string with column name uniquely identifying individuals |
vars_group |
a string with the column name identifying grouping variable |
vars_metric_common |
a character vector the common items among all individuals |
vars_metric_grouped |
a named list of character vectors with the items to use in the Rasch Analysis per group. The list should have names corresponding to the different groups, and contain character vectors of the corresponding items for each group. |
TAM_model |
a string with the type of IRT model to use, passed to |
vars_DIF |
Currently does nothing. In the future, a string with the column names to use for analyzing differential item functioning (DIF). Default is NULL, to skip analysis of DIF. |
resp_opts |
a numeric vector of possible response options for |
has_at_least_one |
a numeric vector with the response options that a respondent must have at least one of in order to be included in the metric calculation. See details for more information. |
max_NA |
a numeric value for the maximum number of NAs allowed per individual among |
print_results |
a logical value indicating whether or not to print various files displaying results from the Rasch Model. Default is FALSE, to not print the files. |
path_parent |
a string with the path to the folder where results from multiple models will be outputted. Default is NULL |
model_name |
a string with a name for the model, which is used to create a new folder for model output. Default is NULL. |
testlet_strategy |
a list giving the strategy to take for creating testlets, passed to |
recode_strategy |
a named list giving the strategy to take for recoding variables, passed to |
drop_vars |
a character vector of column names to drop from the Rasch Analysis. Default is NULL, to not drop items. |
split_strategy |
a named list giving the strategy to take for splitting variables by categories, passed to |
comment |
a string giving a comment describing the analysis, printed to a txt file. Default is NULL, to not print a comment. |
This function combines all of the separate analyses of model fit necessary to assess the quality of the Rasch Model. It is designed to require minimal intervention from the user. Users wishing to have more control over the analysis can use the other Rasch functions in this package separately.
Often Rasch Analysis of children data is more difficult because of the extreme skewness of the responses. For this reason, it is often advisable to build a scale only with the respondents on the more severe end of the disability continuum. By specifying has_at_least_one
, the function will remove all children from the sample who do endorse an answer of any of has_at_least_one
in at least one vars_metric
. The scores created can be reunited with the excluded children post-hoc.
a tibble with new columns representing the original person abilities (person_pars
) and the rescaled person abilities (rescaled
).
If print_results
is TRUE, prints files to the working directory with the results of the Rasch Model.
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Run the Rasch Model and print diagnostic results
rasch_model( df, vars_metric, vars_id, print_results = FALSE, path_output = NULL, LIDcutoff = 0.2 )
rasch_model( df, vars_metric, vars_id, print_results = FALSE, path_output = NULL, LIDcutoff = 0.2 )
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_id |
a string with column name uniquely identifying individuals |
print_results |
a logical value indicating whether or not to print various files displaying results from the Rasch Model. Default is FALSE, to not print the files. |
path_output |
a string with the path to the output folder. Default is NULL. |
LIDcutoff |
either a numeric value between 0 and 1 indicating the cut-off for significant local item dependence, or the string "christensen" to use the cut-off suggested by Christensen et al. 2017 (see reference). If "christensen" cut-off fails, defaults to 0.2. |
The Rasch Model is calculated using the function eRm::PCM()
.
a list with results from the Rasch Model:
model |
the results from the Rasch Model |
df_score |
a tibble with the items used in the analysis and the person abilities |
thresholds |
the item thresholds (i.e., crossings) |
person_parameters |
person abilities |
PSI |
the person-separation index |
item_fit |
infit and outfit statistics per item |
residuals_PCM |
the standardized person residuals |
LID |
matrix with the item residual correlations |
targeting |
a matrix with information on the targeting of the model |
fit_results |
a string with results of the item fit |
LID_results |
a string with results of the local item dependency |
disordered_results |
a string listing items with disordered thresholds |
Christensen, K. B., Makransky, G., & Horton, M. (2017). Critical Values for Yen’s Q 3 : Identification of Local Dependence in the Rasch Model Using Residual Correlations. Applied Psychological Measurement, 41(3), 178-194. doi:10.1177/0146621616677520
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Run the multigroup and anchored Rasch Model
rasch_model_children(df, df_nest, vars_metric, vars_group, TAM_model)
rasch_model_children(df, df_nest, vars_metric, vars_group, TAM_model)
df |
a data frame of individual survey data, where each row is an individual |
df_nest |
a nested tibble that contains the column |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_group |
a string with the column name identifying grouping variable |
TAM_model |
a string with the type of IRT model to use, passed to |
a nested tibble with new columns with the Rasch Models calculated with the TAM
package
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Calculate quality of multigroup and anchored Rasch Models
rasch_quality_children(df_nest, vars_metric)
rasch_quality_children(df_nest, vars_metric)
df_nest |
a nested tibble that contains the column |
vars_metric |
a character vector of items to use in the Rasch Analysis |
a nested tibble with new columns with information about model quality
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Print results of analysis of Rasch Model quality
rasch_quality_children_print( df_nest, vars_metric, vars_group, TAM_model, LIDcutoff = 0.2, path_output )
rasch_quality_children_print( df_nest, vars_metric, vars_group, TAM_model, LIDcutoff = 0.2, path_output )
df_nest |
a nested tibble that contains the column |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_group |
a string with the column name identifying grouping variable |
TAM_model |
a string with the type of IRT model to use, passed to |
LIDcutoff |
a numeric value between 0 and 1 for the cut-off for significant correlation |
path_output |
a string with the path to the output folder |
does not return anything to the environment, but prints files to the folder specified in path_output
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Add the raw scores to the data and artificial individuals attaining the minimum and/or maximum
rasch_rawscore(df, vars_metric, vars_id, max_values)
rasch_rawscore(df, vars_metric, vars_id, max_values)
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_id |
a string with column name uniquely identifying individuals |
max_values |
a tibble with two columns, |
a tibble with a new column RawScore
with the raw sum score of vars_metric
for each individual, and artificial rows with individuals that attain the minimum and/or maximum if either is not attained in df
. The artificial maximum row has value "MAX" in the vars_id
column, and likewise the artificial minimum row has the value "MIN" in this column.
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Recode survey items for use in Rasch Analysis
rasch_recode(df, vars_metric, recode_strategy, max_values)
rasch_recode(df, vars_metric, recode_strategy, max_values)
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
recode_strategy |
a named list giving the strategy to take for recoding variables, passed to |
max_values |
a tibble with two columns, |
a named list with:
df |
new |
max_values |
new |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Rescale score from Rasch Analysis to range from 0 to 100
rasch_rescale(df, df_score, vars_id)
rasch_rescale(df, df_score, vars_id)
df |
a data frame of individual survey data, where each row is an individual |
df_score |
a tibble resulting from |
vars_id |
a string with column name uniquely identifying individuals |
a tibble with the left join between df
and df_score
and new column "rescaled" with the rescaled person abilities, ranging from 0 to 100, and filter out any rows with an artificial minimum or maximum
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Rescale score from Rasch Analysis for children to range from 0 to 100
rasch_rescale_children(df, df_nest, vars_group, vars_id)
rasch_rescale_children(df, df_nest, vars_group, vars_id)
df |
a data frame of individual survey data, where each row is an individual |
df_nest |
a nested tibble that contains the column |
vars_group |
a string with the column name identifying grouping variable |
vars_id |
a string with column name uniquely identifying individuals |
a tibble with the data df
or unnested df_nest
and new columns "person_pars" and "rescaled" with the original and rescaled person abilities, ranging from 0 to 100, and filter out any rows with an artificial minimum or maximum
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_split_age()
,
rasch_split()
,
rasch_testlet()
Split survey items by categories for a Rasch Model
rasch_split(df, vars_metric, split_strategy, max_values)
rasch_split(df, vars_metric, split_strategy, max_values)
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
split_strategy |
a named list giving the strategy to take for splitting variables by categories, passed to |
max_values |
a tibble with two columns, |
If significant differential item functioning (DIF) is observed, it may be desirable to split variables based on the characteristic for which DIF is observed. For example, if men and women have significantly different patterns of responses to items, then it may be desirable to split items by sex. This function performs that variable splitting.
a named list with:
df |
new |
vars_metric |
new |
max_values |
new |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_testlet()
Split all survey items by age category for a Rasch Model if they are not discrete
rasch_split_age(df, vars_group, vars_metric, vars_id, max_values)
rasch_split_age(df, vars_group, vars_metric, vars_id, max_values)
df |
a data frame of individual survey data, where each row is an individual |
vars_group |
a string with the column name identifying grouping variable |
vars_metric |
a character vector of items to use in the Rasch Analysis |
vars_id |
a string with column name uniquely identifying individuals |
max_values |
a tibble with two columns, |
a named list with:
df |
new |
vars_metric |
new |
max_values |
new |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split()
,
rasch_testlet()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split()
,
rasch_testlet()
Create testlets of survey items for a Rasch Model
rasch_testlet(df, vars_metric, testlet_strategy, max_values, resp_opts)
rasch_testlet(df, vars_metric, testlet_strategy, max_values, resp_opts)
df |
a data frame of individual survey data, where each row is an individual |
vars_metric |
a character vector of items to use in the Rasch Analysis |
testlet_strategy |
a list giving the strategy to take for creating testlets, passed to |
max_values |
a tibble with two columns, |
resp_opts |
a numeric vector of possible response options for |
If high local item dependence is observed (i.e., residual correlation) is observed between items, it may be desirable to combine them into a testlet. This code creates the testlets as desired.
a named list with:
df |
new |
vars_metric |
new |
testlet_strategy |
new |
max_values |
new |
Other rasch functions:
rasch_DIF()
,
rasch_df_nest()
,
rasch_drop()
,
rasch_factor()
,
rasch_mds_children()
,
rasch_mds()
,
rasch_model_children()
,
rasch_model()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_rawscore()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_rescale()
,
rasch_split_age()
,
rasch_split()
Other children analysis functions:
rasch_df_nest()
,
rasch_drop()
,
rasch_mds_children()
,
rasch_model_children()
,
rasch_quality_children_print()
,
rasch_quality_children()
,
rasch_recode()
,
rasch_rescale_children()
,
rasch_split_age()
,
rasch_split()
Copied from eRm::SepRel(), v1.0-1: This function calculates the proportion of person variance that is not due to error. The concept of person separation reliability is very similar to reliability indices such as Cronbach's alpha.
SepRel_1.0.1(pobject)
SepRel_1.0.1(pobject)
pobject |
Object of class |
See full documentation at https://www.rdocumentation.org/packages/eRm/versions/1.0-1/topics/Separation%20Reliability
SepRel returns a list object of class eRm_SepRel containing:
sep.rel |
the person separation reliability, |
SSD.PS |
the squared standard deviation (i.e., total person variability), |
MSE |
the mean square measurement error (i.e., model error variance). |
Original code by Adrian Brügger ([email protected]), adapted by Marco J. Maier in package eRm
v1.0-1
Wright, B.D., and Stone, M.H. (1999). Measurement essentials. Wide Range Inc., Wilmington. (https://www.rasch.org/measess/me-all.pdf 28Mb).
Compute basic statistics of the number of members per group per household
table_basicstats(df, hh_id, group_by_var)
table_basicstats(df, hh_id, group_by_var)
df |
a data frame of household data where the rows represent members of the households in the sample |
hh_id |
string (length 1) indicating the name of the variable in |
group_by_var |
string (length 1) to pass to |
A tibble with rows for each level of group_by_var
and "Total" and columns for the Mean (SD), Median and Range of the number of people in each group per household.
Includes a call to tidyr::complete()
, which causes the function to be a bit slow.
Other table functions:
table_unweightedpctn()
,
table_weightedpct()
#create dummy table of household data, where each row represents one member df_hh <- data.frame(HHID = sample( x = 1:300, size = 1000, replace = TRUE ), age_cat = ordered(sample( x = c("18-24", "25-39", "40-64", "64-100"), size = 1000, replace = TRUE ))) table_basicstats(df_hh, "HHID", "age_cat")
#create dummy table of household data, where each row represents one member df_hh <- data.frame(HHID = sample( x = 1:300, size = 1000, replace = TRUE ), age_cat = ordered(sample( x = c("18-24", "25-39", "40-64", "64-100"), size = 1000, replace = TRUE ))) table_basicstats(df_hh, "HHID", "age_cat")
Compute unweighted percent and N for multiple variables, disaggregated
table_unweightedpctn( df, vars_demo, group_by_var = NULL, spread_by_group_by_var = FALSE, group_by_var_sums_to_100 = FALSE, add_totals = FALSE )
table_unweightedpctn( df, vars_demo, group_by_var = NULL, spread_by_group_by_var = FALSE, group_by_var_sums_to_100 = FALSE, add_totals = FALSE )
df |
a data frame of individual survey data, where each row is an individual |
vars_demo |
a character vector of names of variables to calculate percent and N for |
group_by_var |
a string (length 1) with the name of the variable from |
spread_by_group_by_var |
logical determining whether to pass |
group_by_var_sums_to_100 |
logical determining whether percentages sum to 100 along the margin of |
add_totals |
logical determining whether to create total rows or columns (as appropriate) that demonstrate the margin that sums to 100. Default is FALSE. |
A tibble with percent and N for each level of each variable in vars_demo
Other table functions:
table_basicstats()
,
table_weightedpct()
table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat")) table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat"), group_by_var = "disability_cat") table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat"), group_by_var = "disability_cat", spread_by_group_by_var = TRUE)
table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat")) table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat"), group_by_var = "disability_cat") table_unweightedpctn(df_adults, vars_demo = c("sex", "age_cat", "work_cat", "edu_cat"), group_by_var = "disability_cat", spread_by_group_by_var = TRUE)
Calculate table of percentages or N of response distribution for survey items, survey weighted, disaggregated
table_weightedpct( df, vars_ids, vars_strata, vars_weights, formula_vars, ..., formula_vars_levels = 0:1, by_vars = NULL, pct = TRUE, willfilter = NULL, add_totals = FALSE, spread_key = NULL, spread_value = "prop", arrange_vars = NULL, include_SE = FALSE )
table_weightedpct( df, vars_ids, vars_strata, vars_weights, formula_vars, ..., formula_vars_levels = 0:1, by_vars = NULL, pct = TRUE, willfilter = NULL, add_totals = FALSE, spread_key = NULL, spread_value = "prop", arrange_vars = NULL, include_SE = FALSE )
df |
a data frame of individual survey data, where each row is an individual |
vars_ids |
a character vector of cluster ids, passed to |
vars_strata |
a character vector of strata ids, passed to |
vars_weights |
a character vector of survey weight ids, passed to |
formula_vars |
a character vector of variables to calculate the percentages of each level for |
... |
captures expressions to pass to |
formula_vars_levels |
a vector of the levels of the the |
by_vars |
a character vector of variables to disaggregate results by. Default is |
pct |
a logical variable indicating whether or not to calculate weighted percentages. Default is |
willfilter |
a logical variable that tells the function whether or not to filter or transmute the data. Leave as default |
add_totals |
logical determining whether to create total rows or columns (as appropriate) that demonstrate the margin that sums to 100. Default is FALSE. |
spread_key |
a string with variable name to pass to |
spread_value |
a string with variable name to pass to |
arrange_vars |
a character vector with variables to pass to |
include_SE |
a logical variable indicating whether to include the standard errors in the table. Default is FALSE. Currently does not work when adding totals, spreading or transmuting. |
If willfilter
is NULL, the table is not filtered or transmuted. If willfilter
is TRUE, the table is filtered before it is spread or arranged. If willfilter
is FALSE, the table is transmuted after the spread and/or arrange. "..." captures the non-standard evaluation expressions (NSE) to pass to dplyr::filter
or dplyr::transmute()
.
The function performs the following actions with the table after results are calculated in the following order (if applicable): filter, add totals, spread, arrange, transmute
a tibble of weighted response percentages or N's
See vignette("programming", package = "dplyr")
for more about non-standard evaluation (NSE)
Other table functions:
table_basicstats()
,
table_unweightedpctn()
table_weightedpct(df_adults, vars_ids = c("HHID", "PSU"), vars_strata = "strata", vars_weights = "weight", formula_vars = paste0("EF",1:10), formula_vars_levels = 1:5, by_vars = "sex")
table_weightedpct(df_adults, vars_ids = c("HHID", "PSU"), vars_strata = "strata", vars_weights = "weight", formula_vars = paste0("EF",1:10), formula_vars_levels = 1:5, by_vars = "sex")