Dear R users, I have been trying to understand what the Weights arguments is doing in the estimation of the parameters when using the Surreg function. I looked through the function''s code but I am not sure if I got it or not. For example, if I inclue the Surv function in it: survreg(Surv(vector, status)~1,weights=vector2,dist="Weibull") will it try to maximize the likelihood with a weight on each density function f (when non-censored) and 1-distribution, 1-F (censored case)? Can anyone tell me if I''m in the right way? Thank you very much, Boris [[alternative HTML version deleted]]

The survreg function uses case weights. That is, if a subject is given a weight of 2, the result is the same as if there were a second observation (exactly the same). Early in my career data sets that contained only categorical variables were often collapsed in just this way, in order to save on computer memory and allow the analysis of larger problems. (Continuous variables such as age might be turned into categorical to facilitate the collapse). Long, long ago in computer time... Terry Therneau

Thank you for your reply, it has been helpful. Do you know if the parameters estimators are MLE estimators? One more question: In my case study I have failures that occured on different objects that have different age and length, could I use weight to find the estimates of a weibull law and so to find the probabilty of failure per unit of length for example? Thank you very much again for your help, Boris -- View this message in context: http://r.789695.n4.nabble.com/Weights-using-Survreg-tp3781803p3785931.html Sent from the R help mailing list archive at Nabble.com.

Survreg produces MLE estimates. For your second question, don''t know what you are asking. Can you be more specific and detailed? ---begin included message -- Do you know if the parameters estimators are MLE estimators? One more question: In my case study I have failures that occured on different objects that have different age and length, could I use weight to find the estimates of a weibull law and so to find the probabilty of failure per unit of length for example?

Sorry when we talk about about MLE estimates does that mean WLE?I am trying to understand if the survreg function is allowing a weight for each density function when calculating the likelihood. In my second question I was trying to explain that my problem is that I have pipes of different length and I want to know their probability to break per metre. My idea was to weight each of my observations to get estimate probabilities per metre.Does that sound realistic? Thank you very much, Boris -- View this message in context: http://r.789695.n4.nabble.com/Weights-using-Survreg-tp3781803p3793462.html Sent from the R help mailing list archive at Nabble.com.

I think you are replying to Dr Therneau without including this context:>> --- begin---- >> Survreg produces MLE estimates. >> >> For your second question, don''t know what you are asking. Can you be >> more specific and detailed? >> >> ---begin included message -- >> Do you know if the parameters estimators are MLE estimators? >> >> One more question: >> In my case study I have failures that occured on different objects >> that >> have different age and length, could I use weight to find the >> estimates of a >> weibull law and so to find the probabilty of failure per unit of >> length >> for example?-----end--------- On Sep 6, 2011, at 9:50 AM, Boris Beranger wrote:> Sorry when we talk about about MLE estimates does that mean WLE?I am > trying > to understand if the survreg function is allowing a weight for each > density > function when calculating the likelihood. > > In my second question I was trying to explain that my problem is > that I have > pipes of different length and I want to know their probability to > break per > metre. My idea was to weight each of my observations to get estimate > probabilities per metre.Does that sound realistic?I have generally used Poisson regression [ glm(..., family="poisson") ] in that situation. It lets you do two things: a) apply weighting by using offset=log(length_of_pipe) and b) model multiple breaks in a pipe if such an occurrence is possible. (It also produces an MLE estimate if that feature is of some special importance.) I respectfully defer to anything Dr Therneau says on this matter and am only really posting in hopes that he will clarify whether there is any value in thinking about the use of offset terms in either parametric or Cox survival models. There is an offset argument in glm but I do not see one (any longer?) in survreg or coxph. I have what must be an extremely vague memory of seeing an offset term in coxph formulas, but I do not see such a possibility described in the current help pages. Therenau and Grambsch indicates that CPH models with certain forms of frailty are similar to models with offsets but the help apge for `Surv` specifically warns against the use of "gamma/ml or gaussian/reml [frailty terms] with survreg". -- David Winsemius, MD West Hartford, CT

Hi everyone, I have three numerica vectors: x, y, z. I want to plot a heatmap or surface plot of z against x and y. Is there any package for this? If possible, please drop me several lines of example code. Thanks! jinrui,

