[Stpp-commits] r41 - in pkg: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 26 15:25:25 CEST 2012


Author: gabriele
Date: 2012-03-26 15:25:24 +0200 (Mon, 26 Mar 2012)
New Revision: 41

Removed:
   pkg/src/stpp.dll
Modified:
   pkg/R/STIKhat.r
   pkg/R/animation.r
   pkg/R/rinfec.r
   pkg/R/rinter.r
   pkg/R/rlgcp.r
   pkg/R/rpcp.r
   pkg/R/rpp.r
Log:


Modified: pkg/R/STIKhat.r
===================================================================
--- pkg/R/STIKhat.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/STIKhat.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -1,34 +1,7 @@
 STIKhat <- function(xyt, s.region, t.region, dist, times, lambda, correction = TRUE, infectious = TRUE) 
 {
+require(splancs)
 
-#  library(splancs)
-  #
-  # This function computes the space-time inhomogeneous K function.
-  #
-  # Arguments:
-  #  - xyt: coordinates and times of the point process,
-  #  - s.region: set of points defining the domain D,
-  #  - t.region: vector giving the lower and upper boundaries of T
-  #  - dist: vector of distances h at which K() is computed,
-  #  - times: vector of times t at which K() is computed,
-  #  - lambda: vector of values of the space-time intensity
-  #            function evaluated at the points of the pattern,
-  #  - correction: logical value. If True, the Ripley's edge correction
-  #                is used.
-  #  - infectious: logical value. If True, the STIK function is the one defined
-  #            in the case of infectious diseases.
-  #
-  # Value:
-  #  - Khat: a ndist x ntimes matrix containing the values of K(h,t),
-  #  - dist: the vector of distances used,
-  #  - times: the vector of times used.
-  #
-  #
-  # E. Gabriel, september 2005
-  #
-  # last modification: 25.10.2006
-  #
-
   if (missing(s.region)) s.region <- sbox(xyt[,1:2],xfrac=0.01,yfrac=0.01)
   if (missing(t.region)) t.region <- range(xyt[,3],na.rm=T)
     
@@ -65,9 +38,6 @@
 
   if (area>10) lambda <- lambda*area
   
-#  dyn.load("/home/gabriel/functions/STIKfunction/libF/stikfunction.dll")
-#  pathname <- paste(path,"stikfunction.dll",sep="")
-#  dyn.load(pathname)
   nev <- rep(0,ntimes)
   klist <- .Fortran("stikfunction", as.double(ptsx),
                     as.double(ptsy), as.double(ptst), 
@@ -101,7 +71,7 @@
   Khpp <- matrix(0,ncol=length(times),nrow=length(dist))
   for(i in 1:length(dist)){Khpp[i,]<-pi*(dist[i]^2)*times}
   
-  if (infectious==T) Ktheo <- Khpp
+  if (infectious==TRUE) Ktheo <- Khpp
   else Ktheo <- 2*Khpp
  
   lhat <- hkhat-Ktheo

Modified: pkg/R/animation.r
===================================================================
--- pkg/R/animation.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/animation.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -1,31 +1,5 @@
 animation <- function(xyt, s.region, t.region, runtime=1, incident="red", prevalent="pink3", pch=19, cex=0.5, plot.s.region=TRUE, scales=TRUE, border.frac=0.05, add=FALSE)
 { 
-  #
-  # Description:
-  #   Animation of spatio-temporal point process data.
-  #   Requires splancs library
-  #
-  # Arguments:
-  #            xyt: data - matrix containing the (x,y,t)-coordinates
-  #        runtime: approximate running time of animation, in seconds
-  # 			  (but longer than expected...).	
-  #       s.region: two-column matrix specifying polygonal
-  #                 region containing all data-locations xyt[,1:2]
-  #       t.region: interval containing all data-times xyt[,3]
-  #       incident: colour in which incident point xyt[i,1:2] is
-  #                 plotted at time xyt[i,3]
-  #      prevalent: colour to which prevalent point xyt[i,1:2] fades
-  #                 at time xyt[i+1,3]
-  #            pch: plotting symbol usedfor each point 
-  #            cex: magnification of plotting symbol relative to standard size
-  #  plot.s.region: if true, plot s.region as polygon
-  #         scales: if true, plot X and Y axes with scales
-  #    border.frac: extent of border of plotting region surounding s.region,
-  #                 as fraction of ranges of X and Y
-  #
-  #
-
-
   if (missing(s.region)) s.region <- sbox(xyt[,1:2],xfrac=0.01,yfrac=0.01)
   if (missing(t.region)) t.region <- range(xyt[,3],na.rm=T)
   

Modified: pkg/R/rinfec.r
===================================================================
--- pkg/R/rinfec.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/rinfec.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -3,71 +3,6 @@
 recent=1, lambda=NULL, lmax=NULL, nx=100, ny=100, nt=1000, 
 t0, inhibition=FALSE, ...)
 {
-  #
-  # Simulate an infectious point process in a region D x T.
-  #
-  # Requires Splancs.
-  #  
-  # Arguments:
-  #  
-  #  npoints: number of points to simulate.
-  #
-  #  s.region: two columns matrix specifying polygonal region containing
-  #        all data locations. If poly is missing, the unit square is
-  #        considered.
-  #
-  #  t.region: vector containing the minimum and maximum values of
-  #            the time interval.
-  #  
-  #  nsim: number of simulations to generate. Default is 1.
-  #
-  #  alpha: numerical value for the latent period.
-  #
-  #  beta: numerical value for the maximum infection rate.
-  #
-  #  gamma: numerical value for the infection period.
-  #
-  #  delta: spatial distance of inhibition.
-  #
-  #  maxrad: single value or 2-vector of spatial and temporal maximum
-  #          radiation respectively. If single value, the same value is used
-  #          for space and time.
-  #
-  #  s.distr: spatial distribution. Must be choosen among "uniform", "gaussian",
-  #           "expoenntial" and "poisson".
-  #
-  #  t.distr: temporal distribution. Must be choosen among "uniform" and "exponential".  
-  #
-  #  h: infection rate function which depends on alpha, beta and delta.
-  #     Must be choosen among "step" and "gaussian".
-  #
-  #  g: Must be choosen among "min", "max" and "prod".
-  #
-  #  recent:  If "all" consider all previous events. If is an integer, say N, 
-  #           consider only the N most recent events. 
-  #
-  #  lambda: function or matrix define the intensity of a Poisson process if 
-  #         s.distr is Poisson.
-  #
-  #  lmax: upper bound for the value of lambda.
-  #
-  #  nx,ny: define the 2-D grid on which the intensity is evaluated if s.distr 
-  #        is Poisson.
-  #
-  #  nt: used to discretize time to compute the infection rate function.
-  #
-  #  t0: minimum time used to compute the infection rate function.
-  #      Default in the minimum of t.region.
-  #
-  #  inhibition: Logical. If TRUE, an inhibition process is generated.
-  #              Otherwise, it is a contagious process.
-  #
-  #
-  # Value:
-  #  xyt: list containing the points (x,y,t) of the simulated point
-  #           process.
-  #
-
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)
   if (missing(t.region)) t.region <- c(0,1)
   if (missing(t0)) t0 <- t.region[1]

Modified: pkg/R/rinter.r
===================================================================
--- pkg/R/rinter.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/rinter.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -1,38 +1,5 @@
 spatial.inhibition <- function(npoints,h,theta,delta,p,recent="all",s.region,inhibition=TRUE,...)
   {
-  #
-  # Simulate an inhibition or a contagious spatial point process in a region D
-  #
-  # Requires Splancs.
-  #  
-  # Arguments:
-  #  
-  #  s.region: two columns matrix specifying polygonal region containing
-  #        all data locations. If poly is missing, the unit square is
-  #        considered.
-  #
-  #         h: a function of the distance between points.
-  #            If inhibition=TRUE, h is monotone, increasing, and must tend
-  #            to 1 when the distance tends to infinity. 0<= h(d,theta,delta) <= 1.
-  #            Else, h is monotone, decreasing, and must tend
-  #            to 1 when the distance tends to 0. 0<= h(d,theta,delta) <= 1.
-  #  
-  #         p: a function among "min", "max", "prod".  
-  #  
-  #   npoints: number of points to simulate. 
-  #
-  #
-  # Value:
-  #  pattern: list containing the points (x,y) of the simulated point
-  #           process.
-  #
-  ##
-  ## E. GABRIEL, 26/03/2007
-  ##
-  ## last modification: 21/10/2008
-  ##
-  ##
-
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)
 
   if (!(is.function(h)))
@@ -169,40 +136,7 @@
 
 
 temporal.inhibition <- function(npoints,h,theta,delta,p,recent="all",t.region,discrete.time=FALSE,replace=FALSE,inhibition=TRUE)
-  {
-  #
-  # Simulate an inhibition or a contagious temporal point process in T
-  #
-  # Requires Splancs.
-  #  
-  # Arguments:
-  #  
-  #  t.region: vector containing the minimum and maximum values of
-  #            the time interval.
-  #
-  #         h: a function of the distance between times and theta.
-  #            If inhibition=TRUE, h is monotone, increasing, and must tend
-  #            to 1 when the distance tends to infinity. 0<= h(d,theta,delta) <= 1.
-  #            Else, h is monotone, decreasing, and must tend
-  #            to 1 when the distance tends to 0. 0<= h(d,theta,delta) <= 1.
-  #  
-  #         p: a function among "min", "max", "prod".  
-  #  
-  #   replace: logical allowing times repetition.
-  #
-  #   npoints: number of points to simulate. 
-  #
-  #
-  # Value:
-  #  pattern: list containing times t of the simulated process.
-  #
-  ##
-  ## E. GABRIEL, 26/03/2007
-  ##
-  ## last modification: 31/10/2008
-  ##
-  ##
-  
+  {  
   if (missing(t.region)) t.region <- c(0,1)
 
   if (!(is.function(h)))
@@ -355,40 +289,6 @@
 
 rinter <- function(npoints,s.region,t.region,hs="step",gs="min",thetas=0,deltas,ht="step",gt="min",thetat=1,deltat,recent="all",nsim=1,discrete.time=FALSE,replace=FALSE,inhibition=TRUE,...)
   {
-  #
-  # Simulate an inhibition or a contagious point process in a region D x T.
-  #
-  # Requires Splancs.
-  #  
-  # Arguments:
-  #  
-  #  s.region: two columns matrix specifying polygonal region containing
-  #        all data locations. If poly is missing, the unit square is
-  #        considered.
-  #
-  #  t.region: vector containing the minimum and maximum values of
-  #            the time interval.
-  #
-  #    hs, ht: a function of the distance between points and theta.
-  #            If inhibition=TRUE, h is monotone, increasing, and must tend
-  #            to 1 when the distance tends to infinity. 0<= h(d,theta) <= 1.
-  #            Else, h is monotone, decreasing, and must tend
-  #            to 1 when the distance tends to 0. 0<= h(d,theta) <= 1.
-  #  
-  #    gs, gt: a function among "min", "max", "prod".  
-  #  
-  #   replace: logical allowing times repetition.
-  #
-  #   npoints: number of points to simulate. 
-  #
-  #      nsim: number of simulations to generate. Default is 1.
-  #
-  #
-  # Value:
-  #  xyt: list containing the points (x,y,t) of the simulated point
-  #           process.
-  #
-
   
   if (is.null(npoints)) stop("please specify the number of points to generate")
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)

Modified: pkg/R/rlgcp.r
===================================================================
--- pkg/R/rlgcp.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/rlgcp.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -80,41 +80,6 @@
 
 rlgcp <- function(s.region, t.region, replace=TRUE, npoints=NULL, nsim=1, nx=100, ny=100, nt=100,separable=TRUE,model="exponential",param=c(1,1,1,1,1,2),scale=c(1,1),var.grf=1,mean.grf=0,lmax=NULL,discrete.time=FALSE,exact=FALSE)
 {
-  #
-  # Simulate a space-time log-Gaussian point process in a region D x T.
-  #
-  # Requires Splancs.
-  #  
-  # Arguments:
-  #  
-  #  s.region: two columns matrix specifying polygonal region containing
-  #        all data locations. If poly is missing, the unit square is
-  #        considered.
-  #
-  #  t.region: vector containing the minimum and maximum values of
-  #            the time interval.
-  #
-  #   replace: logical allowing times repetition.
-  #
-  #   npoints: number of points to simulate. If NULL (default), the
-  #            number of points is from a Poisson distribution with
-  #            mean the double integral of lambda over s.region and
-  #            t.region.
-  #
-  #      nsim: number of simulations to generate. Default is 1.
-  #
-  #  nx,ny,nt: define the 3-D grid on which the intensity is evaluated.
-  #
-  #
-  # Value:
-  #  pattern: list containing the points (x,y,t) of the simulated point
-  #           process.
-  #  Lambda: an array of the intensity surface at each time.
-  #
-  # NB: the probability that an event occurs at a location s and a time t
-  #     is:
-  #     p(t)=lambda(s,t)/(max_{s_i, i=1,...,ngrid} lambda(s_i,t)).
-  #
   
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)
   if (missing(t.region)) t.region <- c(0,1)

Modified: pkg/R/rpcp.r
===================================================================
--- pkg/R/rpcp.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/rpcp.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -215,69 +215,7 @@
 
 rpcp <- function(s.region, t.region, nparents=NULL, npoints=NULL, lambda=NULL, mc=NULL, nsim=1, cluster="uniform", dispersion, infectious=TRUE, edge = "larger.region", larger.region=larger.region, tronc=1,...)
 {
-  #
-  # Simulate a space-time Poisson cluster process in a region D x T.
-  # Children are simulated within a cylinder defined around the parent. 
-  #
-  # Requires Splancs package.
-  #  
-  # Arguments:
-  #  
-  #   s.region: two columns matrix specifying polygonal region containing
-  #             all data locations. If s.region is missing, the unit square
-  #             is considered.
-  #
-  #   t.region: vector containing the minimum and maximum values of
-  #             the time interval.
-  #
-  #   nparents: number of parents. If missing, nparents is from a
-  #             Poisson distribution with intensity lambda.
-  #
-  #    npoints: number of points to simulate. If NULL (default), the
-  #             number of points is from a Poisson distribution with
-  #             mean the double integral of lambda over s.region and
-  #             t.region.
-  #
-  #    lambda: intensity of the parent process. Can be either a numeric
-  #             value or a function. If NULL, it is constant and equal
-  #             to nparents / volume of the domain.
-  #
-  #         mc: average number of children per parent. It is used when
-  #             npoints is NULL. 
-  #
-  #       nsim: number of simulations to generate. Default is 1.
-  #
-  #    cluster: distribution of children. "uniform", "normal" and
-  #             exponential are currently implemented.
-  #             Either a single value if the distribution in space
-  #             and time is the same, or a vector of length 2, given
-  #             first the spatial distribution of children and then
-  #             the temporal distribution.
-  #
-  #     dispersion: vector of length 2 giving the maximum spatial and temporal
-  #             variation of the offspring.
-  #             dispersions = maximum distance between parent and child (radius of
-  #             a circle centred at the parent).
-  #             dispersiont = maximum time separiting parent and child.
-  #             For a normal distribution of children, dispersion corresponds to 
-  #             the 2 * standard deviation of location of children relative
-  #             to their parent, such that children lies in the 95% IC
-  #             of the normal distribution.
-  #
-  # infectious: If TRUE (default), corresponds to infectious diseases
-  #             (times of children are always greater than parent's time).
-  #
-  #       edge: specify the edge correction to use, "weight", "larger.region",
-  #             "without". 
-  #
-  #        ...: additional parameters of the intensity of the parent process.
-  #
-  # Value:
-  #  xyt: matrix (or list of matrix if nsim>1) containing the points (x,y,t)
-  #           of the simulated point process.
-  #
 
-
   if (missing(cluster)) cluster <- "uniform"
   
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)

Modified: pkg/R/rpp.r
===================================================================
--- pkg/R/rpp.r	2012-03-23 16:18:37 UTC (rev 40)
+++ pkg/R/rpp.r	2012-03-26 13:25:24 UTC (rev 41)
@@ -1,38 +1,5 @@
 make.grid <- function(nx,ny,poly)
   {
-  #
-  # Generate a rectangular grid of points in a polygon
-  #
-  # Requires Splancs package.
-  #
-  # Arguments:
-  #
-  #   nx, ny: grid dimensions.
-  #
-  #   poly: two columns matrix specifying polygonal region containing
-  #         all data locations. If poly is missing, the unit square is
-  #         considered.
-  #
-  # Value:
-  #
-  #    x, y: numeric vectors giving the coordinates of the points
-  #          of the rectangular grid,
-  #
-  #    X, Y: matrix containing x and y coordinates respectively,
-  #
-  #     pts: index of the grid points belonging to the polygon,
-  #
-  #  xinc, yinc: mesh size of the grid,
-  #
-  #   mask: nx*ny matrix of logicals. TRUE if the grid point belongs
-  #         to the polygon.
-  #  
-  ##
-  ## E. GABRIEL, 28/12/2005
-  ##
-
-#    library(splancs)
-
     if (missing(poly)) poly <- matrix(c(0,0,1,0,1,1,0,1),4,2,T)
     
     if ((nx < 2) || (ny < 2)) stop("the grid must be at least of size 2x2")
@@ -75,7 +42,7 @@
 
     X[pts] <- TRUE
     X[X!=TRUE] <- FALSE
-    mask <- matrix(X,ncol=ny,nrow=nx,byrow=T)
+    mask <- matrix(X,ncol=ny,nrow=nx,byrow=TRUE)
 
     invisible(return(list(x=xgrid,y=ygrid,X=xx,Y=yy,pts=pts,xinc=xinc,yinc=yinc,mask=matrix(as.logical(mask),nx,ny))))
   }
@@ -114,7 +81,7 @@
       if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
-          if ((length(vect)<npoints) & (replace==F))
+          if ((length(vect)<npoints) & (replace==FALSE))
             stop("when replace=FALSE and discrete.time=TRUE, the length of seq(t.region[1],t.region[2],by=1) must be greater than the number of points")
           names(vect) <- 1:length(vect) 
           M <- sample(vect,npoints,replace=replace)
@@ -179,7 +146,7 @@
     {
       s.grid <- make.grid(nx,ny,s.region)
       s.grid$mask <- matrix(as.logical(s.grid$mask),nx,ny)
-      if (discrete.time==T)
+      if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
           if (nt>length(vect))
@@ -203,25 +170,25 @@
           for(it in 1:nt)
             {
               L <- lambda(as.vector(s.grid$X),as.vector(s.grid$Y),t.grid$times[it],...)
-              M <- matrix(L,ncol=ny,nrow=nx,byrow=T)
+              M <- matrix(L,ncol=ny,nrow=nx,byrow=TRUE)
               M[!(s.grid$mask)] <- NaN
               Lambda[,,it] <- M
             }
         }
       
-      if (is.null(npoints)==T)
+      if (is.null(npoints)==TRUE)
         {
           if (t.area==0)
-            { en <- sum(Lambda,na.rm=T)*s.grid$xinc*s.grid$yinc }
+            { en <- sum(Lambda,na.rm=TRUE)*s.grid$xinc*s.grid$yinc }
           else
             {
-              en <- sum(Lambda,na.rm=T)*s.grid$xinc*s.grid$yinc*t.grid$tinc 
+              en <- sum(Lambda,na.rm=TRUE)*s.grid$xinc*s.grid$yinc*t.grid$tinc 
               npoints <- round(rpois(n=1,lambda=en),0)
             }
         }
 
       if (is.null(lambdamax))
-        lambdamax <- max(Lambda,na.rm=T)
+        lambdamax <- max(Lambda,na.rm=TRUE)
       npts <- round(lambdamax/(s.area*t.area),0)
       if (npts==0) stop("there is no data to thin")
       
@@ -229,8 +196,8 @@
       x <- xy[,1]
       y <- xy[,2]
       
-      if ((replace==F) & (nt < max(npts,npoints))) stop("when replace=FALSE, nt must be greater than the number of points used for thinning")
-      if (discrete.time==T)
+      if ((replace==FALSE) & (nt < max(npts,npoints))) stop("when replace=FALSE, nt must be greater than the number of points used for thinning")
+      if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
           times.init <- sample(vect,nt,replace=replace)
@@ -243,12 +210,12 @@
       prob <-  lambda(x,y,times,...)/lambdamax
       u <- runif(npts)
       retain <- u <= prob
-      if (sum(retain==F)==length(retain))
+      if (sum(retain==FALSE)==length(retain))
         {
           lambdas <- matrix(0,nrow=nx,ncol=ny)
           for(ix in 1:nx){for(iy in 1:ny){
-            lambdas[ix,iy] <- median(Lambda[ix,iy,],na.rm=T)}}
-          lambdamax <- max(lambdas,na.rm=T)
+            lambdas[ix,iy] <- median(Lambda[ix,iy,],na.rm=TRUE)}}
+          lambdamax <- max(lambdas,na.rm=TRUE)
           prob <-  lambda(x,y,times,...)/lambdamax
           retain <- u <= prob
           if (sum(retain==F)==length(retain)) stop ("no point was retained at the first iteration, please check your parameters")
@@ -265,7 +232,7 @@
           xy <- as.matrix(csr(poly=s.region,npoints=npoints-neffec))
           if(dim(xy)[2]==1){wx <- xy[1]; wy <- xy[2]}
           else{wx <- xy[,1]; wy <- xy[,2]}
-          if(replace==F)
+          if(replace==FALSE)
             { wsamp <- sample(samp.remain,npoints-neffec,replace=replace) }
           else{ wsamp <- sample(1:nt,npoints-neffec,replace=replace) }
           wtimes <- times.init[wsamp]
@@ -298,7 +265,7 @@
       s.grid <- make.grid(nx,ny,s.region)
       s.grid$mask <- matrix(as.logical(s.grid$mask),nx,ny)
 
-      if (discrete.time==T)
+      if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
           if (nt>length(vect))
@@ -318,17 +285,17 @@
           
       if (is.null(npoints))
         {
-	    en <- sum(Lambda,na.rm=T)*s.grid$xinc*s.grid$yinc*t.grid$tinc 
+	    en <- sum(Lambda,na.rm=TRUE)*s.grid$xinc*s.grid$yinc*t.grid$tinc 
           npoints <- round(rpois(n=1,lambda=en),0)
         }
       if (is.null(lambdamax))
-        lambdamax <- max(Lambda,na.rm=T)
+        lambdamax <- max(Lambda,na.rm=TRUE)
 #      npts <- round(lambdamax/(s.area*t.area),0)
       npts <- npoints
       if (npts==0) stop("there is no data to thin")
 
-      if ((replace==F) & (nt < max(npts,npoints))) stop("when replace=FALSE, nt must be greater than the number of points used for thinning")
-      if (discrete.time==T)
+      if ((replace==FALSE) & (nt < max(npts,npoints))) stop("when replace=FALSE, nt must be greater than the number of points used for thinning")
+      if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
           times.init <- sample(vect,nt,replace=replace)
@@ -339,8 +306,8 @@
       samp <- sample(1:nt,npts,replace=replace)
       times <- times.init[samp]
 
-      retain.eq.F <- F
-      while(retain.eq.F==F)
+      retain.eq.F <- FALSE
+      while(retain.eq.F==FALSE)
         {
           xy <- matrix(csr(poly=s.region,npoints=npts),ncol=2)
           x <- xy[,1]
@@ -367,21 +334,21 @@
           
           u <- runif(npts)
           retain <- u <= prob
-          if (sum(retain==F)==length(retain)) retain.eq.F <- F
-          else retain.eq.F <- T
+          if (sum(retain==F)==length(retain)) retain.eq.F <- FALSE
+          else retain.eq.F <- TRUE
         }
-#      if (sum(retain==F)==length(retain)) stop ("no point was retained at the first iteration, please check your parameters")
+#      if (sum(retain==FALSE)==length(retain)) stop ("no point was retained at the first iteration, please check your parameters")
       
 
-      if (sum(retain==F)==length(retain))
+      if (sum(retain==FALSE)==length(retain))
         {
           lambdas <- matrix(0,nrow=nx,ncol=ny)
           for(ix in 1:nx){for(iy in 1:ny){
-            lambdas[ix,iy] <- median(Lambda[ix,iy,],na.rm=T)}}
-          lambdamax <- max(lambdas,na.rm=T)
+            lambdas[ix,iy] <- median(Lambda[ix,iy,],na.rm=TRUE)}}
+          lambdamax <- max(lambdas,na.rm=TRUE)
           prob <-  lambda(x,y,times,...)/lambdamax
           retain <- u <= prob
-          if (sum(retain==F)==length(retain)) stop ("no point was retained at the first iteration, please check your parameters")
+          if (sum(retain==FALSE)==length(retain)) stop ("no point was retained at the first iteration, please check your parameters")
         }
 
       x <- x[retain]
@@ -406,7 +373,7 @@
           xy <- as.matrix(csr(poly=s.region,npoints=npoints-neffec))
           if(dim(xy)[2]==1){wx <- xy[1]; wy <- xy[2]}
           else{wx <- xy[,1]; wy <- xy[,2]}
-          if(replace==F)
+          if(replace==FALSE)
             { wsamp <- sample(samp.remain,npoints-neffec,replace=replace) }
           else{ wsamp <- sample(1:nt,npoints-neffec,replace=replace) }
           wtimes <- times.init[wsamp]
@@ -453,57 +420,6 @@
 
 rpp <- function(lambda, s.region, t.region, npoints=NULL, nsim=1, replace=TRUE, discrete.time=FALSE, nx=100, ny=100, nt=100, lmax=NULL, Lambda=NULL, ...)
 {
-  #
-  # Simulate a space-time Poisson process in a region D x T.
-  #
-  # Requires Splancs package.
-  #  
-  # Arguments:
-  #
-  #        lambda: Spatio-temporal intensity of the Poisson process. 
-  #                If 'lambda' is a single positive number, the function 
-  #			 generates realisations of a homogeneous Poisson process, 
-  # 			 whilst if 'lambda' is a function of the form 
-  #			 lambda(x,y,t,...) or a character it generates 
-  #   		 realisations of an inhomogeneous Poisson process.
-  #
-  #      s.region: two columns matrix specifying polygonal region containing
-  #                all data locations. If s.region is missing, the unit square
-  #                is considered.
-  #
-  #      t.region: vector containing the minimum and maximum values of
-  #                the time interval. If t.region is missing, the interval
-  #                [0,1] is considered.
-  #
-  #       replace: logical allowing times repetition.
-  #
-  #       npoints: number of points to simulate. If NULL (default), the
-  #                number of points is from a Poisson distribution with
-  #                mean the double integral of lambda over s.region and
-  #                t.region.
-  #
-  # discrete.time: if TRUE, times belong to N, otherwise belong to R+.
-  #
-  #          nsim: number of simulations to generate. Default is 1.
-  #
-  #      nx,ny,nt: define the 3-D grid on which the intensity is evaluated.
-  #
-  #          lmax: upper bound for the value of lambda(x,y,t), if lambda
-  #                is a function.
-  #
-  #	      Lambda: array of spatial intensity if 'lambda' is a character.
-  #
-  #
-  #
-  # Value:
-  #     xyt: matrix (or list if nsim>1) containing the points (x,y,t)
-  #           of the simulated point process.
-  #  Lambda: an array of the intensity surface  
-  #
-  # NB: the probability that an event occurs at a location s and a time t
-  #     is:
-  #     p(s,t)=lambda(s,t)/(max_{(s_i,t_i), i=1,...,ngrid} lambda(s_i,t_i)).
-  #
 
   if (missing(s.region)) s.region <- matrix(c(0,0,1,1,0,1,1,0),ncol=2)
   if (missing(t.region)) t.region <- c(0,1)
@@ -555,7 +471,7 @@
     {
       s.grid <- make.grid(nx,ny,s.region)
       s.grid$mask <- matrix(as.logical(s.grid$mask),nx,ny)
-      if (discrete.time==T)
+      if (discrete.time==TRUE)
         {
           vect <- seq(floor(t.region[1]),ceiling(t.region[2]),by=1)
           if (nt>length(vect))
@@ -577,7 +493,7 @@
       for(it in 1:nt)
         {
           L <- lambda(as.vector(s.grid$X),as.vector(s.grid$Y),t.grid$times[it],...)
-          M <- matrix(L,ncol=ny,nrow=nx,byrow=T)
+          M <- matrix(L,ncol=ny,nrow=nx,byrow=TRUE)
           M[!(s.grid$mask)] <- NaN
           Lambda[,,it] <- M
         }

Deleted: pkg/src/stpp.dll
===================================================================
(Binary files differ)



More information about the Stpp-commits mailing list