jacob-long/interactions

Create confidence interval around johnson-neyman point

lunahj opened this issue · 1 comments

Hi Jacob
Thanks for this great package, such a wonderful contribution to me (and others) learning to use R .
Is there a way to identify a confidence interval around the point calculated in the jnplot? Since there is a 95% confidence band around the slope, it should be doable I think, but I am not sure how to get the x-values for that region. Any suggestions?

I don't have a way for you to query a specific point, but there is a way to get pretty fine-grained data.

If you follow the example,

states <- as.data.frame(state.x77)
states$HSGrad <- states$`HS Grad`
fit <- lm(Income ~ HSGrad + Murder*Illiteracy, data = states)
johnson_neyman(model = fit, pred = Murder, modx = Illiteracy)

You could instead extract the cbands object from johnson_neyman()

johnson_neyman(model = fit, pred = Murder, modx = Illiteracy)$cbands

Which is the data frame used to produce the plot, with 1000 points. One such point is bound to be close to the value you're looking for.