hch2d {spgam}R Documentation

~~function to do ... ~~

Description

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

Usage

hch2d(hvals, pts, y, w = rep(1, length(y)))

Arguments

hvals ~~Describe hvals here~~
pts ~~Describe pts here~~
y ~~Describe y here~~
w ~~Describe w 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(hvals, pts, y, w = rep(1, length(y)))
{
                                        # hvals contains 5, 10, 15 or 20 values of h, and we want the one which
                                        # minimises the CV criterion for kernel regression as in cvkreg2d.
  nh <- length(hvals)
  if((nh != 5) & (nh != 10) & (nh != 15) & (nh != 20)) {
    stop("length of hvals must be one of 5,10,15 and 20")
  }
  cv <- rep(NA, nh)
  i <- 1
  cv[i] <- cvkreg2d(hvals[i], pts, y, w)
  cat(i, hvals[i], cv[i], "\n")
  i <- 2
  cv[i] <- cvkreg2d(hvals[i], pts, y, w)
  cat(i, hvals[i], cv[i], "\n")
  i <- 3
  cv[i] <- cvkreg2d(hvals[i], pts, y, w)
  cat(i, hvals[i], cv[i], "\n")
  i <- 4
  cv[i] <- cvkreg2d(hvals[i], pts, y, w)
  cat(i, hvals[i], cv[i], "\n")
  i <- 5
  cv[i] <- cvkreg2d(hvals[i], pts, y, w)
  cat(i, hvals[i], cv[i], "\n")
  if(nh > 5) {
    i <- 6
    cv[i] <- cvkreg2d(hvals[i], pts, y, w)
    cat(i, hvals[i], cv[i], "\n")
    i <- 7
    cv[i] <- cvkreg2d(hvals[i], pts, y, w)
    cat(i, hvals[i], cv[i], "\n")
    i <- 8
    cv[i] <- cvkreg2d(hvals[i], pts, y, w)
    cat(i, hvals[i], cv[i], "\n")
    i <- 9
    cv[i] <- cvkreg2d(hvals[i], pts, y, w)
    cat(i, hvals[i], cv[i], "\n")
    i <- 10
    cv[i] <- cvkreg2d(hvals[i], pts, y, w)
    cat(i, hvals[i], cv[i], "\n")
    if(nh > 10) {
      i <- 11
      cv[i] <- cvkreg2d(hvals[i], pts, y, w)
      cat(i, hvals[i], cv[i], "\n")
      i <- 12
      cv[i] <- cvkreg2d(hvals[i], pts, y, w)
      cat(i, hvals[i], cv[i], "\n")
      i <- 13
      cv[i] <- cvkreg2d(hvals[i], pts, y, w)
      cat(i, hvals[i], cv[i], "\n")
      i <- 14
      cv[i] <- cvkreg2d(hvals[i], pts, y, w)
      cat(i, hvals[i], cv[i], "\n")
      i <- 15
      cv[i] <- cvkreg2d(hvals[i], pts, y, w)
      cat(i, hvals[i], cv[i], "\n")
      if(nh > 15) {
        i <- 16
        cv[i] <- cvkreg2d(hvals[i], pts, y, w)
        cat(i, hvals[i], cv[i], "\n")
        i <- 17
        cv[i] <- cvkreg2d(hvals[i], pts, y, w)
        cat(i, hvals[i], cv[i], "\n")
        i <- 18
        cv[i] <- cvkreg2d(hvals[i], pts, y, w)
        cat(i, hvals[i], cv[i], "\n")
        i <- 19
        cv[i] <- cvkreg2d(hvals[i], pts, y, w)
        cat(i, hvals[i], cv[i], "\n")
        i <- 20
        cv[i] <- cvkreg2d(hvals[i], pts, y, w)
        cat(i, hvals[i], cv[i], "\n")
      }
    }
  }
  if(any(is.na(cv)))
    warning("One of CV values is an NA")
  opt <- (1:nh)[cv == min(cv, na.rm = T)]
  ans <- hvals[sort(opt)]
  if(length(ans) > 1) {
    ans <- (max(ans))
  }
  ans
  }

[Package spgam version 1.0 Index]