CIs in phi() function show jitter when ci approaches 1. #627
Closed
ngallagher1218
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am working on a paper involving a series of chi-square tests, and have been using the phi() function to calculate and report phi and a 95% CI for phi. However, when adjusting the ci value from 0.95 to 0.983 (this is related to a correction for multiple comparisons), the resulting confidence interval shrank rather than increasing. To explore this, I looked at the upper and lower bounds returned by the phi() function for various levels of ci, and found an odd jittering effect - for some values of ci close to 1, the upper bound goes closer to the point estimate rather than further from it. The issue appears both with and without the adjustment applied.
It's possible that this is somehow related to the non-centrality parameter method for establishing CIs, with which I am not extremely familiar, but it seemed odd enough that I am submitting it as a possible glitch.
Reprex is below, as well as visualization of the upper and lower bounds given different CI values for this particular dataset.
Thanks in advance for any guidance about this issue!
Best,
Nat
library(tidyverse)
GB_tbl <- data.frame(Variable = c("A", "B"),
Boy = c(42, 126),
Girl = c(71, 127))
GB_tbl %>%
column_to_rownames(var = "Variable") ->
GB_tbl
X <- data.frame(civalue = seq(0.001,0.999,0.001), phi = NA, LowerBound = NA, UpperBound = NA)
X %>%
mutate(Adjustment = FALSE) %>%
bind_rows(X) %>%
mutate(Adjustment = ifelse(is.na(Adjustment), TRUE, Adjustment)) ->
X
for(i in 1:nrow(X)){
effectsize::phi(GB_tbl, ci = X$civalue[i], adjust = X$Adjustment[i], alternative="two.sided") -> Y
if(X$Adjustment[i] == TRUE) {
X$phi[i] <- Y$phi_adjusted
}
if(X$Adjustment[i] == FALSE) {
X$phi[i] <- Y$phi
}
X$LowerBound[i] <- Y$CI_low
X$UpperBound[i] <- Y$CI_high
}
X %>%
mutate(Adjustment = ifelse(Adjustment == TRUE, "Adjustment Applied",
ifelse(Adjustment == FALSE, "Adjustment Not Applied", NA))) %>%
gather(WhichValue, Value, -civalue, -Adjustment) %>%
filter(civalue >= 0.5) %>%
ggplot(aes(x = civalue, y = Value, group = WhichValue, color = WhichValue)) +
geom_line() +
facet_grid(Adjustment~.) +
theme_bw()
Beta Was this translation helpful? Give feedback.
All reactions