1 |
n |
|
type |
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 | ##---- 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 (n = 200, type = 3)
{
q <- 5
y <- 0 * 1:n
y[(n/2 + 1):n] <- y[(n/2 + 1):n] + 1
beta <- 0 * 1:q
if (type == 1) {
beta[1] <- 1
alpha <- -0.5
}
if (type == 2) {
beta <- beta + 1
alpha <- -q/2
}
if (type == 3) {
beta[1:3] <- 1
alpha <- -1.5
}
x <- matrix(rnorm(n * q), nrow = n, ncol = q)
if (type == 1) {
x[(n/2 + 1):n, 1] <- x[(n/2 + 1):n, 1] + 1
}
if (type == 2) {
x[(n/2 + 1):n, ] <- x[(n/2 + 1):n, ] + 1
}
if (type == 3) {
x[(n/2 + 1):n, 1:3] <- x[(n/2 + 1):n, 1:3] + 1
}
out <- glm(y ~ x[, 1] + x[, 2] + x[, 3] + x[, 4] + x[, 5],
family = binomial)
list(alpha = alpha, beta = beta, lrcoef = out$coef, x = x,
y = y)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.