Learn R Programming

R2MLwiN (version 0.8-9)

reading1: Students' reading attainment in inner London infant schools.

Description

Reading score data for 407 pupils across 6 occasions.

Usage

reading1

Arguments

Format

A data frame with 407 observations on the following 13 variables:

id

Unique pupil identifying code.

age1

Age at occasion 1.

read1

Reading score at occasion 1.

age2

Age at occasion 2.

read2

Reading score at occasion 2.

age3

Age at occasion 3.

read3

Reading score at occasion 3.

age4

Age at occasion 4.

read4

Reading score at occasion 4.

age5

Age at occasion 5.

read5

Reading score at occasion 5.

age6

Age at occasion 6.

read6

Reading score at occasion 6.

Details

The reading1 dataset is one of the sample datasets provided with the multilevel-modelling software package MLwiN (Rasbash et al., 2009), and was analysed in Tizard et al. (1988); see also Rasbash et al. (2012) for further details.

Examples

Run this code

if (FALSE) {
# from demo(UserGuide13)

data(reading1, package = "R2MLwiN")
summary(reading1)

reading1[reading1 == -10] <- NA

summary(reading1)

reading <- reshape(reading1, idvar = "student", timevar = "id",
                   varying = c("read1", "age1", "read2", "age2", "read3", "age3",
                   "read4", "age4", "read5", "age5", "read6", "age6"),
                   sep = "", direction = "long")

reading <- reading[c("student", "id", "age", "read")]
reading <- reading[order(reading$student, reading$id), ]

colnames(reading) <- c("student", "occasion", "age", "reading")
rownames(reading) <- NULL

summary(reading)

head(reading, 5)

tab <- aggregate(reading ~ occasion, reading,
                 function(x) c(N = length(x), mean = mean(x), sd = sd(x)))
tab <- rbind(tab, c(NA, NA))
tab$reading[7, ] <- c(length(na.omit(reading$reading)),
                      mean(na.omit(reading$reading)),
                      sd(na.omit(reading$reading)))
rownames(tab)[7] <- "Total"
tab

tab <- aggregate(age ~ occasion, reading,
                 function(x) c(N = length(x), mean = mean(x), sd = sd(x)))
tab <- rbind(tab, c(NA, NA))
tab$age[7, ] <- c(length(na.omit(reading$age)),
                  mean(na.omit(reading$age)),
                  sd(na.omit(reading$age)))
rownames(tab)[7] <- "Total"
tab

(mymodel1 <- runMLwiN(reading ~ 1 + (1 | student) + (1 | occasion),
                      data = reading))
}

Run the code above in your browser using DataLab