Agriculture Reference
In-Depth Information
If the aim is to calculate the direct HT estimates for all the SAs, we can use the
following code.
> domdir < - svyby(~yobs,~coddom,dsrs,svymean)
> domdir
coddom
yobs
se
11
11 80.12641 4.8138426
12
12 93.52410 3.9684518
13
13 74.28390 5.6532726
21
21 101.37026 4.5704614
22
22 119.01017 0.8044394
23
23 96.89364 4.2063243
31
31 78.69029 3.9254892
32
32 98.91292 5.6468604
33
33 83.37624 4.5737139
The first argument in svyby specifies the variables to be analyzed (i.e.,
~yobs), the second denotes the grouping variables that define the subpopulations
(i.e., ~coddom), the third is a svydesign object that identifies the sampling
design (i.e., dsrs), and the fourth identifies the analysis to be performed on each
subpopulation, in this case a sample mean (i.e., svymean). The output provides the
estimates and standard deviations (i.e., column se) for each SA.
The HT direct estimates for all the SAs can be also obtained with the sae
package using the following commands.
> dtab < - table(framepop$coddom)
> dsize < - as.data.frame(cbind(as.numeric(names(dtab)),dtab))
> colnames(dsize) < - c("coddom","Freq")
> domdirsae < - direct(y ¼ yobs,dom ¼ coddom, domsize ¼ dsize, data ¼ framesrs,
+
replace ¼ F)
> domdirsae
Domain SampSize
Direct
SD
CV
1
11
14
80.12641 4.9187668 6.138758
9
12
9
93.52410 4.2399097 4.533494
8
13
13
74.28390 5.7951789 7.801393
2
21
8
101.37026 4.9310622 4.864407
3
22
11
119.01017 0.8398941 0.705733
4
23
12
96.89364 4.3224972 4.461074
7
31
11
78.69029 4.0855991 5.191999
6
32
9
98.91292 6.0331281 6.099434
5
33
13
83.37624 4.7047441 5.642788
Note that the standard deviations of the direct estimates obtained with sae are
different from those calculated using survey. As stated in the help files of sae,
Search WWH ::




Custom Search