Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/survey/apiclus1.rda
Binary file not shown.
Binary file added data/survey/apiclus2.rda
Binary file not shown.
Binary file added data/survey/apipop.rda
Binary file not shown.
Binary file added data/survey/apisrs.rda
Binary file not shown.
Binary file added data/survey/apistrat.rda
Binary file not shown.
Binary file added data/survey/crowd.rda
Binary file not shown.
Binary file added data/survey/election.rda
Binary file not shown.
Binary file added data/survey/fpc.rda
Binary file not shown.
Binary file added data/survey/hospital.rda
Binary file not shown.
Binary file added data/survey/mu284.rda
Binary file not shown.
Binary file added data/survey/myco.rda
Binary file not shown.
Binary file added data/survey/nhanes.rda
Binary file not shown.
Binary file added data/survey/salamander.rda
Binary file not shown.
Binary file added data/survey/scd.rda
Binary file not shown.
Binary file added data/survey/yrbs.rda
Binary file not shown.
15 changes: 15 additions & 0 deletions doc/datasets.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/packages.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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"
81 changes: 81 additions & 0 deletions doc/survey/crowd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html><html><head><title>R: Household crowding</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
<script type="text/javascript">
const macros = { "\\R": "\\textsf{R}", "\\code": "\\texttt"};
function processMathHTML() {
var l = document.getElementsByClassName('reqn');
for (let e of l) { katex.render(e.textContent, e, { throwOnError: false, macros }); }
return;
}</script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"
onload="processMathHTML();"></script>
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body><div class="container"><main>

<table style="width: 100%;"><tr><td>crowd</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Household crowding</h2>

<h3>Description</h3>

<p>A tiny dataset from the VPLX manual.
</p>


<h3>Usage</h3>

<pre><code class='language-R'>data(crowd)</code></pre>


<h3>Format</h3>

<p>A data frame with 6 observations on the following 5 variables.
</p>

<dl>
<dt>rooms</dt><dd><p>Number of rooms in the house</p>
</dd>
<dt>person</dt><dd><p>Number of people in the household</p>
</dd>
<dt>weight</dt><dd><p>Sampling weight</p>
</dd>
<dt>cluster</dt><dd><p>Cluster number</p>
</dd>
<dt>stratum</dt><dd><p>Stratum number</p>
</dd>
</dl>



<h3>Source</h3>

<p>Manual for VPLX, Census Bureau.
</p>


<h3>Examples</h3>

<pre><code class='language-R'>data(crowd)

## Example 1-1
i1.1&lt;-as.svrepdesign(svydesign(id=~cluster, weight=~weight,data=crowd))
i1.1&lt;-update(i1.1, room.ratio=rooms/person,
overcrowded=factor(person&gt;rooms))
svymean(~rooms+person+room.ratio,i1.1)
svytotal(~rooms+person+room.ratio,i1.1)
svymean(~rooms+person+room.ratio,subset(i1.1,overcrowded==TRUE))
svytotal(~rooms+person+room.ratio,subset(i1.1,overcrowded==TRUE))

## Example 1-2
i1.2&lt;-as.svrepdesign(svydesign(id=~cluster,weight=~weight,strata=~stratum, data=crowd))
svymean(~rooms+person,i1.2)
svytotal(~rooms+person,i1.2)

</code></pre>

</main>

</div>
</body></html>
110 changes: 110 additions & 0 deletions doc/survey/election.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!DOCTYPE html><html><head><title>R: US 2004 presidential election data at state or county level</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
<script type="text/javascript">
const macros = { "\\R": "\\textsf{R}", "\\code": "\\texttt"};
function processMathHTML() {
var l = document.getElementsByClassName('reqn');
for (let e of l) { katex.render(e.textContent, e, { throwOnError: false, macros }); }
return;
}</script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"
onload="processMathHTML();"></script>
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body><div class="container"><main>

<table style="width: 100%;"><tr><td>election</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>US 2004 presidential election data at state or county level</h2>

<h3>Description</h3>

<p>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 &quot;sampling&quot; package.
</p>


<h3>Usage</h3>

<pre><code class='language-R'>data(election)</code></pre>


<h3>Format</h3>

<p><code>election</code> is a data frame with 4600 observations on the following 8 variables.
</p>

<dl>
<dt><code>County</code></dt><dd><p>A factor specifying the state or country</p>
</dd>
<dt><code>TotPrecincts</code></dt><dd><p>Number of precincts in the state or county</p>
</dd>
<dt><code>PrecinctsReporting</code></dt><dd><p>Number of precincts supplying data</p>
</dd>
<dt><code>Bush</code></dt><dd><p>Votes for George W. Bush</p>
</dd>
<dt><code>Kerry</code></dt><dd><p>Votes for John Kerry</p>
</dd>
<dt><code>Nader</code></dt><dd><p>Votes for Ralph Nader</p>
</dd>
<dt><code>votes</code></dt><dd><p>Total votes for those three candidates</p>
</dd>
<dt><code>p</code></dt><dd><p>Sampling probability, proportional to <code>votes</code></p>
</dd>
</dl>

