[R] predict error for survreg with natural splines

Moshe Olshansky m_olshansky at yahoo.com
Wed Dec 5 01:31:48 CET 2007


Hi Gad,

The problem is with ns:

> x <- ns(rnorm(100), knots=c(50, 60))
Error in qr.default(t(const)) : 
  NA/NaN/Inf in foreign function call (arg 1)

but the following is OK:

> x <- ns(rnorm(100))
> dim(x)
[1] 100   1

Regards,

Moshe.

--- Gad Abraham <g.abraham at ms.unimelb.edu.au> 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
> 
> 
> 
>  > sessionInfo()
> R version 2.6.1 (2007-11-26)
> i486-pc-linux-gnu
> 
> locale:
>
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;
>
LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;
>
LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;
> LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] splines   stats     graphics  grDevices utils   
>  datasets  methods
> [8] base
> 
> other attached packages:
> [1] survival_2.34
> 
> loaded via a namespace (and not attached):
> [1] rcompgen_0.1-17
> 
> 
> 
> -- 
> 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
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list