[19230] in s-news-athena
[S] censor() error message
daemon@ATHENA.MIT.EDU (Max_Kuhn@ms.bd.com)
Wed Sep 15 12:40:27 1999
From: Max_Kuhn@ms.bd.com
To: s-news@wubios.wustl.edu
Message-Id: <852567ED.005A8AEC.00@7crmta_md.ms.bd.com>
Date: Wed, 15 Sep 1999 12:27:41 -0400
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
From: Max Kuhn@BDX on 09/15/99 12:27 PM
Hello,
I'm writing a function that will create probability plots for several
distributions for a number of groups and put the plots for each group on a
different page of a graphsheet. (NT v4, 128 ram, S+ v4.5R2)
I have a fairly standard function that I tend to use (instead of one of the
apply functions) whose implementation is taken from lm(). It loops through
groups and acts upon the subset of data coming from a group (I realize that many
of you would write it differently). In this case, the "action" is to run
censorReg and use the function probplot6.censorReg to create the probability
plots. There is no censoring in the data and there are usually 2 to 5 groups.
A watered down version of the function is:
temp<-function(formula, data, subset, na.action = na.omit)
{
call <- match.call()
m <- match.call(expand = T)
m$log.y <- NULL
m[[1]] <- as.name("model.frame")
m <- eval(m, sys.parent())
Terms <- attr(m, "terms")
y <- model.extract(m, response)
.x <- model.matrix(Terms, m)
x <- .x[, 2]
groups <- unique(x)
groups <- groups[groups != 0]
graphsheet(pages = "every graph")
par(pty = "s")
for(i in groups) {
temp <- y[x == i]
fit <- censorReg(censor(temp) ~ 1)
label <- paste("Group =", i)
probplot6.censorReg(fit)
}
}
The error message I find is:
> temp(rnorm(200)+20~rep(1,200))
Error in censor(temp): Time variable is not numeric
Dumped
I have looked through censor and have been unable to find the reason that this
particular error message is occurring. Note that
probplot6.censorReg(censorReg(censor(rnorm(200)+20)~1))
works fine. If you replace the insides of the for loop with something simple,
such as
temp <- y[x == i]
hist(temp)
things are fine. In fact, the error appears to occur during probplot6.censorReg,
not censorReg.
Any ideas why the function censor() would have trouble with the output from
censorReg when placed inside this loop? Thanks in advance,
Max
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news