This function computes the Potential for Conflict Index (PCI) for each item in a summarized data frame produced by the 'counting' function. The PCI is a measure of consensus versus conflict in responses, based on the distribution of responses across the two poles of a scale (e.g., -1 and 1).
Calculate the Potential for Conflict Index (PCI). This function computes the PCI by comparing the counts of positive and negative values within a dataset. The PCI value is normalized by the total responses.
Arguments
- df2
A data frame generated by the
counting
function, containing the summarized data.- negative_val
The value representing negative responses. Default is '-1'.
- positive_val
The value representing positive responses. Default is '1'.
- scale_type
The scale type used: 'bipolar' or 'unipolar'. Default is 'bipolar'.
Value
A data frame including the original columns plus the computed 'PCI' value for each row/item. Numeric columns are rounded to two decimal places.
A data frame with the calculated PCI values for each group.
Details
The PCI is calculated using the formula: PCI = 1 - (na / xt - nu / xt) * xt / z where 'na' and 'nu' are the counts of agreement and disagreement respectively, 'xt' is the total of positive and negative responses, and 'z' is the total number of responses.
The resulting PCI ranges from 0 (no conflict) to 1 (maximum conflict).
Examples
df1 <- data.frame(
A = c(-1, 1, 1, 0, -1),
B = c(-1, 1, 0, -1, 1),
C = c(1, 1, -1, 0, -1),
D = c(0, 1, 1, -1, -1),
E = c(1, 1, 0, -1, -1)
)
df2 <- counting(df1, cols = c('A', 'B', 'C', 'D', 'E'))
result <- pci(df2)
print(result)
#> # A tibble: 5 × 15
#> name Mean SD Total `Count -1` `Percentage -1` `Count 0` `Percentage 0`
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 A 0 1 5 2 40 1 20
#> 2 B 0 1 5 2 40 1 20
#> 3 C 0 1 5 2 40 1 20
#> 4 D 0 1 5 2 40 1 20
#> 5 E 0 1 5 2 40 1 20
#> # ℹ 7 more variables: `Count 1` <dbl>, `Percentage 1` <dbl>, nu <dbl>,
#> # na <dbl>, xt <dbl>, z <dbl>, PCI <dbl>
df2 <- counting(df1)
#> Error in dplyr::select(., all_of(cols)): ℹ In argument: `all_of(cols)`.
#> Caused by error:
#> ! argument "cols" is missing, with no default
pci(df2)
#> # A tibble: 5 × 15
#> name Mean SD Total `Count -1` `Percentage -1` `Count 0` `Percentage 0`
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 A 0 1 5 2 40 1 20
#> 2 B 0 1 5 2 40 1 20
#> 3 C 0 1 5 2 40 1 20
#> 4 D 0 1 5 2 40 1 20
#> 5 E 0 1 5 2 40 1 20
#> # ℹ 7 more variables: `Count 1` <dbl>, `Percentage 1` <dbl>, nu <dbl>,
#> # na <dbl>, xt <dbl>, z <dbl>, PCI <dbl>