Learn R Programming

survey (version 2.4)

api: Student performance in California schools

Description

The Academic Performance Index is computed for all California schools based on standardised testing of students. The data sets contain information for all schools with at least 100 students and for various probability samples of the data.

Usage

data(apipop)
data(apistrat)
data(apiclus1)
data(apiclus2)

Arguments

source

Data were obtained from the survey sampling help pages of UCLA Academic Technology Services, at http://www.ats.ucla.edu/stat/stata/Library/svy_survey.htm.

Details

pop is the entire population, clus1 is a cluster sample of school districts, strat is a sample stratified by stype, and clus2 is a two-stage cluster sample of schools within districts.

References

The API program and original data files are at http://api.cde.ca.gov/

Examples

Run this code
library(survey)
data(api)
mean(apipop$api00)
sum(apipop$enroll)

#stratified sample
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
summary(dstrat)
svymean(~api00, dstrat)
svytotal(~enroll, dstrat)

# one-stage cluster sample
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
summary(dclus1)
svymean(~api00, dclus1)
svytotal(~enroll, dclus1)

# two-stage cluster sample
dclus2<-svydesign(id=~dnum+snum, weights=~pw, data=apiclus2)
summary(dclus2)
svymean(~api00, dclus2)
svytotal(~enroll, dclus2)

# convert to replicate weights
rclus1<-as.svrepdesign(dclus1)
summary(rclus1)
svrepmean(~api00, rclus1)
svreptotal(~enroll, rclus1)

# post-stratify on school type
pop.types<-xtabs(~stype, data=apipop)

rclus1p<-postStratify(rclus1, ~stype, pop.types)
summary(rclus1p)
svrepmean(~api00, rclus1p)
svreptotal(~enroll, rclus1p)

Run the code above in your browser using DataLab