1 |
x |
|
y |
|
xout |
|
outfun |
|
plotit |
|
xlab |
|
ylab |
|
varfun |
|
YHAT |
|
STAND |
|
... |
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 | ##---- 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,
xlab = "X", ylab = "Y", varfun = var, YHAT = FALSE, STAND = TRUE,
...)
{
xy = elimna(cbind(x, y))
x <- as.matrix(x)
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)
}
temp = glm(formula = y ~ x, family = poisson)
init = summary(temp)
yhat = temp$coef[1]
for (j in 1:ncol(x)) {
j1 = j + 1
yhat = yhat + temp$coef[j1] * x[, j]
}
yhat = exp(yhat)
if (plotit) {
x = as.matrix(x)
if (ncol(x) > 1)
stop("Cannot plot with more than one predictor")
plot(x, y, xlab = xlab, ylab = ylab)
xord = order(x)
lines(x[xord], yhat[xord])
init$coef
}
ex = varfun(yhat)/varfun(y)
str = sqrt(ex)
hatv = NULL
if (YHAT)
hatv = yhat
list(results = init, Explanatory.Power = ex, Strength.Assoc = str,
yhat = hatv)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.