Description Usage Arguments Details Value Author(s) References Examples
Compute the index for new observations using output from lm.main
, lm.interaction
, logistic.main
, logistic.interaction
, cox.main
and cox.interaction
.
1 | index.prediction(res, x)
|
res |
list "res" term from the outputs in |
x |
New covariate matrix |
index.prediction
computes the new index for given observations based on the fitted AIM
index.prediction
returns score
which is the index for new observations with covariate matrix "x".
Lu Tian and Robert Tibshirani
Lu Tian and Robert Tibshirani (2010) Adaptive index models for marker-based risk stratification. Tech Report. Available at http://www-stat.stanford.edu/~tibs/AIM.
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 | ## generate data
set.seed(1)
n=400
p=10
x=matrix(rnorm(n*p), n, p)
z=(x[,1]<0.2)+(x[,5]>0.2)
trt=rbinom(n,1, 0.5)
beta=1
prb=1/(1+exp(trt-beta*trt*z-0.5))
y=rbinom(n,1,prb)
## fit the interaction logistic AIM model
a=logistic.interaction(x, trt, y, nsteps=10)
## examine the model sequence
print(a)
## compute the index based on the 2nd model of the sequence, using data x
z.prd=index.prediction(a$res[[2]],x)
## compute the index based on the 2nd model of the sequence using new data xx, and compare the result with the true index
nn=10
xx=matrix(rnorm(nn*p), nn, p)
zz=(xx[,1]<0.2)+(xx[,5]>0.2)
zz.prd=index.prediction(a$res[[2]],xx)
cbind(zz, zz.prd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.