[R] predict error for survreg with natural splines
Gad Abraham
g.abraham at ms.unimelb.edu.au
Thu Dec 6 01:07:48 CET 2007
Charles C. Berry wrote:
> On Wed, 5 Dec 2007, Gad Abraham wrote:
>
>> Hi,
>>
>> The following error looks like a bug to me but perhaps someone can shed
>> light on it:
>>
>> > library(splines)
>> > library(survival)
>> > s <- survreg(Surv(futime, fustat) ~ ns(age, knots=c(50, 60)),
>> data=ovarian)
>> > n <- data.frame(age=rep(mean(ovarian$age), 10))
>> > predict(s, newdata=n)
>> Error in qr.default(t(const)) :
>> NA/NaN/Inf in foreign function call (arg 1)
>>
>> Thanks,
>> Gad
>
> Gad,
>
> I think I have it now.
>
> survreg does not automatically place the boundary knots in its $terms
> component.
>
> You can force this by hand:
Thanks Chuck and Moshe, manually setting the boundary fixes the problem.
Cheers,
Gad
--
Gad Abraham
Department of Mathematics and Statistics
The University of Melbourne
Parkville 3010, Victoria, Australia
email: g.abraham at ms.unimelb.edu.au
web: http://www.ms.unimelb.edu.au/~gabraham
More information about the R-help
mailing list