You mean like the examples in help("heatmap") ? On Tue, Sep 6, 2011 at 1:20 PM, Jinrui Xu <jinruixu at umich.edu> wrote:> Hi everyone, > > I have three numerica vectors: x, y, z. I want to plot a heatmap or surface > plot of z against x and y. Is there any package for this? If possible, > please drop me several lines of example code. Thanks! > > jinrui, >-- Sarah Goslee http://www.functionaldiversity.org

Hi Sarah, To me, the heatmap function calculates "density value" for each grid of the heatmap automatically from the input matrix. In my case, I already got the "density value" as a vector, say Z. I want to plot a heat map with x and y as is axsis and z values as the "density" of grid. I am not familiar with R code, so I am writting to ask how to. Thanks! jinrui, Quoting Sarah Goslee <sarah.goslee at gmail.com>:> You mean like the examples in help("heatmap") ? > > On Tue, Sep 6, 2011 at 1:20 PM, Jinrui Xu <jinruixu at umich.edu> wrote: >> Hi everyone, >> >> I have three numerica vectors: x, y, z. I want to plot a heatmap or surface >> plot of z against x and y. Is there any package for this? If possible, >> please drop me several lines of example code. Thanks! >> >> jinrui, >> > > -- > Sarah Goslee > http://www.functionaldiversity.org > > >-- Ph.D Student, Bioinformatics Program Center for Computational Medicine and Bioinformatics (CCMB) The University of Michigan 100 Washtenaw Avenue Ann Arbor, MI 48109-2218 1075 Natural Science Building 830 North University Avenue Ann Arbor, MI 48109-1048 Tel (lab): 734-763-0514 http://www-personal.umich.edu/~jinruixu/

