Re: [R] R keeps crashing when executing 'rlogspline'

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Thu, 31 May 2007 16:56:36 -0700

On Thu, 31 May 2007, Jacques Wagnor wrote:

> Dear List,
>
> I have a simple model as follows:
>
> x <- rnorm(500)
> library(logspline)
> fit <- logspline(x)
> n <- 1000000
> y <- replicate(n, sum(rlogspline(rpois(1,10), fit))) # last line
>

What you do not see in RGui is this:

Traceback:

  1. .C("rpqlsd", as.double(c(fit$coef.pol, fit$coef.kts)), as.double(fit$knots), as.double(fit$bound), as.integer(0), qq = as.double(p), as.integer(length(fit$knots)), as.integer(length(p)), PACKAGE = "logspline")
  2. qlogspline(pp, fit) [rest deleted]

I think you are getting zero from rpois(1,10) with larger values of n.

rlogspline does not check for n==0

This results in calling qlogspline( numeric(0), fit ) and generates the segfault, I guess.

So figure out what should happen when rpois(1,10) returns zero and avoid calling rlogspline in those cases.

If 'zero.value' is a suitable value, then this will work:

> library(logspline)
> x <- rnorm(500)
> fit <- logspline(x)
> res <- sapply(1:50, function(x) sum(rlogspline(x, fit)))
> n <- 1000000
> rp <- rpois(n,10)
> y <- c( zero.value, res )[ rp+1 ] ## table lookup is faster!

Chuck

> The problem I keep getting is Rcrashes when doing the last line. It
> seems to be fine if n is small, but not if n is 1000000. The message
> I keep getting is:
>
> "R for Windows GUI front-end has encountered a problem and needs to
> close. We are sorry for the inconvenience. If you were in the middle
> of something, the information you were working on might be lost."
>
> Any insights would be appreciated,
>
> Jacques
>
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 5.0
> year 2007
> month 04
> day 23
> svn rev 41293
> language R
> version.string R version 2.5.0 (2007-04-23)
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>

Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0901

______________________________________________
R-help_at_stat.math.ethz.ch 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 Fri 01 Jun 2007 - 00:02:47 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 Fri 01 Jun 2007 - 08:31:45 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.