Title: | Methods for Cross-Cultural Psychology |
---|---|
Description: | With the development of new cross-cultural methods this package is intended to combine multiple functions automating and simplifying functions providing a unified analysis approach for commonly employed methods. |
Authors: | Johannes Karl [aut, cre] |
Maintainer: | Johannes Karl <[email protected]> |
License: | GPL-3 |
Version: | 0.2.6 |
Built: | 2024-11-26 06:47:32 UTC |
Source: | CRAN |
Bootstrapped pairwise differences in psychometric function of groups.
boot_inv_eff( n, n_sample, df, items, group, eff_sizes = c("SDI2", "UDI2", "WSDI", "WUDI", "dmacs"), seed = 2711 )
boot_inv_eff( n, n_sample, df, items, group, eff_sizes = c("SDI2", "UDI2", "WSDI", "WUDI", "dmacs"), seed = 2711 )
n |
Number of bootstraps |
n_sample |
Number of participants to sample |
df |
Data to resample |
items |
Items to resample for the model as vector of strings |
group |
String variable indicating grouping variable |
eff_sizes |
Effect sizes to be returned |
seed |
Seed for replicability |
Returns a dataframe with the bootstrapped effect sizes based on the invariance_eff function in this package for two country comparisons.
two_country <- dplyr::filter(example, country %in% c("NZ" , "BRA")) boot_inv_eff(n = 10, n_sample = 200, df = two_country, group = "country", items = paste0("voice",1:3, "m"))
two_country <- dplyr::filter(example, country %in% c("NZ" , "BRA")) boot_inv_eff(n = 10, n_sample = 200, df = two_country, group = "country", items = paste0("voice",1:3, "m"))
Function to quickly organize and clear psych factor loadings
clearing_fa( psych_fa, cutoff = 0.4, dbl_dist = 0.2, key_file = NULL, cleaned = TRUE )
clearing_fa( psych_fa, cutoff = 0.4, dbl_dist = 0.2, key_file = NULL, cleaned = TRUE )
psych_fa |
Output from the psych package, can be either fa or principal with at least two dimensions |
cutoff |
Desired cutoff below which loadings are omitted defaults to .40 |
dbl_dist |
Desired distance between highest and second highest loading for an item to remove double loadings, defaults to .20 |
key_file |
Optional: Either a .csv or .xlsx file with at least two columns: 1 labeled item containing the item labels as in the data frame, 2 a column labeled wording containing the item wording. |
cleaned |
If true (default), only the cleaned solution with a message for descriptive stats are returned. If false the function returns a list of data frames one cleaned and one showing all in-between steps |
clean This column contains the assignment after removing NAs and double loadings
dir This column contains the direction (positive or negative) of the highest loading.
library(psych) fa_solution <- fa(example[c(paste0("help", 1:6, "m"), c(paste0("voice", 1:5, "m")))], nfactors = 2) clearing_fa(fa_solution)
library(psych) fa_solution <- fa(example[c(paste0("help", 1:6, "m"), c(paste0("voice", 1:5, "m")))], nfactors = 2) clearing_fa(fa_solution)
Computes dMACS
dMACS(fit.cfa, group1, group2)
dMACS(fit.cfa, group1, group2)
fit.cfa |
Lavaan output object with two groups and a single factor. |
group1 |
String for first group in the grouping factor |
group2 |
String for second group in the grouping factor |
Returns dMACS for each item.
dMACS
dMACS
One-step equivalence testing The function allows for a simple one step test of configural, metric, and scalar equivalence between multiple groups.
equival(x, dat, group, standart_lv = TRUE, orthog = TRUE, estim = "MLM")
equival(x, dat, group, standart_lv = TRUE, orthog = TRUE, estim = "MLM")
x |
CFA model identical to models provided to lavaan. |
dat |
A data frame or tibble containing the raw data for the specified model. |
group |
A character string that indicates the column of dat that contains the grouping variable. e.g "country" |
standart_lv |
A boolean that indicates whether the latent variables should be standardised. |
orthog |
A boolean that indicates whether the latent variables should be orthogonal. |
estim |
A string indicating the estimator to be used MLM for complete data and MLR for incomplete data. Defaults to MLM |
Returns a data frame with the fit indices for each model and delta values comparing the different levels of equivalence. For a step by step interpretation see.
model <- "voice =~ voice1m + voice2m + voice3m help =~ help1m + help2m + help3m" equival(x = model, dat = example, group = "country")
model <- "voice =~ voice1m + voice2m + voice3m help =~ help1m + help2m + help3m" equival(x = model, dat = example, group = "country")
Help and Voice Behavior in different countries
example
example
A data frame with 5201 rows and 13 variables:
Country of sample
First Help Item
Second Help Item
Third Help Item
Fourth Help Item
Fifth Help Item
Sixth Help Item
Seventh Help Item
First Voice Item
Second Voice Item
Third Voice Item
Fourth Voice Item
Fifth Voice Item
...
https://www.frontiersin.org/articles/10.3389/fpsyg.2019.01507/full
Improving boot effectsize output
format_boot_inv_eff(x)
format_boot_inv_eff(x)
x |
The output of a bootstrapped invariance effect call |
A formatted tibble with all effect sizes reported by boot_inv_eff from this package and significant determined by 95% CIs either crossing 0 or .30
two_country <- dplyr::filter(example, country %in% c("NZ" , "BRA")) boot_inv_eff_result <- boot_inv_eff(n = 10, n_sample = 200, df = two_country, group = "country", items = paste0("voice",1:3, "m")) format_boot_inv_eff(boot_inv_eff_result)
two_country <- dplyr::filter(example, country %in% c("NZ" , "BRA")) boot_inv_eff_result <- boot_inv_eff(n = 10, n_sample = 200, df = two_country, group = "country", items = paste0("voice",1:3, "m")) format_boot_inv_eff(boot_inv_eff_result)
Gamma Hat from MLM fitted lavaan object
gamma_hat_scaled(object)
gamma_hat_scaled(object)
object |
A lavaan output object that was fitted with a MLM estimator |
Invariance Effect Sizes
invariance_eff( df, items, group, nodewidth = 0.01, intercept_fix = 1, lowerLV = -10, upperLV = 10, ... )
invariance_eff( df, items, group, nodewidth = 0.01, intercept_fix = 1, lowerLV = -10, upperLV = 10, ... )
df |
Multi-group dataframe |
items |
vector of items for the target construct |
group |
string defining grouping variable |
nodewidth |
Steps tested |
intercept_fix |
Which item should have a fixed intercept defaults to the first item |
lowerLV |
Lower range of latent variable tested |
upperLV |
Upper range of latent variable tested |
... |
Passes on to lavaan CFA functions |
Returns a dataframe with a row for each item comprising the uni-factorial solution and one column for each invariance effect size. A detailed interpretation of each effect size is provided in Gunn et al. (2019).
Get more comprehensible output from lavTestScore
lavTestScore.clean(lavaan.fit, ndigit = 3, ...)
lavTestScore.clean(lavaan.fit, ndigit = 3, ...)
lavaan.fit |
Model fitted with lavaan |
ndigit |
Defines the rounding |
... |
Arguments passed to lavTestScore |
Returns a dataframe which contains one row for each constrained parameter in the model together with a chi-square test indicating whether the parameter significantly differs between groups.
This is a cleaned version identical to lavTestScore
.
Maksim Rudnev
Multi-group reliability table
mg_rel_table(df_s, measure_list, group, digitn = 3, seed = 2711)
mg_rel_table(df_s, measure_list, group, digitn = 3, seed = 2711)
df_s |
The full dataframe with all groups and items. |
measure_list |
A named list of vectors containing the item names. The format should be list(measure_name1 = c('Item1', 'Item2', 'Item3'), measure_name2 = c('Item1', 'Item2', 'Item3')) |
group |
Grouping variable in the dataset as string for example "country" |
digitn |
Controls the amount of digits shown in the output |
seed |
Seed for the bootstrapped confidence intervals |
Returns a formatted dataframe with the reliability of all constructs by group
Non-Centrality Index
MNCI(object)
MNCI(object)
object |
A lavaan object that was fitted with a MLM estimator/ |
Pairwise Effect sizes of similarities and difference in the psychometric structure between multiple groups
multi_group_eff( df, group, items, eff_sizes = c("SDI2", "UDI2", "WSDI", "WUDI", "dmacs") )
multi_group_eff( df, group, items, eff_sizes = c("SDI2", "UDI2", "WSDI", "WUDI", "dmacs") )
df |
Multi-Group data frame |
group |
String variable indicating the grouping variable |
items |
Vector of strings indicating items for the uni-factorial construct |
eff_sizes |
Effect sizes to be returned |
The function returns a list of dataframes with the first reporting the averaged results per item and the second reporting the pairwise comparisons.
example_s <- dplyr::filter(example, country %in% c("NZ", "BRA")) multi_group_eff(df = example, group = "country", items = paste0("voice",1:3, "m"))
example_s <- dplyr::filter(example, country %in% c("NZ", "BRA")) multi_group_eff(df = example, group = "country", items = paste0("voice",1:3, "m"))
Creating a Pan-Cultural Loading Matrix
pancultural(df, group, nfactors)
pancultural(df, group, nfactors)
df |
A data frame contains the variables for the exploratory factor analysis and the grouping variable. |
group |
The name of the column tht cointains the grouping supplied as a string. |
nfactors |
The number of factors expected. |
returns a Pan-Cultural loading matrix.
pancultural(example, "country", 5)
pancultural(example, "country", 5)
Procrustes rotation function, returning Tucker's Phi
prost(loading, norm, rotated = FALSE, digits = 2)
prost(loading, norm, rotated = FALSE, digits = 2)
loading |
A correlation matrix to be rotated towards a target |
norm |
A correlation matrix that is the goal of the rotation |
rotated |
A TRUE/FALSE operator indicating if the rotated matrix should be returned in addition to Tucker's Phi |
digits |
The number of digits to be displayed in the output, defaults to 2 |
Returns Tuckers Phi evaluating the congruence of the loading matrix to the normative matrix
Examening chisquare improvement if paths are unconstrained. The function returns the paths to be unconstrained based on chisquare change. Adjusted P-values are calculated based on iterative Bonferroni corrections.
release_bonferroni(lavaan.fit, ndigit = 3, exp_p = 0.05, ...)
release_bonferroni(lavaan.fit, ndigit = 3, exp_p = 0.05, ...)
lavaan.fit |
Model fitted with lavaan |
ndigit |
Number of digits to round chi and p to |
exp_p |
Expected p-value |
... |
Arguments passed to lavTestScore |
Returns a dataframe representing a Bonferroni corrected version of lavTestScore.clean
.
Maksim Rudnev
Split by groups
splitgroup(df, group, named = FALSE, name.list = NA)
splitgroup(df, group, named = FALSE, name.list = NA)
df |
Dataframe |
group |
Variable from the dataset that defines the groups |
named |
TRUE/FALSE argument wheter the resulting list should be named |
name.list |
Supply a list of names same length as number of groups |
Returns a list of dataframes with only the selected groups