I am currently using the "segmented.lm" function to detect a change point in my data. At this stage I am trying to figure out how to derive the SE of the y value of the corresponding change point at x. My research has led me to the delta method, but I am not sure if I am using it correctly.
Example
set up model
require(segmented)
lm_mod <- lm(y ~ x, data = dat, weights = wghts)
seg_mod <- segmented(lm_mod, seg.Z= ~ x, npsi = 1)
Derive y value at change point and get SE
require(car)
require(Matrix)
# predefine coefficients
cp_est <- summary(seg_mod)$psi[2]
SE_cp <- summary(seg_mod)$psi[3]
# diagonal matrix of variance covariance matrix
coefs <- c(coef(seg_mod), psi1.x = cp_est)
vc_all <- bdiag(vcov(seg_mod), matrix((SE_cp*SE_cp), 1, 1))
# delta method
deltaMethod(coefs, "(Intercept) + x * psi1.x", vcov. = vc_all)
I would greatly appreciate some thoughts here!