1 |
x |
|
y |
|
xout |
|
outfun |
|
plotit |
|
POLY |
|
xlab |
|
ylab |
|
zlab |
|
SCALE |
|
expand |
|
theta |
|
phi |
|
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 49 50 51 52 53 54 55 56 57 | ##---- 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, xout = FALSE, outfun = outpro, plotit = FALSE,
POLY = FALSE, xlab = "X", ylab = "Y", zlab = "", SCALE = FALSE,
expand = 0.5, theta = 50, phi = 25, duplicate = "error",
ticktype = "simple", ...)
{
x <- as.matrix(x)
p = ncol(x)
xy = elimna(cbind(x, y))
x = xy[, 1:ncol(x)]
y = xy[, ncol(xy)]
x <- as.matrix(x)
if (xout) {
flag <- outfun(x, ...)$keep
x <- x[flag, ]
y <- y[flag]
}
x <- as.matrix(x)
if (p == 1 || POLY) {
xord = order(x[, 1])
x = x[xord, ]
y = y[xord]
}
fitit = glm(formula = y ~ x, family = binomial)
init <- summary(fitit)
if (plotit) {
vals = fitted.values(fitit)
if (p == 1) {
plot(x, y, xlab = xlab, ylab = ylab)
lines(x, vals)
}
if (p == 2) {
if (!scale)
print("With dependence, suggest using scale=T")
fitr = vals
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)
}
}
init$coef
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.