#### 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)
Run the code above in your browser using DataLab