I've got the output of some simulations that look something like this:
Run,ID,Time,Var1,Outcome
1,1,6,0.5,1
1,2,4,0.25,1
1,3,2,0.9,1
2,1,5,0.07,1
...
10,3,9,0.08,1
Basically a series of M studies of N individuals (in actuality M = 1000 and N = 123). I'd like to run a Cox model (preferably) or a parametric regression model (if I must) to estimate the effect of Var1
on survival time. What I want to do is estimate the effect for each "Run" (to produce 1,000 estimates) and then dump all those estimates into a single data frame, matrix, etc. where I can look at their distribution.
If I were using SAS, the code would look something like this:
ods output ParameterEstimates=work.parameters;
proc phreg model time*outcome(0) = Var1;
BY Run;
run;
ods output close;
But since this is a side project, and I'm trying to force myself to do side projects in R in order to learn it, I can't so much fall back on SAS. As far as I can tell from the coxph() documentation, there's no easy way to include a by-variable. My guess is this is going to involve loops and subsets.
Any suggestions?