Description Usage Arguments Value Examples
View source: R/utils.R View source: R/utils.R
OLS summary of the clusterwise regression (cwr) models
1 2 |
object |
a cwr object returned by function HP |
... |
further arugments to be passed to |
a list of "summary.lm" objects, with each object a summary of the linear model of a subgroup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | n <- 50
p <- 3
X <- matrix(rnorm(n * p), nrow = n)
Xj <- X[,1] # the threshold variable
beta1 <- rep(3,p)
beta2 <- rep(-3,p)
index.g1 <- which(Xj <= 0)
index.g2 <- which(Xj > 0)
y.g1 <- X[index.g1,] %*% beta1
y.g2 <- X[index.g2,] %*% beta2
y <- rep(0,n)
y[index.g1] <- y.g1
y[index.g2] <- y.g2
y <- y + rnorm(n = n, sd = 0.5)
res <- HP(X, y, method = "mst", Xj = X[,1], max.no.cluster = 2)
s <- summary(res)
## summary of the first subgroup model ##
s1 <- s$lm1.summary
coef(s1) # regression coefficient estimates of the first group
s1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.