Last data update: 2014.03.03
|
R: Data used for fitting examples
Data used for fitting examples
Description
Example data for logistic, Poisson and negative binomial models.
Usage
data("simData")
Format
A data frame with 200 observations on the following 8 variables.
obs a binary vector. Used as a response for a logistic model.
x1 a numeric vector.
x2 a numeric vector.
x3 a categorical vector with levels blue , red , and yellow .
z1 a categorical vector with levels D1 , D2 , D3 , D4 , and D5 .
z2 a categorical vector with levels 1 , 2 , 3 , 4 , and 5 .
z3 a categorical vectir with levels A , B , and D .
count a numeric vector. Used as a response for a Poisson model.
Details
The levels of z2 can be nested within $z1 $. The observations were generated with the code shown in the examples section.
Examples
set.seed(47819)
x1 <- rnorm(200, 10, 1)
x2 <- rnorm(200, 5, 1)
x3 <- sample(c("red", "blue", "yellow"), size = 200, replace = TRUE)
z1 <- factor(rep(c("D1", "D2", "D3", "D4", "D5"), each = 40))
z2 <- factor(rep(rep(1:4, each = 5), 10))
z3 <- factor(c(rep("A", 100), rep("B", 60), rep("D", 40)))
kX <- model.matrix(~x1 + x2 + x3)
kZ <- cbind(model.matrix(~ 0+z1), model.matrix(~ 0+z1:z2), model.matrix(~ 0+z3))
kBeta <- c(5, -4, 5, 0, 8)
kU <- 3 * rt(28, 5)
linf0 <- kX
prob0 <- exp(linf0)/(1+exp(linf0))
obs <- as.numeric(runif(100) < prob0)
simData <- data.frame(obs, x1, x2, x3, z1, z2, z3)
Results
|