[R] is this a bug? problem saving and restoring coxph objects

Thomas Lumley thomas at biostat.washington.edu
Sat Mar 25 19:39:41 CET 2000


On Sat, 25 Mar 2000, Ramon Diaz-Uriarte wrote:

> I am using R 1.0.0 on Linux, and I am running into a problem with coxph objects
> (library survival5).
> 
> If I fit a model that includes a frailty term with sparse=F (e.g
> my.model<-coxph(Surv(t,censor)~trt+frailty(id,sparse=F))),
> 
> when I try to save all the objects (e.g., save.image()) I get the error:
> 
> > save.image()
> Error in save(list = ls(all.names = TRUE), file = ".RData", oldstyle = FALSE) : 
> 	NewWriteItem: unknown type 17
> 
> 


> This seems like a bug. Where should I report it? Is there a workaround?


The following change to frailty() seems to work. 
 frailty <- function(x,distribution = 'gamma', ...) {
    dlist <- c("gamma", "gaussian", "t")
    i <- pmatch(distribution, dlist)
    if (!is.na(i)) distribution <- dlist[i]
    temp <- paste("frailty", distribution, sep='.')
    if (!exists(temp))
            stop(paste("Function '", temp, "' not found", sep=""))
    ##(get(temp))(x, ...)
    m<-match.call()
    m$distribution<-NULL
    m[[1]]<-as.name(temp)
    eval(m,sys.frame(sys.parent()))
    }
        		  
Also, it seems that the bug does not occur if you specify the frailty
distribution explicitly like this 

rfit2a <- survreg(Surv(time, status) ~ rx + frailty.gamma(litter, df=13,
sparse=F), rats )

ie, say frailty.gamma() or frailty.gaussian() rather than using frailty().

I say "seems" because I don't really understand why this fix works.


	-thomas


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list