[R] Cox model -missing data.
shouro at gmail.com
Fri Dec 19 11:18:40 CET 2014
First recode the * in NA: death.dat$v3[death.dat$v1==*] <- NA
Include this in your model: na.rm=TRUE
Or you could create a new dataset: newdata <- na.omit(death.dat)
On Fri, Dec 19, 2014 at 11:12 AM, aoife doherty <aoife.m.doherty at gmail.com>
> Hi all,
> I have a data set like this:
> Test.cox file:
> V1 V2 V3 Survival Event
> ann 13 WTHomo 4 1
> ben 20 * 5 1
> tom 40 Variant 6 1
> where "*" indicates that I don't know what the value is for V3 for Ben.
> I've set up a Cox model to run like this:
> death.dat <- read.table("Test.cox",header=T)
> deathdat.kmat <-2*with(death.dat,makekinship(famid,ID,faid,moid))
> Model <- coxme(Surv(Survival,Event)~ strata(factor(V1)) +
> strata(factor(V2)) + factor(V3)) +
> As you can see from the Test.cox file, I have a missing value "*". How and
> where do I tell the R script "treat * as a missing variable". If I can't
> incorporate missing values into the model, I assume the alternative is to
> remove all of the rows with missing data, which will greatly reduce my data
> set, as most rows have at least one missing variable.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help