# How to calculate p-value for a parameter given confidence interval when null hypothesis != 0

Given the dataset:

d = structure(list(x = c(22.9362216327734, 24.4504147133069, 23.2710364752618,
22.5253827558421, 24.8139647577093, 22.8804536162757, 24.3948588709677,
25.4304112554113, 25.7243410214168, 26.6003943661972, 26.0698382492864
), y = c(3.536, 3.867, 4.482, 2.033, 2.912, 3.958, 5.445, 6.973,
5.115, 8.382, 4.438)), .Names = c("x", "y"), class = "data.frame", row.names = c(16L,
17L, 19L, 20L, 23L, 24L, 25L, 26L, 28L, 29L, 30L))


I can make a nonlinear fit:

a = nls(y ~ a * exp(b * x), data = d, start = list(a = 1, b = 0.05))

Formula: y ~ a * exp(b * x)

Parameters:
Estimate Std. Error t value Pr(>|t|)
a  0.02980    0.05046   0.590   0.5694
b  0.20483    0.06723   3.047   0.0139 *


I am interested in the value of the b parameter:

library(MASS)
confint(a, parm = 'b')

2.5%      97.5%
0.05583547 0.37719675


I see that the model converged on b as 0.205 with a 95% CI of (0.056, 0.377).

My question is:

How do I calculate the p-value for the following null hypothesis?

H0: b = 0.069

I've seen online the conversion between CI and p-value when the null is zero but I'm unsure of:

1. how many degrees of freedom exist for this parameter? Is it just nrow(d) - 1 still?
2. how to calculate p-value with a non-zero null
• Commented Jun 23, 2017 at 18:47

The Wald statistic for testing the null hypothesis is:

$$W = \frac{\hat{\theta} - \theta_0}{se(\hat{\theta})}$$

your $\hat{\theta}$ is the point estimate $b$: 0.20483 and $se(\hat{\theta})$ is the SE : 0.06723 used to describe the approximate normal sampling distribution of the test statistic when the null hypothesis is true. In this case, the null says: the $\theta_0 = 0.069$. So putting all the pieces together a p-value is obtained with:

pt(abs({0.20483-0.069}/0.06723), lower.tail=F, df=9)*2

which gives the same result as Matthew Drury's answer of:

> pt(abs({0.20483-0.069}/0.06723), lower.tail=F, df=9)*2
[1] 0.0740768


Note the degrees of freedom is nrow(d)-2 because you estimate two parameters.

M = a = nls(y ~ a * exp((b + 0.069) * x), data = d, start = list(a = 1, b = 0))


So b == 0 in this model if and only if b == 0.069 in the original model.

The summary for the new model is:

Formula: y ~ a * exp((b + 0.069) * x)

Parameters:
Estimate Std. Error t value Pr(>|t|)
a  0.02980    0.05046    0.59   0.5694
b  0.13583    0.06723    2.02   0.0741 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.314 on 9 degrees of freedom

Number of iterations to convergence: 20
Achieved convergence tolerance: 3.168e-06


Which gives you the p-values you want.

• Very clever! This makes a lot of sense. Commented Jun 22, 2017 at 21:17