I agree with David that poisson regression would be the simplest thing. It''s a consequence of the poison formulation and an exponential "trick" E(#breaks) = breaks per meter * length in meters = exp(Xb) * exp(log(length)) = exp(Xb + log(length)) X = covariates that affect "breaks per meter", b=coefficients log(length) appears as an offset, i.e., a covariate that has a known coefficient of 1. You could also use log(length) as an offset in a Cox model, for the same logic. relative risk that a given pipe breaks = length * risk per meter = exp(Xb + log(length)) You need to decide if such a model is scientifically defensible, e.g., if this involved flexing I would expect breakage to go up faster than linear. Notes: offset has always been a part of coxph and survreg, time to improve the documentation I guess I forgot to include the context in my first reply. Terry T. On Tue, 2011-09-06 at 12:19 -0400, David Winsemius wrote:> I think you are replying to Dr Therneau without including this context: > >> --- begin---- > >> Survreg produces MLE estimates. > >> > >> For your second question, don''t know what you are asking. Can you be > >> more specific and detailed? > >> > >> ---begin included message -- > >> Do you know if the parameters estimators are MLE estimators? > >> > >> One more question: > >> In my case study I have failures that occured on different objects > >> that > >> have different age and length, could I use weight to find the > >> estimates of a > >> weibull law and so to find the probabilty of failure per unit of > >> length > >> for example? > -----end--------- > > On Sep 6, 2011, at 9:50 AM, Boris Beranger wrote: > > > Sorry when we talk about about MLE estimates does that mean WLE?I am > > trying > > to understand if the survreg function is allowing a weight for each > > density > > function when calculating the likelihood. > > > > In my second question I was trying to explain that my problem is > > that I have > > pipes of different length and I want to know their probability to > > break per > > metre. My idea was to weight each of my observations to get estimate > > probabilities per metre.Does that sound realistic? > > I have generally used Poisson regression [ glm(..., > family="poisson") ] in that situation. It lets you do two things: a) > apply weighting by using offset=log(length_of_pipe) and b) model > multiple breaks in a pipe if such an occurrence is possible. (It also > produces an MLE estimate if that feature is of some special importance.) > > I respectfully defer to anything Dr Therneau says on this matter and > am only really posting in hopes that he will clarify whether there is > any value in thinking about the use of offset terms in either > parametric or Cox survival models. > > There is an offset argument in glm but I do not see one (any longer?) > in survreg or coxph. I have what must be an extremely vague memory of > seeing an offset term in coxph formulas, but I do not see such a > possibility described in the current help pages. Therenau and Grambsch > indicates that CPH models with certain forms of frailty are similar to > models with offsets but the help apge for `Surv` specifically warns > against the use of "gamma/ml or gaussian/reml [frailty terms] with > survreg". >

I wrote this function (borrowing heavily from an example from Longhow Lam) heatplot = function(x,y,z,bgcol="#777044",coltype=''heat'', ccex = 1.5, circles=TRUE, ...){ #browser() layout(matrix(c(1, 2, 3), nc=3), widths=c(7, 1, .5)) ## create the scatterplot withdifferent colors #ccols = heat.colors(length(z)) ColFormula1 = paste(coltype, ''.colors(length(z))'', sep='''') ccols = eval(parse(text=ColFormula1)) bgfun=function(){ tmp = par("usr") rect(tmp[1], tmp[3], tmp[2], tmp[4], col=bgcol) ylimits=par()$usr[c(3,4)] abline(h=pretty(ylimits,10), lty=2, col=''black'') } scale = function(x){(x-min(x))/diff(range(x))} xname = deparse(substitute(x)) yname = deparse(substitute(y)) zname = deparse(substitute(z)) plot(x, y, pch=16, col=ccols[rank(z)], panel.first=bgfun(), xlab=xname,ylab=yname, cex=ccex ,...) if(circles){ points(x, y, cex=ccex) } zlim = range(z, finite=TRUE) lvs = pretty(zlim, 20) plot.new() mtext(paste(''legend for "'', zname, ''" values'', sep=''''), side=2) plot.window(xlim=c(0, 1), ylim=range(lvs), xaxs="i", yaxs="i") points(1,1,cex=5) #rect(0, lvs[-length(lvs)],1, lvs[-1], # col=heat.colors(length(lvs)-1)) ColFormula2 = paste(coltype, ''.colors(length(lvs)-1)'', sep='''') rect(.1, lvs[-length(lvs)],1, lvs[-1], col=eval(parse(text=ColFormula2))) axis(4) layout(c(1)) } ## Examples: x = 1:100 y = sin(x/50) + rnorm(100)/20 z = sort(rnorm(100)) heatplot(x,y,z) heatplot(x,y,z, ccex=5) heatplot(x,y,z, ccex=5, circles=F) heatplot(x,y,z, ccex=5, circles=F, coltype=''cm'') heatplot(x,y,z, ccex=5, circles=F, coltype=''topo'', bgcol=''lavender'', main=''Something Special'') On Tue, Sep 6, 2011 at 2:14 PM, Jinrui Xu <jinruixu@umich.edu> wrote:> Hi Sarah, > > To me, the heatmap function calculates "density value" for each grid of > the heatmap automatically from the input matrix. In my case, I already got > the "density value" as a vector, say Z. I want to plot a heat map with x and > y as is axsis and z values as the "density" of grid. I am not familiar with > R code, so I am writting to ask how to. Thanks! > > jinrui, > > > Quoting Sarah Goslee <sarah.goslee@gmail.com>: > > You mean like the examples in help("heatmap") ? >> >> On Tue, Sep 6, 2011 at 1:20 PM, Jinrui Xu <jinruixu@umich.edu> wrote: >> >>> Hi everyone, >>> >>> I have three numerica vectors: x, y, z. I want to plot a heatmap or >>> surface >>> plot of z against x and y. Is there any package for this? If possible, >>> please drop me several lines of example code. Thanks! >>> >>> jinrui, >>> >>> >> -- >> Sarah Goslee >> http://www.**functionaldiversity.org <http://www.functionaldiversity.org> >> >> >> >> > > > -- > Ph.D Student, Bioinformatics Program > Center for Computational Medicine and Bioinformatics (CCMB) > The University of Michigan > 100 Washtenaw Avenue > Ann Arbor, MI 48109-2218 > > 1075 Natural Science Building > 830 North University Avenue > Ann Arbor, MI 48109-1048 > Tel (lab): 734-763-0514 > > http://www-personal.umich.edu/**~jinruixu/<http://www-personal.umich.edu/%7Ejinruixu/> > > > ______________________________**________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]