llm {bhm} | R Documentation |
Fit an L-shape linear model
Description
Fit an L-shape linear model with the cut point estimated by the profile likelihood method.
Usage
## S3 method for class 'formula'
llm(formula, data=list(...), epsilon = 0.025, ...)
Arguments
formula |
an object of class " |
data |
an optional data frame, list or enviroment containing the variables in the model. |
epsilon |
Step width for the profile likelihood method, default is 0.025 |
... |
additional arguments to be passed to the low level regression fitting functions (see below). |
Details
Define a L shape linear funcation that change slope at c0:
when x <c0, y = b1 + b2*x
when x>=c0, y = b1 + b2*x + b3*(x-x0) = (b1-b3*c0) + (b2+b3)*x
Value
llm returns an object of class inheriting from "llm" which inherits from the class glm. See later in this section.
An object of class "llm" is a list containing at least the following components:
coefficients |
a named vector of coefficients from 'llm' |
residuals |
the residuals, that is response minus fitted values. |
fitted.values |
the fitted mean values. |
rank |
the numeric rank of the fitted linear model. |
df.residual |
the residual degrees of freedom. |
call |
the matched call. |
terms |
the 'terms' object used. |
c.max |
the maximum likelihood estimate for the threshold parameter(s). |
loglik |
the log-likelihood with the final values of the coefficients. |
Author(s)
Bingshu E. Chen (bingshu.chen@queensu.ca)
References
Liu, S. S. and Chen, B. E. (2020). Continuous threshold models with two-way interactions in survival analysis. Canadian Journal of Statistics. Vol. 48, page 751-772.
See Also
Examples
#### simulate the data and fit a L-shape model.
n = 50 ; p <- 2
X = matrix(rnorm(n * p), n, p) # no intercept!
w = X[, 1]; age = X[, 2]
wc = w - 0.2; sigma = 0.25
y = rnorm(n, -0.1+0.7*w-1.2*ifelse(wc>0, wc, 0), sigma)
fit=llm(y~w+age)
print(fit)
print(summary(fit))
#### to plot the L-shape function
# plot(fit)