Agriculture Reference
In-Depth Information
π
1
¼
X
s
'
ðÞ
pðÞ
¼1
=
9
þ
4
=
9
þ
3
=
9 ¼ 8
=
9
:
It is also possible to compute the second-order inclusion probability for the pair
(1,2),
π
12
¼
X
s
pðÞ
¼1
=
9
þ
4
=
9 ¼ 5
=
9
:
ðÞ
1
;
'
We can use the following
R
code to calculate the first- and second-order inclusion
probabilities for a certain sampling design.
>
set.seed(160964)
>
ps
<
- runif(nrow(indicator_matrix))+5
>
ps
<
- ps / sum(ps)
>
first_order
<
- colSums(indicator_matrix *ps)
>
second_order
<
- matrix(0,N,N)
>
for (i in 1:(N-1))
{
for (j in (i+1):N)
{
second_order[i,j]
<
- sum(indicator_matrix [,i]*
indicator_matrix [,j]*ps)
}
}
>
second_order
<
- second_order + t(second_order)
>
diag(second_order)
<
- first_order
>
first_order
[1] 0.5919065 0.6069048 0.6069510 0.5975452 0.5966925
>
second_order
[,1] [,2] [,3] [,4] [,5]
[1,] 0.5919065 0.2986742 0.2944651 0.2938064 0.2968673
[2,] 0.2986742 0.6069048 0.3079239 0.3113729 0.2958386
[3,] 0.2944651 0.3079239 0.6069510 0.3003725 0.3111405
[4,] 0.2938064 0.3113729 0.3003725 0.5975452 0.2895386
[5,] 0.2968673 0.2958386 0.3111405 0.2895386 0.5966925
The second row of the code concerns a sample design using
p
(
s
). If the
researcher chooses to use simple random sampling (i.e.,
p
(
s
) is constant), this line
can be replaced with:
>
ps
<
- rep(1/nrow(indicator_matrix),nrow(indicator_matrix)).
Search WWH ::
Custom Search