Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

How to loop over several models for survival analysis in R?

$
0
0

I have about 10 different models with different combination of features that I would like to test using survival analysis. I have tried the following but it doesn't work

model1 = A1+A2+A3
model2 = A1+A2+A3+A4+A5
model3 = A1+A3+A4+A6

models = c(model1,model2,model3)
model_list <- array(c(models))

for (i in model_list){
  print(i)
  mod <- survreg(Surv(data$Days),data$Status)~ i, dist="weibull", data=data)
  print(AIC(mod))
}

I realised that it is giving a numeric value and not the list of parameters itself. How do I correct this?


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>