library("care")
# diabetes data
data(efron2004)
x = efron2004$x
y = efron2004$y
xnames = colnames(x)
#####
# ordering of the variables using squared CAR score
car = carscore(x, y)
xnames[order(car^2, decreasing=TRUE)]
# CAR regression models with 5, 7, 9 included predictors
care(x, y, numpred=c(5,7,9))
#####
# plot regression coefficients for all possible CAR models
p = 10
bmat= care(x, y, 1:p)[,-1]
bmat
plot(1:p, bmat[,1], type="l",
ylab="estimated regression coefficients",
xlab="number of included predictors",
main="CAR Regression Models for Diabetes Data",
xlim=c(1,p+1), ylim=c(min(bmat), max(bmat)))
for (i in 2:p) lines(1:p, bmat[,i], col=i, lty=i)
for (i in 1:p) points(1:p, bmat[,i], col=i)
for (i in 1:p) text(p+0.5, bmat[p,i], xnames[i])
Run the code above in your browser using DataLab