I'm using the corrosion dataset from the faraway package in R.
I have built a simple linear model using:
# Load the data
data(corrosion)
help(corrosion) # Display in the "Help" window some informations
head(corrosion)
# Simple linear regression
model <- lm(loss ~ Fe, data = corrosion)
summary(model)
One of the question is: "You want to test the null hypothesis that the same expected weight loss is equal to 95mg/dm2/day at 1.5% of iron content"
To answer this question I use the linearHypothesis function from the car package.
# H0: C*beta = rhs
linearHypothesis(model, c(1, 1.5), rhs = 95)
And it give me the p-value for this test.
So, now my question is: if null hypothesis H0 is like: "weight loss of at least 95mg/dm2/day", how can I test it?
In other words, the first question the equation of H0 was: Hypothesis: (Intercept) + 1.5 Fe = 95 And now I want to test this H0: Hypothesis: (Intercept) + 1.5 Fe >= 95
Thanks in advance for your help!
The answer based on
t_value <- summary(model)$coefficients["Fe", "t value"]is incorrect. Thatt_valuewould be used in a test ofH0: Fe = 0, not in a test ofH0: Hypothesis: (Intercept) + 1.5 Fe >= 95.The difficulty here is that the
linearHypothesis()function doesn't do one-sided tests.One way to do the one-sided test is to use the relation between p-values of one-sided and two-sided tests that works in linear models when the parameter estimates have normally distributed errors. The relation is as follows:
If the test of
H0: param = xversusH1: param != xhas p-valuep, then the test ofH0: param >= xversusH1: param < xwill have p-value of eitherp/2or1-p/2. It will bep/2when the estimate of the parameter is less than x, and1-p/2when it is greater.In your case, the parameter is
(intercept) + 1.5*Fewhose estimate can be found fromsummary(model)to be129.787 - 1.5*24.02 = 93.757, which is less than 95, so you should usep/2 = 0.3097/2 = 0.15485.Edited to add: The answer above is really an answer to the statistical question, rather than the programming question. Here's how to do the programming:
Created on 2023-03-05 with reprex v2.0.2