simm.bb {adehabitat}R Documentation

Brownian bridge motion

Description

~~ A concise (1-5 lines) description of what the function does. ~~

Usage

simm.bb(date = 1:100, begin = c(0, 0), end = begin, id = "A1", burst = id)

Arguments

date ~~Describe date here~~
begin ~~Describe begin here~~
end ~~Describe end here~~
id ~~Describe id here~~
burst ~~Describe burst here~~

Details

~~ If necessary, more details than the description above ~~

Value

~Describe the value returned If it is a LIST, use

comp1 Description of 'comp1'
comp2 Description of 'comp2'

...

Warning

....

Note

~~further notes~~

~Make other sections like Warning with section{Warning }{....} ~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(date=1:100, begin = c(0,0),
                     end=begin, id="A1", burst=id)
  {
    class(date) <- c("POSIX","POSIXct")
    n <- length(date)
    dt <- c(diff(unclass(date)),NA)
    
    dx <- c(rnorm(n-1,0,sqrt(dt[-n])),NA)
    dy <- c(rnorm(n-1,0,sqrt(dt[-n])),NA)
    W <- cbind(dx,dy)
    
    xtmp <- begin
    x <- begin            
    for (i in 2:(n-1)) {
      a <- diag(1/(date[n]-date[i-1]),2)
      dX <- as.numeric((a%*%(end - xtmp)*dt[i-1] + W[i-1,]))
      x <- rbind(x,xtmp+dX)
      xtmp <- xtmp+dX
    }
    x <- rbind(x,end)

    res <- as.ltraj(data.frame(x[,1],x[,2]),date, id, burst)
    return(res)
    
  }

[Package adehabitat version 1.6-1 Index]