kerreg2d {spgam}R Documentation

~~function to do ... ~~

Description

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

Usage

kerreg2d(h, pts, y, w = rep(1, length(y)), x = pts, grid = F, poly = NA, ngrid = 1000)

Arguments

h ~~Describe h here~~
pts ~~Describe pts here~~
y ~~Describe y here~~
w ~~Describe w here~~
x ~~Describe x here~~
grid ~~Describe grid here~~
poly ~~Describe poly here~~
ngrid ~~Describe ngrid 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 (h, pts, y, w = rep(1, length(y)), x = pts, grid = F, 
    poly = NA, ngrid = 1000) 
{
    if (!grid) {
        n <- length(y)
        m <- length(x[, 1])
        yans <- rep(0.3, m)
        datx1 <- pts[, 1]
        datx2 <- pts[, 2]
        x1 <- x[, 1]
        x2 <- x[, 2]
        result <- .Fortran("ker2d", h = as.single(h), datx1 = as.single(datx1), 
            datx2 = as.single(datx2), y = as.single(y), w = as.single(w), 
            n = as.integer(n), x1 = as.single(x1), x2 = as.single(x2), 
            yans = as.single(yans), m = as.integer(m), df = as.single(0))
        ans <- list(vals = result$yans, df = result$df)
    }
    if (grid) {
        n <- length(y)
        datx1 <- pts[, 1]
        datx2 <- pts[, 2]
        x1range <- range(poly[, 1])
        x2range <- range(poly[, 2])
        x1min <- x1range[1]
        x1max <- x1range[2]
        x2min <- x2range[1]
        x2max <- x2range[2]
        x1length <- diff(x1range)
        x2length <- diff(x2range)
        actngrid <- (ngrid * x1length * x2length)/(areapl(poly))
        m1 <- ceiling(sqrt((actngrid * x1length)/x2length))
        m2 <- ceiling(sqrt((actngrid * x2length)/x1length))
        zmat <- matrix(0, m1, m2)
        mode(zmat) <- "single"
        x1 <- seq(x1min + x1length/(2 * m1), x1max - x1length/(2 * 
            m1), length = m1)
        x2 <- seq(x2min + x2length/(2 * m2), x2max - x2length/(2 * 
            m2), length = m2)
        xyvec1 <- rep(x1, m2)
        xyvec2 <- rep(x2, rep(m1, m2))
        xyvec <- cbind(xyvec1, xyvec2)
        lpmat <- matrix(inout(xyvec, poly), nrow = m1, ncol = m2, 
            byrow = F)
        mode(lpmat) <- "logical"
        result <- .Fortran("ker2dg", h = as.single(h), datx1 = as.single(datx1), 
            datx2 = as.single(datx2), y = as.single(y), w = as.single(w), 
            n = as.integer(n), x1 = as.single(x1), x2 = as.single(x2), 
            zmat = zmat, lpmat = lpmat, m1 = as.integer(m1), 
            m2 = as.integer(m2))
        z <- result$zmat
        z[z == 0] <- NA
        ans <- list(x = x1, y = x2, z = z)
    }
    ans
  }

[Package spgam version 1.0 Index]