1 |
x |
|
y |
|
fr |
|
est |
|
theta |
|
phi |
|
nmin |
|
pyhat |
|
eout |
|
outfun |
|
plotit |
|
xout |
|
nboot |
|
SEED |
|
STAND |
|
expand |
|
scale |
|
xlab |
|
ylab |
|
zlab |
|
ticktype |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ##---- 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 (x, y, fr = 1, est = tmean, theta = 50, phi = 25, nmin = 0,
pyhat = FALSE, eout = FALSE, outfun = out, plotit = TRUE,
xout = FALSE, nboot = 40, SEED = TRUE, STAND = TRUE, expand = 0.5,
scale = FALSE, xlab = "X", ylab = "Y", zlab = "", ticktype = "simple",
...)
{
library(MASS)
library(akima)
if (SEED)
set.seed(2)
temp <- cbind(x, y)
x <- as.matrix(x)
p <- ncol(x)
p1 <- p + 1
if (p > 2)
plotit <- F
temp <- elimna(temp)
x <- temp[, 1:p]
x <- as.matrix(x)
y <- temp[, p1]
if (xout) {
keepit <- rep(T, nrow(x))
flag <- outfun(x, plotit = FALSE, STAND = STAND, ...)$out.id
keepit[flag] <- F
x <- x[keepit, ]
y <- y[keepit]
}
mat <- matrix(NA, nrow = nboot, ncol = length(y))
vals <- NA
for (it in 1:nboot) {
idat <- sample(c(1:length(y)), replace = TRUE)
xx <- temp[idat, 1:p]
yy <- temp[idat, p1]
tmy <- rung3hat(xx, yy, pts = x, est = est, fr = fr,
...)$rmd
mat[it, ] <- tmy
}
rmd <- apply(mat, 2, mean, na.rm = TRUE)
flag <- !is.na(rmd)
rmd <- elimna(rmd)
x <- x[flag, ]
y <- y[flag]
nval <- NA
m <- cov.mve(x)
for (i in 1:nrow(x)) nval[i] <- length(y[near3d(x, x[i, ],
fr, m)])
if (plotit && ncol(x) == 2) {
fitr <- rmd[nval > nmin]
y <- y[nval > nmin]
x <- x[nval > nmin, ]
iout <- c(1:length(fitr))
nm1 <- length(fitr) - 1
for (i in 1:nm1) {
ip1 <- i + 1
for (k in ip1:length(fitr)) if (sum(x[i, ] == x[k,
]) == 2)
iout[k] <- 0
}
fitr <- fitr[iout >= 1]
mkeep <- x[iout >= 1, ]
fit <- interp(mkeep[, 1], mkeep[, 2], fitr)
persp(fit, theta = theta, phi = phi, xlab = xlab, ylab = ylab,
zlab = zlab, expand = expand, scale = scale, ticktype = ticktype)
}
last <- "Done"
if (pyhat)
last <- rmd
list(output = last)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.