Performs an interrupted regression analysis with heteroskedastic robust standard errors. This function fits two regression lines with a breakpoint at a specified value of the first predictor variable.
reg2(f, xc, graph = 1, family = "gaussian", data = NULL)A list containing:
b1, b2: Slopes of the two regression lines
p1, p2: P-values for the slopes
z1, z2: Z-statistics for the slopes
u.sig: Indicator (0/1) for whether u-shape is significant
xc: The breakpoint value
glm1, glm2: The fitted GLM models
rob1, rob2: Robust coefficient test results
msg: Messages about standard error computation
yhat.smooth: Fitted smooth values (if graph=1)
A formula object specifying the model (e.g., y ~ x1 + x2 + x3). The first predictor is the one on which the u-shape is tested.
Numeric value specifying where to set the breakpoint.
Integer. If 1 (default), produces a plot. If 0, no plot is generated.
Character string specifying the family for the GLM model. Default is "gaussian" for OLS regression. Use "binomial" for probit models.
A data frame containing the variables in the formula.
This function fits two interrupted regression lines with heteroskedastic robust
standard errors using the sandwich package. The first predictor variable is split
at the breakpoint xc, creating separate slopes before and after the breakpoint.