<p><code>election_pps</code> is a sample of 40 counties or states taken with
probability proportional to the number of votes. It includes the
additional column <code>wt</code> with the sampling weights.
</p>
<p><code>election_insample</code> indicates which rows of <code>election</code> were sampled.
</p>
<p><code>election_jointprob</code> are the pairwise sampling probabilities and
<code>election_jointHR</code> are approximate pairwise sampling probabilities using
the Hartley-Rao approximation.
</p>


<h3>Source</h3>

<p>.
</p>


<h3>Examples</h3>

<pre><code class='language-R'>data(election)
## high positive correlation between totals
plot(Bush~Kerry,data=election,log="xy")
## high negative correlation between proportions
plot(I(Bush/votes)~I(Kerry/votes), data=election)

## Variances without replacement
## Horvitz-Thompson type
dpps_br&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps="brewer")
dpps_ov&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps="overton")
dpps_hr&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps=HR(sum(election$p^2)/40))
dpps_hr1&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps=HR())
dpps_ht&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps=ppsmat(election_jointprob))
## Yates-Grundy type
dpps_yg&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps=ppsmat(election_jointprob),variance="YG")
dpps_hryg&lt;- svydesign(id=~1, fpc=~p, data=election_pps, pps=HR(sum(election$p^2)/40),variance="YG")

## The with-replacement approximation
dppswr &lt;-svydesign(id=~1, probs=~p, data=election_pps)

svytotal(~Bush+Kerry+Nader, dpps_ht)
svytotal(~Bush+Kerry+Nader, dpps_yg)
svytotal(~Bush+Kerry+Nader, dpps_hr)
svytotal(~Bush+Kerry+Nader, dpps_hryg)
svytotal(~Bush+Kerry+Nader, dpps_hr1)
svytotal(~Bush+Kerry+Nader, dpps_br)
svytotal(~Bush+Kerry+Nader, dpps_ov)
svytotal(~Bush+Kerry+Nader, dppswr)
</code></pre>

</main>

</div>
</body></html>
112 changes: 112 additions & 0 deletions doc/survey/fpc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!DOCTYPE html><html><head><title>R: Small survey example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
<script type="text/javascript">
const macros = { "\\R": "\\textsf{R}", "\\code": "\\texttt"};
function processMathHTML() {
var l = document.getElementsByClassName('reqn');
for (let e of l) { katex.render(e.textContent, e, { throwOnError: false, macros }); }
return;
}</script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"
onload="processMathHTML();"></script>
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body><div class="container"><main>

<table style="width: 100%;"><tr><td>fpc</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Small survey example</h2>

<h3>Description</h3>

<p>The <code>fpc</code> data frame has 8 rows and 6 columns. It is artificial
data to illustrate survey sampling estimators.
</p>


<h3>Usage</h3>

<pre><code class='language-R'>data(fpc)</code></pre>


<h3>Format</h3>

<p>This data frame contains the following columns:
</p>

<dl>
<dt>stratid</dt><dd><p>Stratum ids</p>
</dd>
<dt>psuid</dt><dd><p>Sampling unit ids</p>
</dd>
<dt>weight</dt><dd><p>Sampling weights</p>
</dd>
<dt>nh</dt><dd><p>number sampled per stratum</p>
</dd>
<dt>Nh</dt><dd><p>population size per stratum</p>
</dd>
<dt>x</dt><dd><p>data</p>
</dd>
</dl>



<h3>Source</h3>

<p><code style="white-space: pre;">&#8288;https://www.stata-press.com/data/r7/fpc.dta&#8288;</code>
</p>


<h3>Examples</h3>

<pre><code class='language-R'>data(fpc)
fpc


withoutfpc&lt;-svydesign(weights=~weight, ids=~psuid, strata=~stratid, variables=~x,
data=fpc, nest=TRUE)

withoutfpc
svymean(~x, withoutfpc)

withfpc&lt;-svydesign(weights=~weight, ids=~psuid, strata=~stratid,
fpc=~Nh, variables=~x, data=fpc, nest=TRUE)

withfpc
svymean(~x, withfpc)

## Other equivalent forms
withfpc&lt;-svydesign(prob=~I(1/weight), ids=~psuid, strata=~stratid,
fpc=~Nh, variables=~x, data=fpc, nest=TRUE)

svymean(~x, withfpc)

withfpc&lt;-svydesign(weights=~weight, ids=~psuid, strata=~stratid,
fpc=~I(nh/Nh), variables=~x, data=fpc, nest=TRUE)

svymean(~x, withfpc)

withfpc&lt;-svydesign(weights=~weight, ids=~interaction(stratid,psuid),
strata=~stratid, fpc=~I(nh/Nh), variables=~x, data=fpc)

svymean(~x, withfpc)

withfpc&lt;-svydesign(ids=~psuid, strata=~stratid, fpc=~Nh,
variables=~x,data=fpc,nest=TRUE)

svymean(~x, withfpc)

withfpc&lt;-svydesign(ids=~psuid, strata=~stratid,
fpc=~I(nh/Nh), variables=~x, data=fpc, nest=TRUE)

svymean(~x, withfpc)



</code></pre>

</main>

</div>
</body></html>
Loading
Loading