[adegenet-commits] r337 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 28 17:22:04 CEST 2009


Author: jombart
Date: 2009-05-28 17:22:04 +0200 (Thu, 28 May 2009)
New Revision: 337

Modified:
   pkg/R/seqTrack.R
Log:
Corrected a huge mistake: addition of numbers to dates are taken in SECONDES !


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-05-28 15:10:06 UTC (rev 336)
+++ pkg/R/seqTrack.R	2009-05-28 15:22:04 UTC (rev 337)
@@ -450,7 +450,9 @@
     ## DEFAULT CASE: NO MISSING DATES
     if(!any(isMissDate)){
         for(i in 1:nsim){
-            myDates <- seq.dates + .rTimeSeq(n=NB.DATES.TO.SIM, mu0=mu0, L=seq.length, maxNbDays=2*RANGE.DATES)
+            myDates <- seq.dates +
+                .rTimeSeq(n=NB.DATES.TO.SIM, mu0=mu0, L=seq.length, maxNbDays=RANGE.DATES)*24*3600
+            myDates <- as.POSIXct(round(myDates, units="days"))
             res.new <- seqTrack(seq.names=seq.names, seq.dates=myDates, W=W, optim=optim, proxMat=proxMat, ...)
             valRes[i] <- sum(res.new$weight,na.rm=TRUE)
             if(use.new.res(res.best, res.new)){
@@ -460,42 +462,42 @@
     }
 
 
-    ## OTHER CASE: HANDLE MISSING DATES
-    if(any(isMissDate)){
+    ##  ## OTHER CASE: HANDLE MISSING DATES
+    ##     if(any(isMissDate)){
 
-        ## Handle distribution and its parameters ##
-        argList <- list(...)
+    ##         ## Handle distribution and its parameters ##
+    ##         argList <- list(...)
 
-        if(is.null(argList$dateMin) & identical(rMissDate, .rUnifTimeSeq)){ # earliest date
-            argList$dateMin <- min(seq.dates,na.rm=TRUE)
-        } else {
-            argList$dateMin[is.na(argList$dateMin)] <- min(seq.dates,na.rm=TRUE)
-        }
-        if(is.null(argList$dateMax) & identical(rMissDate, .rUnifTimeSeq)){ # latest date
-            argList$dateMax <- max(seq.dates,na.rm=TRUE)
-        } else {
-            argList$dateMax[is.na(argList$dateMax)] <- max(seq.dates,na.rm=TRUE)
-        }
+    ##         if(is.null(argList$dateMin) & identical(rMissDate, .rUnifTimeSeq)){ # earliest date
+    ##             argList$dateMin <- min(seq.dates,na.rm=TRUE)
+    ##         } else {
+    ##             argList$dateMin[is.na(argList$dateMin)] <- min(seq.dates,na.rm=TRUE)
+    ##         }
+    ##         if(is.null(argList$dateMax) & identical(rMissDate, .rUnifTimeSeq)){ # latest date
+    ##             argList$dateMax <- max(seq.dates,na.rm=TRUE)
+    ##         } else {
+    ##             argList$dateMax[is.na(argList$dateMax)] <- max(seq.dates,na.rm=TRUE)
+    ##         }
 
-        argList$n <- sum(isMissDate)
+    ##         argList$n <- sum(isMissDate)
 
-        ## Make simulations ##
-        for(i in 1:nsim){
-            myDates <- seq.dates
-            ## distribution for available dates
-            myDates[!isMissDate] <- myDates[!isMissDate] +
-                .rTimeSeq(n=NB.DATES.TO.SIM, mu0=mu0, L=seq.length, maxNbDays=2*RANGE.DATES)
-            ## distribution for missing dates
-            myDates[isMissDate] <- do.call(rMissDate, argList)
+    ##         ## Make simulations ##
+    ##         for(i in 1:nsim){
+    ##             myDates <- seq.dates
+    ##             ## distribution for available dates
+    ##             myDates[!isMissDate] <- myDates[!isMissDate] +
+    ##                 .rTimeSeq(n=NB.DATES.TO.SIM, mu0=mu0, L=seq.length, maxNbDays=2*RANGE.DATES)
+    ##             ## distribution for missing dates
+    ##             myDates[isMissDate] <- do.call(rMissDate, argList)
 
-            res.new <- seqTrack(seq.names=seq.names, seq.dates=myDates, W=W, optim=optim, proxMat=proxMat, ...)
+    ##             res.new <- seqTrack(seq.names=seq.names, seq.dates=myDates, W=W, optim=optim, proxMat=proxMat, ...)
 
-            valRes[i] <- sum(res.new$weight,na.rm=TRUE)
-            if(use.new.res(res.best, res.new)){
-                res.best <- res.new
-            }
-        }
-    }
+    ##             valRes[i] <- sum(res.new$weight,na.rm=TRUE)
+    ##             if(use.new.res(res.best, res.new)){
+    ##                 res.best <- res.new
+    ##             }
+    ##         }
+    ##     }
 
 
     ## RESULT ##



More information about the adegenet-commits mailing list