knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) options(rmarkdown.html_vignette.check_title = FALSE)
Tidycomm provides a workflow to quickly add mean/sum indices of several variables to the dataset and compute reliability estimates for those added indices:
add_index()
adds a mean or sum index of the specified variablesget_reliability()
computes reliability estimates for all added indiceslibrary(tidycomm)
Once again, we will again sample data from the Worlds of Journalism 2012-16 study for demonstration purposes.
WoJ
ethics_1
to ethics_4
measure agreement with statements concerning ethics in journalism and may be combined into an index of 'ethical flexbility', while the items starting with trust_
measure trust in various political institutions and thus may be combined into an index of trust in politics.
add_index()
adds a mean index of specified variables to the data. The second (or first, if used in a pipe) argument is the name of index variable to be created:
WoJ %>% add_index(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4) %>% # Select variables of relevance for output dplyr::select(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4)
To create a sum index instead, set type = "sum"
:
WoJ %>% add_index(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4, type = "sum") %>% # Select variables of relevance for output dplyr::select(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4)
Use get_reliability()
to compute reliability/internal consistency estimates for indices created with add_index()
. Passing no further arguments to the function will automatically compute reliability estimates for all indices created with add_index()
found in the data and output Cronbach's $\alpha$ along with descriptives and index information.
# Add two indices to data WoJ <- WoJ %>% add_index(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4) %>% add_index(trust_in_politics, trust_parliament, trust_government, trust_parties, trust_politicians) WoJ %>% get_reliability()
If you only want reliability estimates for specific indices, pass their names as function arguments.
WoJ %>% get_reliability(trust_in_politics)
Essentially, get_reliability()
provides a wrapper for the ci.reliability function from the MBESS package. Thus, all arguments of MBESS::ci.reliability()
can be passed to get_reliability()
. For example, to output $\omega$ instead of Cronbach's $\alpha$ including robust maximum likelihood confidence intervals, you can type:
WoJ %>% get_reliability(type = 'omega', interval.type = 'mlr')
See the function documentation for more info (and don't forget to cite the MBESS
package if using get_reliability()
).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.