diff --git a/data/survey/apiclus1.rda b/data/survey/apiclus1.rda
new file mode 100644
index 0000000..9b489a1
Binary files /dev/null and b/data/survey/apiclus1.rda differ
diff --git a/data/survey/apiclus2.rda b/data/survey/apiclus2.rda
new file mode 100644
index 0000000..5cffc96
Binary files /dev/null and b/data/survey/apiclus2.rda differ
diff --git a/data/survey/apipop.rda b/data/survey/apipop.rda
new file mode 100644
index 0000000..c8043d7
Binary files /dev/null and b/data/survey/apipop.rda differ
diff --git a/data/survey/apisrs.rda b/data/survey/apisrs.rda
new file mode 100644
index 0000000..3fbbd90
Binary files /dev/null and b/data/survey/apisrs.rda differ
diff --git a/data/survey/apistrat.rda b/data/survey/apistrat.rda
new file mode 100644
index 0000000..26e67a9
Binary files /dev/null and b/data/survey/apistrat.rda differ
diff --git a/data/survey/crowd.rda b/data/survey/crowd.rda
new file mode 100644
index 0000000..9da3c33
Binary files /dev/null and b/data/survey/crowd.rda differ
diff --git a/data/survey/election.rda b/data/survey/election.rda
new file mode 100644
index 0000000..568ccd4
Binary files /dev/null and b/data/survey/election.rda differ
diff --git a/data/survey/fpc.rda b/data/survey/fpc.rda
new file mode 100644
index 0000000..a1a7baa
Binary files /dev/null and b/data/survey/fpc.rda differ
diff --git a/data/survey/hospital.rda b/data/survey/hospital.rda
new file mode 100644
index 0000000..3feb9f7
Binary files /dev/null and b/data/survey/hospital.rda differ
diff --git a/data/survey/mu284.rda b/data/survey/mu284.rda
new file mode 100644
index 0000000..fa26123
Binary files /dev/null and b/data/survey/mu284.rda differ
diff --git a/data/survey/myco.rda b/data/survey/myco.rda
new file mode 100644
index 0000000..aaeac33
Binary files /dev/null and b/data/survey/myco.rda differ
diff --git a/data/survey/nhanes.rda b/data/survey/nhanes.rda
new file mode 100644
index 0000000..5d7e917
Binary files /dev/null and b/data/survey/nhanes.rda differ
diff --git a/data/survey/salamander.rda b/data/survey/salamander.rda
new file mode 100644
index 0000000..d7fae5e
Binary files /dev/null and b/data/survey/salamander.rda differ
diff --git a/data/survey/scd.rda b/data/survey/scd.rda
new file mode 100644
index 0000000..d58b743
Binary files /dev/null and b/data/survey/scd.rda differ
diff --git a/data/survey/yrbs.rda b/data/survey/yrbs.rda
new file mode 100644
index 0000000..f1de3a2
Binary files /dev/null and b/data/survey/yrbs.rda differ
diff --git a/doc/datasets.csv b/doc/datasets.csv
index b8081be..37b29d6 100644
--- a/doc/datasets.csv
+++ b/doc/datasets.csv
@@ -684,6 +684,21 @@
"sem","Klein","Klein's Data on the U. S. Economy",22,10
"sem","Kmenta","Partly Artificial Data on the U. S. Economy",20,5
"sem","Tests","Six Mental Tests",32,6
+"survey","apiclus1","Student performance in California schools, Cluster Sample of School Districts",183,39
+"survey","apiclus2","Student performance in California schools, Two-Stage Cluster Sample of Schools",126,40
+"survey","apipop","Student performance in California schools, Entire Population",6194,37
+"survey","apisrs","Student performance in California schools, Simple Random Sample",200,39
+"survey","apistrat","Student performance in California schools, Stratified Sample",200,39
+"survey","crowd","Household crowding",6,5
+"survey","election","US 2004 presidential election data at state or county level",4600,8
+"survey","fpc","Small survey example",8,6
+"survey","hospital","Sample of obstetric hospitals",15,6
+"survey","mu284","Two-stage sample from MU284",15,5
+"survey","myco","Association between leprosy and BCG vaccination",516,6
+"survey","nhanes","Cholesterol data from a US survey",8591,7
+"survey","salamander","Salamander mating data set from McCullagh and Nelder (1989)",360,4
+"survey","scd","Survival in cardiac arrest",6,4
+"survey","yrbs","One variable from the Youth Risk Behaviors Survey, 2015.",15624,4
"survival","bladder","Bladder Cancer Recurrences",340,7
"survival","cancer","NCCTG Lung Cancer Data",228,10
"survival","cgd","Chronic Granulotomous Disease data",203,16
diff --git a/doc/packages.csv b/doc/packages.csv
index 011d6ad..f457641 100644
--- a/doc/packages.csv
+++ b/doc/packages.csv
@@ -31,5 +31,6 @@
"rpart","Recursive Partitioning and Regression Trees"
"sandwich","Robust Covariance Matrix Estimators"
"sem","Structural Equation Models"
+"survey","Analysis of Complex Survey Samples"
"survival","Survival Analysis"
"vcd","Visualizing Categorical Data"
diff --git a/doc/survey/crowd.html b/doc/survey/crowd.html
new file mode 100644
index 0000000..d5f0d01
--- /dev/null
+++ b/doc/survey/crowd.html
@@ -0,0 +1,81 @@
+
R: Household crowding
+
+
+
+
+
+
+
+
+
crowd
R Documentation
+
+
Household crowding
+
+
Description
+
+
A tiny dataset from the VPLX manual.
+
+
+
+
Usage
+
+
data(crowd)
+
+
+
Format
+
+
A data frame with 6 observations on the following 5 variables.
+
+
diff --git a/doc/survey/election.html b/doc/survey/election.html
new file mode 100644
index 0000000..e2619cd
--- /dev/null
+++ b/doc/survey/election.html
@@ -0,0 +1,110 @@
+R: US 2004 presidential election data at state or county level
+
+
+
+
+
+
+
+
+
election
R Documentation
+
+
US 2004 presidential election data at state or county level
+
+
Description
+
+
A sample of voting data from US states or counties (depending on data
+availability), sampled with probability proportional to number of votes. The sample was drawn using Tille's splitting method, implemented in the "sampling" package.
+
+
+
+
Usage
+
+
data(election)
+
+
+
Format
+
+
election is a data frame with 4600 observations on the following 8 variables.
+
+
+
+
County
A factor specifying the state or country
+
+
TotPrecincts
Number of precincts in the state or county
+
+
PrecinctsReporting
Number of precincts supplying data
+
+
Bush
Votes for George W. Bush
+
+
Kerry
Votes for John Kerry
+
+
Nader
Votes for Ralph Nader
+
+
votes
Total votes for those three candidates
+
+
p
Sampling probability, proportional to votes
+
+
+
+
election_pps is a sample of 40 counties or states taken with
+probability proportional to the number of votes. It includes the
+additional column wt with the sampling weights.
+
+
election_insample indicates which rows of election were sampled.
+
+
election_jointprob are the pairwise sampling probabilities and
+election_jointHR are approximate pairwise sampling probabilities using
+the Hartley-Rao approximation.
+
The MU284 population comes from Sarndal et al, and the complete data are
+available from Statlib. These data are a two-stage sample from the
+population, analyzed on page 143 of the book.
+
+
+
+
Usage
+
+
data(mu284)
+
+
+
Format
+
+
A data frame with 15 observations on the following 5 variables.
+
+
+
+
id1
identifier for PSU
+
+
n1
number of PSUs in population
+
+
id2
identifier for second-stage unit
+
+
y1
variable to be analysed
+
+
n2
number of second-stage units in this PSU
+
+
+
+
+
+
Source
+
+
Carl Erik Sarndal, Bengt Swensson, Jan Wretman. (1991) "Model Assisted
+Survey Sampling" Springer.
+
+
(downloaded from StatLib, which is no longer active)
+
+
diff --git a/doc/survey/myco.html b/doc/survey/myco.html
new file mode 100644
index 0000000..3e868c0
--- /dev/null
+++ b/doc/survey/myco.html
@@ -0,0 +1,98 @@
+R: Association between leprosy and BCG vaccination
+
+
+
+
+
+
+
+
+
myco
R Documentation
+
+
+Association between leprosy and BCG vaccination
+
+
+
Description
+
+
These data are in a paper by JNK Rao and colleagues, on score tests
+for complex survey data. External information (not further specified) suggests
+the functional form for the Age variable.
+
+
+
+
Usage
+
+
data("myco")
+
+
+
Format
+
+
A data frame with 516 observations on the following 6 variables.
+
+
+
+
Age
Age in years at the midpoint of six age strata
+
+
Scar
Presence of a BCG vaccination scar
+
+
n
Sampled number of cases (and thus controls) in the age stratum
+
+
Ncontrol
Number of non-cases in the population
+
+
wt
Sampling weight
+
+
leprosy
case status 0/1
+
+
+
+
+
+
Details
+
+
The data are a simulated stratified case-control study drawn from a
+population study conducted in a region of Malawi (Clayton and Hills,
+1993, Table 18.1). The goal was to examine whether BCG vaccination against
+tuberculosis protects against leprosy (the causative agents are both species of
+_Mycobacterium_). Rao et al have a typographical error: the number of
+non-cases in the population in the 25-30 age stratum is given as 4981
+but 5981 matches both the computational output and the data as given by Clayton
+and Hills.
+
+
+
+
Source
+
+
JNK Rao, AJ Scott, and Skinner, C. (1998). QUASI-SCORE TESTS WITH SURVEY
+DATA. Statistica Sinica, 8(4), 1059-1070.
+
+
Clayton, D., & Hills, M. (1993). Statistical Models in Epidemiology. OUP
+
+
+
+
Examples
+
+
data(myco)
+dmyco<-svydesign(id=~1, strata=~interaction(Age,leprosy),weights=~wt,data=myco)
+
+m_full<-svyglm(leprosy~I((Age+7.5)^-2)+Scar, family=quasibinomial, design=dmyco)
+m_age<-svyglm(leprosy~I((Age+7.5)^-2), family=quasibinomial, design=dmyco)
+anova(m_full,m_age)
+
+## unweighted model does not match
+m_full
+glm(leprosy~I((Age+7.5)^-2)+Scar, family=binomial, data=myco)
+
+
+
+
+
+
+
diff --git a/doc/survey/nhanes.html b/doc/survey/nhanes.html
new file mode 100644
index 0000000..5e813db
--- /dev/null
+++ b/doc/survey/nhanes.html
@@ -0,0 +1,76 @@
+R: Cholesterol data from a US survey
+
+
+
+
+
+
+
+
+
nhanes
R Documentation
+
+
+Cholesterol data from a US survey
+
+
+
Description
+
+
Data extracted from NHANES 2009-2010 on high cholesterol.
+
+
+
+
Usage
+
+
data(nhanes)
+
+
+
Format
+
+
A data frame with 8591 observations on the following 7 variables.
+
+
+
+
SDMVPSU
Primary sampling units
+
+
SDMVSTRA
Sampling strata
+
+
WTMEC2YR
Sampling weights
+
+
HI_CHOL
Numeric vector: 1 for total cholesterol over
+240mg/dl, 0 under 240mg/dl
+
diff --git a/doc/survey/salamander.html b/doc/survey/salamander.html
new file mode 100644
index 0000000..abd9bff
--- /dev/null
+++ b/doc/survey/salamander.html
@@ -0,0 +1,85 @@
+R: Salamander mating data set from McCullagh and Nelder (1989)
+
+
+
+
+
+
+
+
+
salamander
R Documentation
+
+
Salamander mating data set from McCullagh and Nelder (1989)
+
+
Description
+
+
This data set presents the outcome of three experiments
+conducted at the University of Chicago in 1986 to study interbreeding
+between populations of mountain dusky salamanders (McCullagh and
+Nelder, 1989, Section 14.5). The analysis here is from Lumley (1998,
+section 5.3)
+
+
+
Usage
+
+
data(salamander)
+
+
+
Format
+
+
A data frame with the following columns:
+
+
+
+
Mate
Whether the salamanders mated (1) or did not mate (0).
+
+
Cross
Cross between female and male type. A factor with four levels: R/R,R/W,W/R, and W/W. The type of the female salamander is listed first and the male is listed second. Rough Butt is represented by R and White Side is represented by W. For example, Cross=W/R indicates a White Side female was crossed with a Rough Butt male.
+
+
Male
Identification number of the male salamander. A factor.
+
+
Female
Identification number of the female salamander. A factor.
+
+
+
+
+
+
References
+
+
McCullagh P. and Nelder, J. A. (1989) Generalized
+Linear Models. Chapman and Hall/CRC.
+Lumley T (1998) PhD thesis, University of Washington
+
+
+
+
Examples
+
+
data(salamander)
+salamander$mixed<-with(salamander, Cross=="W/R" | Cross=="R/W")
+salamander$RWvsWR<-with(salamander, ifelse(mixed,
+ ((Cross=="R/W")-(Cross=="W/R"))/2,
+ 0))
+xsalamander<-xdesign(id=list(~Male, ~Female), data=salamander,
+ overlap="unbiased")
+
+## Adjacency matrix
+## Blocks 1 and 2 are actually the same salamanders, but
+## it's traditional to pretend they are independent.
+image(xsalamander$adjacency)
+
+## R doesn't allow family=binomial(identity)
+success <- svyglm(Mate~mixed+RWvsWR, design=xsalamander,
+ family=quasi(link="identity", variance="mu(1-mu)"))
+summary(success)
+
These data are from Section 12.2 of Levy and Lemeshow. They describe
+(a possibly apocryphal) study of survival in out-of-hospital cardiac
+arrest. Two out of five ambulance stations were sampled from each of
+three emergency service areas.
+
+
+
+
Usage
+
+
data(scd)
+
+
+
Format
+
+
This data frame contains the following columns:
+
+
+
+
ESA
Emergency Service Area (strata)
+
+
ambulance
Ambulance station (PSU)
+
+
arrests
estimated number of cardiac arrests
+
+
alive
number reaching hospital alive
+
+
+
+
+
+
Source
+
+
Levy and Lemeshow. "Sampling of Populations" (3rd edition). Wiley.
+
+
+
+
Examples
+
+
data(scd)
+
+## survey design objects
+scddes<-svydesign(data=scd, prob=~1, id=~ambulance, strata=~ESA,
+nest=TRUE, fpc=rep(5,6))
+scdnofpc<-svydesign(data=scd, prob=~1, id=~ambulance, strata=~ESA,
+nest=TRUE)
+
+# convert to BRR replicate weights
+scd2brr <- as.svrepdesign(scdnofpc, type="BRR")
+# or to Rao-Wu bootstrap
+scd2boot <- as.svrepdesign(scdnofpc, type="subboot")
+
+# use BRR replicate weights from Levy and Lemeshow
+repweights<-2*cbind(c(1,0,1,0,1,0), c(1,0,0,1,0,1), c(0,1,1,0,0,1),
+c(0,1,0,1,1,0))
+scdrep<-svrepdesign(data=scd, type="BRR", repweights=repweights)
+
+# ratio estimates
+svyratio(~alive, ~arrests, design=scddes)
+svyratio(~alive, ~arrests, design=scdnofpc)
+svyratio(~alive, ~arrests, design=scd2brr)
+svyratio(~alive, ~arrests, design=scd2boot)
+svyratio(~alive, ~arrests, design=scdrep)
+
+# or a logistic regression
+summary(svyglm(cbind(alive,arrests-alive)~1, family=quasibinomial, design=scdnofpc))
+summary(svyglm(cbind(alive,arrests-alive)~1, family=quasibinomial, design=scdrep))
+
+# Because no sampling weights are given, can't compute design effects
+# without replacement: use deff="replace"
+
+svymean(~alive+arrests, scddes, deff=TRUE)
+svymean(~alive+arrests, scddes, deff="replace")
+
+
+
+
+
+
+
diff --git a/doc/survey/yrbs.html b/doc/survey/yrbs.html
new file mode 100644
index 0000000..6ea2925
--- /dev/null
+++ b/doc/survey/yrbs.html
@@ -0,0 +1,87 @@
+R: One variable from the Youth Risk Behaviors Survey, 2015.
+
+
+
+
+
+
+
+
+
yrbs
R Documentation
+
+
+One variable from the Youth Risk Behaviors Survey, 2015.
+
+
+
Description
+
+
Design information from the Youth Risk Behaviors Survey (YRBS), together
+with the single variable ‘Never/Rarely wore bike helmet’. Used as an
+analysis example by CDC.
+
+
+
+
Usage
+
+
data("yrbs")
+
+
+
Format
+
+
A data frame with 15624 observations on the following 4 variables.
+