Skip to content

[R-sig-dyn-mod] deSolve warning and error messages

6 messages · Ogurtsova, Ekaterina, Thomas Petzoldt

#
Dear Thomas,

Unfortunately,  my R code is quite sophisticated. However, If you insist, I can write down something short and easy (see below). 
But the problem, in the first place, is not that I have warnings. 

For example:

DLSODA-  At current T (=R1), MXSTEP (=I1) steps   
      taken on this call before reaching TOUT     
In above message, I = 
[1] 10
In above message, R = 
[1] 88.8862

And I have an algorithm how handling this situation later in the code.  But I'm annoyed by the messages and just want to suppress them.

---
Here an artificial example just to reproduce a message:

library(deSolve)

lng<-100
times<-seq(1,100, length=lng)
y<-diag(2)

simpleFun<-function(t,y, parms=NULL){
  	p <- array(y,dim=c(2,2))

  	age<-1:101
 	 tab<-cbind(
    		  -seq(0.1,5,length=101)
    		, seq(0.8,0.1, length=101)
    		, seq(0.1,5,length=101)
   		 , -seq(0.8,0.1, length=101)
 	 )
	  i<- max(which(age<=t))

 	 q<-array(tab[i,],dim=c(2,2))
 	 vec<-c(p%*%q)
 	 return(list(vec,NULL))
}

res<-suppressWarnings(
		lsoda(y=diag(2), times=times
     			 , func=simpleFun
    			  , parms=NULL
     			 , maxsteps=10 )
	)

And the output
Thanks a lot!

-----Original Message-----
From: r-sig-dynamic-models-bounces at r-project.org [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of Thomas Petzoldt
Sent: Wednesday, February 20, 2013 9:50 AM
To: r-sig-dynamic-models at r-project.org
Subject: Re: [R-sig-dyn-mod] deSolve warning and error messages

Dear Ekaterina,

thanks for your report, can you please give us a minimal reproducible example?

Thomas Petzoldt

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

----------
This mail has been sent through the MPI for Demographic Research.  Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.
#
Dear Ekaterina,

you are probably right, not all outputs can be suppressed with 
suppressWarnings and I will look at it as soon as possible.


For the moment, the following workaround may help.

Thomas


##--------------------------------------------------------------
library(deSolve)

lng   <- 100
times <- seq(1, 100, length=lng)

simpleFun<-function(t,y, parms=NULL){
   p   <- array(y, dim=c(2, 2))
   age <- 1:101
   tab<-cbind(
      -seq(0.1, 5, length=101),  seq(0.8, 0.1, length=101),
       seq(0.1, 5, length=101), -seq(0.8, 0.1, length=101)
   )
   i <- max(which(age <= t))
   q <- array(tab[i,], dim=c(2,2))
   vec<-c(p %*% q)
   list(vec)
}

runSilent <- function() {
   options(warn = -1)
   on.exit(options(warn = 0))
   capture.output(res <- lsoda(y=diag(2), times=times,
     func=simpleFun, parms=NULL, maxsteps=10))
   res
}

res <- runSilent()

res
#
Thomas! Thanks! 
It works nicely =)

-----Original Message-----
From: r-sig-dynamic-models-bounces at r-project.org [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of Thomas Petzoldt
Sent: Wednesday, February 20, 2013 11:57 AM
To: r-sig-dynamic-models at r-project.org
Subject: Re: [R-sig-dyn-mod] deSolve warning and error messages

Dear Ekaterina,

you are probably right, not all outputs can be suppressed with suppressWarnings and I will look at it as soon as possible.


For the moment, the following workaround may help.

Thomas


##--------------------------------------------------------------
library(deSolve)

lng   <- 100
times <- seq(1, 100, length=lng)

simpleFun<-function(t,y, parms=NULL){
   p   <- array(y, dim=c(2, 2))
   age <- 1:101
   tab<-cbind(
      -seq(0.1, 5, length=101),  seq(0.8, 0.1, length=101),
       seq(0.1, 5, length=101), -seq(0.8, 0.1, length=101)
   )
   i <- max(which(age <= t))
   q <- array(tab[i,], dim=c(2,2))
   vec<-c(p %*% q)
   list(vec)
}

runSilent <- function() {
   options(warn = -1)
   on.exit(options(warn = 0))
   capture.output(res <- lsoda(y=diag(2), times=times,
     func=simpleFun, parms=NULL, maxsteps=10))
   res
}

res <- runSilent()

res

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

----------
This mail has been sent through the MPI for Demographic Research.  Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.
#
Hi,

one additional remark: I assume that the setting of "maxsteps = 10" was 
intentional to force the warnings in the exymple. It is the maximum of 
the internal iteration counter (e.g. adams or bdf). The default value is 
5000 and sometimes, it may help to increase (but not to decrease) it.

Thomas