Learn R Programming

grouped (version 0.6-0)

Sdata: Simulated Data

Description

A simulated data-set used for the illustration of grouped for grouped data coming from a logit-normal distribution.

Arguments

Details

The data set has been produced with the code in the Examples below.

Examples

Run this code
n <- 250
treat <- rbinom(n, 1, 0.5)
x <- runif(n, -4, 4)
mu <- 1 + 0.5 * treat -1 * x + 0.8 * treat * x
u <- plogis(rnorm(n, mu, 2))

index <- cbind(c(0, 0.25, 0.5, 0.75), c(0.25, 0.5, 0.75, 1)) 
a <- b <- numeric(n)
for(i in 1:n){
    ind <- which(index[, 2] - u[i] > 0)[1]
    a[i] <- index[ind, 1]
    b[i] <- index[ind, 2]
}
Sdata <- data.frame(lo = a, up = b, treat = factor(treat), x)

str(Sdata)
summary(Sdata)

Run the code above in your browser using DataLab