1 |
x |
|
y |
|
regfun |
|
pyhat |
|
eout |
|
xout |
|
outfun |
|
plotit |
|
expand |
|
scale |
|
xlab |
|
ylab |
|
zlab |
|
theta |
|
phi |
|
family |
|
duplicate |
|
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 | ##---- 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, regfun = tsreg, pyhat = FALSE, eout = FALSE,
xout = FALSE, outfun = out, plotit = TRUE, expand = 0.5,
scale = FALSE, xlab = "X", ylab = "Y", zlab = "", theta = 50,
phi = 25, family = "gaussian", duplicate = "error", ticktype = "simple",
...)
{
library(akima)
x <- as.matrix(x)
xx <- cbind(x, y)
xx <- elimna(xx)
x <- xx[, 1:ncol(x)]
x <- as.matrix(x)
y <- xx[, ncol(x) + 1]
if (xout) {
p = ncol(x)
p1 = p + 1
m <- cbind(x, y)
flag <- outfun(x, plotit = FALSE, ...)$keep
m <- m[flag, ]
x <- m[, 1:p]
y <- m[, p1]
}
if (!scale)
print("scale=F. If there is an association, try scale=T")
if (ncol(x) != 2)
stop("x should have two columns")
xx = cbind(x, x[, 1] * x[, 2])
temp = regfun(xx, y)
fitr = y - temp$residuals
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, duplicate = duplicate)
persp(fit, theta = theta, phi = phi, expand = expand, scale = scale,
xlab = xlab, ylab = ylab, zlab = zlab, ticktype = ticktype)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.