Re: [R] basehaz and newdata

From: mah <harwood262_at_gmail.com>
Date: Mon, 07 Apr 2008 12:15:14 -0700 (PDT)

Yes, Thank you. I did not separate the arguments for basehaz from those for survfit in the documentation. I had been hoping the tedious alignment of the baseline curve with the value of the variables in the new data set would be [somehow] handled for me.

On Apr 7, 12:27 pm, "Austin, Matt" <maus..._at_amgen.com> wrote:
> I don't believebasehaztakes a newdata argument.
>
> > args(basehaz)
>
> function (fit, centered = TRUE)
> NULL
>
> It simply extracts info from the fitted object.  I think you want to use survfit method for coxph objects and then derive/extract what you need.
>
> --Matt
>
> Matt Austin
> Global Statistical Leader, denosumab PMO
> Biostatistics Director
> Amgen, Inc
>
>
>
> -----Original Message-----
> From: r-help-boun..._at_r-project.org [mailto:r-help-boun..._at_r-project.org] On Behalf Of mah
> Sent: Monday, April 07, 2008 10:01 AM
> To: r-h..._at_r-project.org
> Subject: Re: [R]basehazand newdata
>
> Thanks Roland, but using data frames does not resolve the issue.  See revised code and output below:
>
> >  test1 <- data.frame(
> +                 time=  c(4, 3,1,1,2,2,3),
> +                 status=c(1,NA,1,0,1,1,0),
> +                 x=     c(0, 2,1,1,1,0,0),
> +                 sex=   c(0, 0,0,0,1,1,1)
> +                 )
> >  f1 <- coxph( Surv(time, status) ~ x + strata(sex), data=test1)
> > #stratified model
>
> >  test2 <- data.frame(
> +                 time=  c(4, 3,1,1,2,2,3),
> +                 status=c(1,NA,1,0,1,1,0),
> +                 x=     c(1, 2,1,1,1,0,0),
> +                 sex=   c(0, 0,0,0,1,1,1)
> +                 )
> >  f2 <- coxph( Surv(time, status) ~ x + strata(sex), data=test2)
> > #stratified model
>
> >  f1
> Call:
> coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)
>
>   coef exp(coef) se(coef)     z    p
> x 1.17      3.22     1.29 0.907 0.36
>
> Likelihood ratio test=0.87  on 1 df, p=0.351  n=6 (1 observation deleted due to missingness)
> >  f2
> Call:
> coxph(formula = Surv(time, status) ~ x + strata(sex), data = test2)
>
>    coef exp(coef) se(coef)    z    p
> x 0.896      2.45     1.42 0.63 0.53
>
> Likelihood ratio test=0.38  on 1 df, p=0.535  n=6 (1 observation deleted due to missingness)
> >  basehaz(f1, newdata=test2)
> Error inbasehaz(f1, newdata = test2) :
>   unused argument(s) (newdata = list(time = c(4, 3, 1, 1, 2, 2, 3), status = c(1, NA, 1, 0, 1, 1, 0), x = c(1, 2, 1, 1, 1, 0, 0), sex = c(0, 0, 0, 0, 1, 1, 1)))
>
> Mike
>
> On Apr 7, 11:43 am, Roland Rau <roland.rproj..._at_gmail.com> wrote:
> > Hi,
>
> > just looked at it briefly and I don't know if it is the real cause for
> > your problems. But 'data' as well as 'newdata' require a data.frame
> > and not a list as input.
>
> > Does this help?
>
> > Best,
> > Roland
>
> > mah wrote:
> > > I am unable to get thebasehazfunction to apply a proportional
> > > hazards model to a new data frame.  I replicated my specific
> > > situation with the example for coxph in the help, where I changed
> > > the x value of the first record from 0 to 1.  Is there something
> > > incorrect in the syntax that I am using?  Thanks in advance!
>
> > > test1 <- list(time=  c(4, 3,1,1,2,2,3),
> > >               status=c(1,NA,1,0,1,1,0),
> > >               x=     c(0, 2,1,1,1,0,0),
> > >               sex=   c(0, 0,0,0,1,1,1))
> > > test2 <- list(time=  c(4, 3,1,1,2,2,3),
> > >               status=c(1,NA,1,0,1,1,0),
> > >               x=     c(1, 2,1,1,1,0,0),
> > >               sex=   c(0, 0,0,0,1,1,1))
> > > f1 <- coxph( Surv(time, status) ~ x + strata(sex), data=test1)
> > > #stratified model
> > > f2 <- coxph( Surv(time, status) ~ x + strata(sex), data=test2)
> > > #stratified model
> > >  f1
> > > Call:
> > > coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)
>
> > >   coef exp(coef) se(coef)     z    p
> > > x 1.17      3.22     1.29 0.907 0.36
>
> > > Likelihood ratio test=0.87  on 1 df, p=0.351  n=6 (1 observation
> > > deleted due to missingness)
> > >> f2
> > > Call:
> > > coxph(formula = Surv(time, status) ~ x + strata(sex), data = test2)
>
> > >    coef exp(coef) se(coef)    z    p
> > > x 0.896      2.45     1.42 0.63 0.53
>
> > > Likelihood ratio test=0.38  on 1 df, p=0.535  n=6 (1 observation
> > > deleted due to missingness)
> > >>basehaz(f1, newdata=test2)
> > > Error inbasehaz(f1, newdata = test2) :
> > >   unused argument(s) (newdata = list(time = c(4, 3, 1, 1, 2, 2, 3),
> > > status = c(1, NA, 1, 0, 1, 1, 0), x = c(1, 2, 1, 1, 1, 0, 0), sex =
> > > c(0, 0, 0, 0, 1, 1, 1)))
>
> > > ______________________________________________
> > > R-h..._at_r-project.org mailing list
> > >https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting
> > >guidehttp://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
>
> > ______________________________________________
> > R-h..._at_r-project.org mailing
> > listhttps://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting
> > guidehttp://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.-
> > Hide quoted text -
>
> > - Show quoted text -
>
> ______________________________________________
> R-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.- Hide quoted text -
>
> - Show quoted text -



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Apr 2008 - 20:03:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Apr 2008 - 20:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive