| compare_coins_corr {COINr} | R Documentation |
Compare two coins by correlation
Description
Given two coins, this function returns the correlation between the two coins,
for target datset dset and target indicator code(s) iCodes. Correlation
is calculated as the Pearson correlation coefficient, but if compare_by = "Ranks"
then this is the correlation coefficient of the ranks, which amounts to the
Spearman rank correlation. Set compare_by = "Scores" to return the Pearson
correlation between scores.
Usage
compare_coins_corr(coin1, coin2, dset, iCodes, compare_by = "ranks")
Arguments
coin1 |
A coin |
coin2 |
A coin, with possibly alternative methodology. This should share at
least two units in common with |
dset |
Target data set, must be present in both |
iCodes |
Character vector of indicator codes to correlate between the two coins. |
compare_by |
Either |
Value
A list containing a correlation table and a list of comparison data frames.
Examples
# build example
coin <- build_example_coin()
# copy coin
coin2 <- coin
# change to prank function (percentile ranks)
# we don't need to specify any additional parameters (f_n_para) here
coin2$Log$Normalise$global_specs <- list(f_n = "n_prank")
# regenerate
coin2 <- Regen(coin2)
# iCodes to compare: all at level 3 and 4
iCodes <- coin$Meta$Ind$iCode[which(coin$Meta$Ind$Level > 2)]
# compare index, sort by absolute rank difference
l_comp <- compare_coins_corr(coin, coin2, dset = "Aggregated", iCodes = iCodes)
# see df
l_comp$df_corr