[R] multiple imputation based on a condition

2010-05-22 Thread Gary Collins
Any suggestions on the following would be grateful. I'm trying to impute data, where a fictitional dataset is defined as... set.seed(110) n <- 500 test <- data.frame(smoke_status = rbinom(n, 2, 0.6), smoke_amount = rbinom(n, 2, 0.5), rf1 = rnorm(n), rf2 = rnorm(n), outcome = rbinom(n, 1, 0.3))

Re: [R] discrepancies between stata and r for a cox regression

2009-05-18 Thread Gary Collins
try res <- coxph(Surv(TIME, STATUS)~TREAT, data=leukemia, method="breslow") R default for handling ties is Efron's method, whereas it's Breslow for STATA. Have a look under method in ?coxph it clearly states this, and STATA output clearly states the Breslow method for ties in the output of

[R] replacing missing values in a dataframe with reference values.

2008-08-21 Thread Gary Collins
Any thoughts on the following I'd be most grateful - I'm sure there is an easy and quick way to do this but I'm having a mental block this evening. Essentially, I'm trying to replace missing data in my dataset with reference values based on age and sex. So an example dataset is set.seed(1) X =