This function is a wrapper for linrclus. It requires less input.

CCRls.coord(Y, X, k, nC = 1, ...)

Arguments

Y

vector of outcome variable

X

matrix of covariates. Should not include 1's for the intercept

k

number of clusters

nC

first nC-1 covariates in X not to cluster. Must be at least 1 for the intercept

...

additional parameters to be passed to lm

Value

mobj the low dimension lm regression object

clus cluster assignments of covariates (excluding the first nC covariates - including the intercept 1)

Examples

set.seed(14) #Generate data N = 1000; (bets = rep(-2:2,4)); p = length(bets); X = matrix(rnorm(N*p),N,p)
#> [1] -2 -1 0 1 2 -2 -1 0 1 2 -2 -1 0 1 2 -2 -1 0 1 2
Y = cbind(1,X)%*%matrix(c(0.5,bets),ncol = 1) CCRls.coord(Y,X,k=5,nC=1)
#> Inner iter = 1, RSS = 660.88739, and reldev = 0.30341 #> Inner iter = 2, RSS = 660.88739, and reldev = 0.00000
#> $mobj #> #> Call: #> stats::lm(formula = Y ~ as.matrix(cbind(Xnc, X1)[, -1])) #> #> Coefficients: #> (Intercept) as.matrix(cbind(Xnc, X1)[, -1]) #> 5.00e-01 -2.00e+00 #> as.matrix(cbind(Xnc, X1)[, -1]) as.matrix(cbind(Xnc, X1)[, -1]) #> -1.00e+00 4.01e-16 #> as.matrix(cbind(Xnc, X1)[, -1]) as.matrix(cbind(Xnc, X1)[, -1]) #> 1.00e+00 2.00e+00 #> #> #> $clus #> [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 #>