Re: [R] predict 'expected' with eha package

From: Göran Broström <goran.brostrom_at_gmail.com>
Date: Sat, 21 May 2011 23:21:59 +0200

Mike,

On Sat, May 21, 2011 at 10:15 PM, Mike Harwood <harwood262_at_gmail.com> wrote:
> I am unsure what is being returned, and what is supposed to be
> returned, when using 'predict' with "type='expected'" for an aftreg
> survival model.

I'm sorry, but there is no 'predict.aftreg'. The generic 'predict' "works" because aftreg objects have a secondary class 'coxph'. This is probably a mistake (or two) that should be corrected.

Thanks,

Göran

> The code below first generates a weibull  model, then
> uses predict to create a vector of the linear predictors, then
> attempts to create the 'expected' vector, which is empty.  The final
> two steps in the code generate a lognormal model with the same data,
> and the same empty 'expected' vector.
>
> My expectation had been that 'expected' would generate the same
> transformed dependent variable output as predict with a survreg model
> using type='response'.  Since my 'real' data is left-truncated and
> right-censored I cannot use survreg, and I wanted to investigate the
> output from eha.
>
> Thanks in advance!
>
> Mike
>
>> data(mort)
>> aftreg(Surv(enter, exit, event) ~ ses, data = mort)
> Call:
> aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort)
>
> Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
> ses
>           lower    0.416     0         1           (reference)
>           upper    0.584    -0.348     0.706     0.089     0.000
>
> log(scale)                    3.603    36.698     0.065     0.000
> log(shape)                    0.331     1.392     0.058     0.000
>
> Events                    276
> Total time at risk         17038
> Max. log. likelihood      -1391.3
> LR test statistic         16.1
> Degrees of freedom        1
> Overall p-value           5.91578e-05
>> m1 <- aftreg(Surv(enter, exit, event) ~ ses, data = mort)
>> head(predict(m1, type='lp')) ## produces output
>        1         2         3         4         5         6
> -0.347853  0.000000 -0.347853  0.000000  0.000000  0.000000
>> head(predict(m1, type='expected')) ## is this correct?
> numeric(0)
>> m2 <- aftreg(Surv(enter, exit, event) ~ ses, dist='lognormal', data = mort)
>> head(predict(m2, type='expected')) ## is this correct?
> numeric(0)
>
>
> from eha (the survival and rms packages are not an option for my
> 'real' question, since I have left-truncated right-censored data
>
> ______________________________________________
> 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.
>

-- 
Göran Broström

______________________________________________
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 Sat 21 May 2011 - 21:33:59 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Sat 21 May 2011 - 22:10:09 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