Even though there are some great QAs related to this problem in SE such as this and this, I still have problem finding a good strategy for a one-sided test for a regression's coefficient.
To describe the problem properly, let's go by a simple example, consider the following table:
> table
# not.B B
# not.A 82 63
# A 456 456
If we were to perform a goodness of fit test, we would for example do:
chisq.test(table, correct = FALSE)
# Pearson's Chi-squared test
#
# data: table
# X-squared = 2.1488, df = 1, p-value = 0.1427
> m <- glm(A ~ B, family = binomial())
> summary(m)
# Call:
# glm(formula = A ~ B, family = binomial())
#
# Deviance Residuals:
# Min 1Q Median 3Q Max
# -1.3035 -1.1575 -0.0506 1.1974 1.1974
#
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -0.04704 0.06695 -0.703 0.4823
# B 0.33875 0.18071 1.874 0.0609 .
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# (Dispersion parameter for binomial family taken to be 1)
#
# Null deviance: 1439.0 on 1037 degrees of freedom
# Residual deviance: 1435.4 on 1036 degrees of freedom
# AIC: 1439.4
#
# Number of Fisher Scoring iterations: 3
#
> anova(m, test="LRT")
# Analysis of Deviance Table
#
# Model: binomial, link: logit
#
# Response: A
#
# Terms added sequentially (first to last)
#
#
# Df Deviance Resid. Df Resid. Dev Pr(>Chi)
# NULL 1037 1439.0
# B 1 3.546 1036 1435.4 0.05969 .
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> anova(m, test="Rao")
# Analysis of Deviance Table
#
# Model: binomial, link: logit
#
# Response: A
#
# Terms added sequentially (first to last)
#
#
# Df Deviance Resid. Df Resid. Dev Rao Pr(>Chi)
# NULL 1037 1439.0
# B 1 3.546 1036 1435.4 3.5352 0.06008 .
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
For regression A and B are formed as factors (dummy variables). And as you can see they all agree pretty much and the life goes on.
However, what if the alternative hypothesis is $\beta_B\geq0$? If I perform a one-sided t-test (or z test) here is what I get:
> # one-sided (right tail) z test for B
> pnorm(summary(m)$coefficients[2,3], lower.tail = F)
# [1] 0.03043157
>
> # or a ttest
> pt(summary(m)$coefficients[2,3], df=m$df.residual, lower.tail = F)
# [1] 0.03057217
But what does this even mean? and if I calculate the 95% confidence interval for $\beta_B$ I would get:
# with profiling
> confint(m)
# Waiting for profiling to be done...
# 2.5 % 97.5 %
# (Intercept) -0.17836773 0.08415021
# B -0.01378692 0.69583308
# Or using the usual formula
> summary(m)$coefficients[2,1] + 1.96*summary(m)$coefficients[2,2]
# [1] 0.6929479
> summary(m)$coefficients[2,1] - 1.96*summary(m)$coefficients[2,2]
# [1] -0.01545319
Which shows the CI includes zero. Or perhaps I should have calculated the 90% CI (based on this QA):
> confint(m, level = 0.90)
# 5 % 95 %
# (Intercept) -0.15723305 0.06305549
# B 0.04273375 0.63796301
Question:
- What does this one-sided significance mean?
- If we just wanted to check the relation between B and A, a goodness of fit test would do it. But, what if we also care about the direction of relationship?
- Am I allowed to directly perform a one-sided test (just like the weird example above), or I first need to see if the goodness of fit test is significant and then check for the direction? Or simply check the range of CI and based on the sign of coefficient, make decision about the significance and direction of the coefficient?