r,survival-analysis,cox-regression

Please read the help page for predict.coxph. None of those are supposed to be probabilities. The linear predictor for a specific set of covariates is the log-hazard-ratio relative to a hypothetical (and very possibly non-existent) case with the mean of all the predictor values. The 'expected' comes the closest to...

If I understood the 'tongue' data correctly, you may use the 'time' variable ("Time to death") to calculate the number of patients who dies in a given time interval (here time steps of 50) like this: tt <- table(cut(x = tongue$time, breaks = seq(from = 0, to = 400, by...

You can use data.table package. If df is your original data.frame: library(magrittr) library(data.table) dt = data.table(df) dt[,temp:=ifelse(is.na(lag(event,1)), as.integer(0), lag(event,1)), by=ID] dt[, sequence:=cumsum(temp)+1, by=ID] func = function(x) { which(c(1,lag(x,1)[-1]) %in% 1) %>% c(length(x)+1) %>% diff } dt[, cond.time:=func(event) %>% lapply(seq) %>% unlist, by=ID] > dt year ID event time temp sequence...

For some reason, PHREG will only plot cumulative hazards. This approach will get you a plot of the baseline hazard function. First use the BASELINE statement in PHREG to get survivor function estimates, like so: proc phreg data = yourdata; model (start, end)*death(0) = ...; baseline out = bl survival...

I don't do a lot of survival analysis (and you don't state which distribution you would like to use for this part - there are different options), but this code should get you started for the interval censoring part: library("runjags") # Your data t1 <- c(1.73, NA, NA, NA, NA,0.77,...

Try this. I added a proper Surv() call because you only had times and no status argument and I made it into a formula (with the predictor on the other side of the tilde) because Surv function expects status as its second argument and survdiff expects a formula as its...

r,data.frame,survival-analysis

It is basically the same as you have there, just an extra column res <- summary( survfit( Surv(futime, fustat)~rx, data=ovarian)) cols <- lapply(c(2:6, 8:11) , function(x) res[x]) tbl <- do.call(data.frame, cols) head(tbl) # time n.risk n.event n.censor surv strata std.err upper lower # 1 59 13 1 0 0.9230769 rx=1...

The code for survplot.rms (which has the same parameters as you are using and does exhibit the behavior you're describing) is base-R-grphics and it uses the pretty function to build the x-axis: pretty(c(0,28)) #[1] 0 5 10 15 20 25 30 So if you want to change its behavior you...

The outsurv data set contains the hazard function estimates and the confidence interval. Proc lifetest data=Melanoma outsurv=hazards; EDIT: The above generates an estimate for the hazard function, not the smoothed estimate and only works for method=LT. To obtain the smooth estimate, using method=KM (default), then use the following line: ods...

r,tree,survival-analysis,rpart

The survival data are scaled internally exponentially so that the predicted rate in the root node is always fixed to 1.000. The predictions reported by the predict() method are then always relative to the survival in the root node, i.e., higher or lower by a certain factor. See Section 8.4...

If you look at the code you wil see this was intended behavior: if (sum(cc.ix) < 3) { if (msurv) { data <- list(x = x, surv.time = surv.time, surv.event = surv.event) } else { data <- list(x = x, cl = cl) } return(list(c.index = NA, se = NA,...

r,logistic-regression,survival-analysis,coefficients

Another approach can be with the use of the summary function. You can see that with summary the coefficients of the model are taken as a matrix. > is.matrix(summary(B)$coefficients) [1] TRUE At this point you can store summary(B)$coefficients in an object and then subset it as you wish. summary(B)$coefficients[1,1] ...

stata,mean,margins,survival-analysis

margins gender, predict(mean time) I did not check that, as I don't have Stata on this computer. However, the logic behind margins is that if you do not specify the predict() option, margins will assume the default prediction for your model. In case of streg you can look up in...

I'd say you have a fairly good understanding of the data already and should present what you found. This sounds like a descriptive study rather than one where you will be presenting to the FDA with a request to honor your p-values. Since your audience will (or should) be expecting...

r,datetime,data,survival-analysis,poisson

I hope this does what you need. I've used lubridate and dplyr because they make things easier but the same results could be achieved in base. There's no need to retain year_done or first_jan_done, these can be removed with %>% select(-year_done, -first_jan_done) but I thought I would leave them in...

(If you're only asking for a tool to perform an operation or for statistical advice, then StackOverflow might not be the right place for this question.) Nonetheless, I'd suggest some improvements with the format of your data and your code that should be helpful in achieving your goals in R....

python,bayesian,pymc,survival-analysis

For posterity. Thanks to Chris Fonnesbeck for pointing out that the problem was that I did not give W as an argument to idt. This function should be @deterministic def idt(b1=beta, dl0=dL0, W=W): print beta.value fitted = np.exp(np.dot(X, b1) + W[stfips]) yy = (Y[:,:T] * np.outer(fitted, dl0)) return np.transpose(yy) And...