[R] Problem with locfit( ... , family="hazard")
David Winsemius
dwinsemius at comcast.net
Fri Sep 4 04:34:05 CEST 2009
I'm having difficulties with plot.locfit.3d, at least I think that is
the problem. I have a large dataframe (about 4 MM cases) and was
hoping to see a non-parametric estimate of the hazard plotted against
two variables:
> fit <- locfit(~surv.yr+ ur_protein + ur_creatinine, data=TRdta,
cens = 1-death, family = "hazard", xlim=c(0,10))
# it took somewhere between 1 and 2 hours to complete, but it did
complete and reported no errors or warnings.
> plot(fit, pv=c("ur_protein", "ur_creatinine"))
Error in if (from == to) rep.int(from, length.out) else
as.vector(c(from, :
missing value where TRUE/FALSE needed
> plot(fit, type="persp")
Error in if (from == to) rep.int(from, length.out) else
as.vector(c(from, :
missing value where TRUE/FALSE needed
> plot(fit, pv=c("ur_protein", "ur_creatinine"), type="persp",
xlim=c(0,400), ylim=c(0,400))
Error in if (from == to) rep.int(from, length.out) else
as.vector(c(from, :
missing value where TRUE/FALSE needed
I am guessing this may be a missing parameter needed by persp() but I
cannot figure out what to offer.
My efforts to construct a minimal example are also hitting a dead end:
# From first of Harrell's cph() examples
> n <- 1000
> set.seed(731)
> age <- 50 + 12*rnorm(n)
> label(age) <- "Age"
> sex <- factor(sample(c('Male','Female'), n,
+ rep=TRUE, prob=c(.6, .4)))
> cens <- 15*runif(n)
> h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
> dt <- -log(runif(n))/h
> label(dt) <- 'Follow-up Time'
> e <- ifelse(dt <= cens,1,0)
> dt <- pmin(dt, cens)
> cfit <- locfit( ~ dt + age + sex, cens=cens, family = "hazard",
xlim=c(0, max(dt)) )
Error in lfproc(x, y, weights = weights, cens = e, base = base, geth =
geth, :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In lfproc(x, y, weights = weights, cens = cens, base = base, geth =
geth, :
NAs introduced by coercion
Running the example on the locfit help page works fine, .... just
like Loader's book, which I have been trying to follow in chapter 7.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list