I'm running a linear model, and would like to compare a set of points on the slope to the estimates at 0. My code follows the layout of the response here. The output seems to have a single, identical p-value. I would have expected values near 0 to have high p-values and values far from 0 to have small p-values. I definitely didn't expect to have identical p-values across the comparisons. Any suggestions?
Toy dataset:
library(ggplot2)
library(tidyr)
library(emmeans)
df <- structure(list(Distance = c(0, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5),
Mean = c(139, 119.8, 121, 130.4, 115.9, 134.7, 134.7, 122.2, 118.8, 116.9, 114.4,
109.6, 103.9, 113.2, 103.5, 113.3, 122.1, 105.9, 115.2)), row.names = c(NA, -19L),
class = c("tbl_df", "tbl", "data.frame"))
m <- lm(Mean ~ Distance, data = df)
df$Pred <- predict(m)
# data and predictions look ok
ggplot(df) +
geom_point(aes(x = Distance, y = Mean)) +
geom_line(aes(x = Distance, y = Pred))
# create a fake grid for emmeans
fake.df <- data.frame(Distance = 0:10)
# run a treatment vs control, where control is value at 0 and "treatment" are values
# stepping away from 0
emm <- emmeans(m, trt.vs.ctrl1 ~ Distance, data = fake.df,
cov.reduce = FALSE, covnest = TRUE)
emm