Search code examples
rregressionsurvival-analysis

Gaussian distribution for censored regression with cenreg


I am trying to use the cenreg function in the NADA package in R to run a censored regression with a Gaussian distribution. The function works with a log-normal distribution, but returns an error when I try to use the Gaussian distribution.

Here is reproducible example with dummy data:

## Simulate data
d <- data.frame(x = rep(1:10, times = 3))
d$conc <- d$x * 2 + rnorm(30, 0, sd = 0.25)
d$group <- rep(1:3, each = 10)
d$conc <- d$conc + d$group
d$group <- as.factor(d$group)
d$conc[ d$conc < 8] <- 0
d$conc <- d$conc + .01
d$cen <- FALSE
d$cen[ d$conc < 8] <- TRUE

library(NADA)
## Fit model with log-normal distribution 
m1 <- with(d, cenreg(Cen(conc, cen) ~ x + group - 1,
                     dist = 'lognormal'))
m1
## attempt to fit model with Gaussian distribution
m2 <- with(d, cenreg(Cen(conc, cen) ~ x + group - 1,
                     dist = 'gaussian'))

which gives me this error message:

Error in eval(expr, envir, enclos) : object 'x' not found

I am using R version 3.2.3 and NADA version 1.5.6. This is the most recent version of the NADA package.

How do I use the cenreg function with a Gaussian distribution?


Solution

  • Looks like a bug, but this works:

    cenreg(Cen(d$conc, d$cen) ~ d$x + d$group - 1, dist = 'gaussian')