as , , , uniformly over

advertisement
Supplementary material (Proofs and R Codes) to
Two-sample density-based empirical likelihood ratio tests based on paired
data, with application to a treatment study of Attention-Deficit/Hyperactivity
Disorder and Severe Mood Dysregulation
Albert Vexlera*†, Wan-Min Tsaia, Gregory Gurevichb and Jihnhee Yuaο€ 
S1:
Appendix A1.
Proof of proposition 1
A1.1 Proposed test 1
Consider the case of testing 𝐻0 vs. 𝐻𝐴1 (𝑑 = 1) in Proposition 1. Towards this end, we define
𝑛
1
𝑉𝑛∗1 π‘š = ∑𝑗=1
[log (𝑛
2π‘š
1 πœ‚π‘š,𝑗
) + log (1 −
π‘š+1
2𝑛1
𝑛
2
)] , 𝑉𝑛∗∗2π‘˜ = ∑𝑗=1
[log (𝑛
2π‘˜
2 πœ‘π‘˜,𝑗
π‘˜+1
) + log (1 − 2𝑛 )].
2
(A1.1.1)
𝐻
Then the proposed test statistic at (9), (𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴1
𝑛2 ), can be expressed as
𝐻
(𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴1
𝑛2 ) =
min
𝑛1 0.5+δ ≤π‘š≤𝑛1 1−δ
𝑛2 )−1 𝑉𝑛∗∗2 π‘˜ .
(𝑛1 + 𝑛2 )−1 𝑉𝑛∗1π‘š +
min
𝑛2 0.5+δ ≤π‘˜≤𝑛2 1−δ
(𝑛1 +
(A1.1.2)
We first investigate the first term of the right-hand side of the equation (A1.1.2). To this end, we define the
distribution function 𝑄(π‘₯) to be
𝑄(π‘₯) = (𝑛1 𝐹1 (π‘₯) + 𝑛2 𝐹2 (π‘₯))⁄(𝑛1 + 𝑛2 ),
where
𝐹1 (π‘₯) = (𝐹𝑍1 (π‘₯) + 1 − 𝐹𝑍1 (−π‘₯))⁄2 and 𝐹2 (π‘₯) = (𝐹𝑍2 (π‘₯) + 1 − 𝐹𝑍2 (−π‘₯))⁄2.
a
Department of Biostatisics, The State University of New York, Buffalo, NY 14214, U.S.A.
The Department of Industrial Engineering and Management, SCE- Shamoon College of Engineering, Beer-Sheva 84100, Israel
*
Correspondence to: Albert Vexler, Department of Biostatisics, The State University of New York, Buffalo, NY 14214, U.S.A.
†
Email: avexler@buffalo.edu
b
1
Also, an empirical distribution function is defined by
𝐺𝑛1 +𝑛2 (π‘₯) = (𝑛1 𝐺𝑛1 (π‘₯) + 𝑛2 𝐺𝑛2 (π‘₯))⁄(𝑛1 + 𝑛2 ),
where
𝑛1
𝐺𝑛1 (π‘₯) = (𝑛1
−1
𝑛1
∑ 𝐼(𝑍1𝑗 ≤ π‘₯) + 𝑛1
−1
∑ 𝐼(−𝑍1𝑗 ≤ π‘₯))⁄2
𝑗=1
𝑗=1
𝑛2
𝑛2
and
𝐺𝑛2 (π‘₯) = (𝑛2 −1 ∑ 𝐼(𝑍2𝑗 ≤ π‘₯) + 𝑛2 −1 ∑ 𝐼(−𝑍2𝑗 ≤ π‘₯))⁄2
𝑗=1
𝑗=1
are the empirical distribution functions based on observations 𝑍11 , … , 𝑍1𝑛1 and 𝑍21 , … , 𝑍2𝑛2 , respectively.
Consequently, the first term of 𝑉𝑛∗1π‘š in (A1.1.1) can be reformulated as
𝑛
𝑛
𝑗=1
𝑗=1
1
1
𝑛1 [𝐺𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) )]
1
2π‘š
1
∑ log (
)=−
∑ log (
)
𝑛1 + 𝑛2
𝑛1 πœ‚π‘š,𝑗
𝑛1 + 𝑛2
2π‘š
𝑛
1
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
1
=−
∑ log (
)
𝑛1 + 𝑛2
𝐹 (𝑍
) − 𝐹 (𝑍
)
1
𝑗=1
𝑛1
−𝑛
1
1 +𝑛2
1
1 (𝑗−π‘š)
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
1
+
∑ log (
𝑛1 + 𝑛2
𝐺
𝑗=1
1 (𝑗+π‘š)
)
(𝑍
)
−
𝐺
(𝑍
)
𝑛1 +𝑛2
1 (𝑗+π‘š)
𝑛1 +𝑛2
1 (𝑗−π‘š)
𝑛1 [𝐹1 (𝑍1 (𝑗+π‘š) )−𝐹1 (𝑍1 (𝑗−π‘š) )]
1
∑𝑛𝑗=1
π‘™π‘œπ‘” (
2π‘š
).
(A1.1.3)
The first term in the right-hand of the equation (A1.1.3) can be expressed as
𝑛
𝑛
1
1
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
1
1
∑ log (
)=
∑ log (
)
𝑛1 + 𝑛2
𝑛1 + 𝑛2
𝑍1 (𝑗+π‘š) − 𝑍1 (𝑗−π‘š)
𝐹 (𝑍
) − 𝐹 (𝑍
)
1
𝑗=1
−𝑛
1 (𝑗+π‘š)
1
1 (𝑗−π‘š)
𝑗=1
𝐹1 (𝑍1 (𝑗+π‘š) )−𝐹1 (𝑍1 (𝑗−π‘š) )
1
1 +𝑛2
1
∑𝑛𝑗=1
log (
𝑍1 (𝑗+π‘š) −𝑍1 (𝑗−π‘š)
).
(A1.1.4)
The result shown in Theorem 1 of Vasicek [29] leads to
1
𝑛1 +𝑛2
1
∑𝑛𝑗=1
log (
𝑄(𝑍1 (𝑗+π‘š) )−𝑄(𝑍1 (𝑗−π‘š) )
𝑍1 (𝑗+π‘š) −𝑍1 (𝑗−π‘š)
2
)=𝑛
𝑛1
1
1 +𝑛2 2π‘š
∑2π‘š
𝑑=1 𝑆𝑑 ,
(A1.1.5)
where
𝑛
1
𝑆𝑑 = ∑𝑗=1
log (
𝑄(𝑍1 (𝑗+π‘š) )−𝑄(𝑍1 (𝑗−π‘š) )
𝑍1 (𝑗+π‘š) −𝑍1 (𝑗−π‘š)
) (𝐹1 (𝑍1 (𝑗+π‘š) ) − 𝐹1 (𝑍1 (𝑗−π‘š) )) , 𝑗 ≡ 𝑑 (mod 2m).
Let 𝑓𝑖 (π‘₯) = 𝑑𝐹𝑖 (π‘₯)⁄𝑑π‘₯ = (𝑓𝑍𝑖 (π‘₯) + 𝑓𝑍𝑖 (−π‘₯))⁄2 , 𝑖 = 1, 2.
Suppose 𝑍1 (𝑗−π‘š) and 𝑍1 (𝑗+π‘š) is within an interval in which
π‘ž(π‘₯) = 𝑑𝑄(π‘₯)⁄𝑑π‘₯ = 𝑛1 𝑓1 (π‘₯)⁄(𝑛1 + 𝑛2 ) + 𝑛2 𝑓2 (π‘₯)⁄(𝑛1 + 𝑛2 )
is positive and continuous, then
π‘ž(𝑍𝑑′ ) =
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
𝑍1 (𝑗+π‘š) − 𝑍1 (𝑗−π‘š)
,
for some existing value 𝑍𝑑′ ∈ (𝑍1 (𝑗−π‘š) , 𝑍1 (𝑗+π‘š) ). (The assumption that π‘ž(π‘₯) is positive and continuous, when
π‘₯ ∈ (𝑍1 (𝑗−π‘š) , 𝑍1 (𝑗+π‘š) ), is used to simplify the proof and this condition can be excluded, for example, see the
proof scheme applied in [29].) It follows that 𝑆𝑑 can be written as
𝑛
1
𝑆𝑑 = ∑𝑗=1
log(π‘ž(𝑍𝑑′ )) (𝐹1 (𝑍1 (𝑗+π‘š) ) − 𝐹1 (𝑍1 (𝑗−π‘š) )) , 𝑗 ≡ 𝑑 (mod 2m).
Let us define a density function π‘žΜ…(π‘₯) that approximates π‘ž(π‘₯) as follows:
π‘žΜ… (π‘₯) = 𝛾𝑓1 (π‘₯)⁄(1 + 𝛾) + 𝑓2 (π‘₯)⁄(1 + 𝛾).
For each πœ€ > 0 and sufficiently large 𝑛1 and 𝑛2 ,
𝑛1 ⁄𝑛2 → 𝛾 so that we have (1 − πœ€)π‘žΜ… (π‘₯) ≤ π‘ž(π‘₯) ≤ (1 + πœ€)π‘žΜ… (π‘₯).
It follows that for sufficiently large 𝑛1 and 𝑛2 ,
𝑆𝑑,(−πœ€) ≤ 𝑆𝑑 ≤ 𝑆𝑑,πœ€ ,
𝑛
1
where 𝑆𝑑,(−πœ€) = ∑𝑗=1
log((1 − πœ€)π‘žΜ…(𝑍𝑑′ )) (𝐹1 (𝑍1 (𝑗+π‘š) ) − 𝐹1 (𝑍1 (𝑗−π‘š) )),
𝑛
1
and 𝑆𝑑,πœ€ = ∑𝑗=1
log((1 + πœ€)π‘žΜ… (𝑍𝑑′ )) (𝐹1 (𝑍1 (𝑗+π‘š) ) − 𝐹1 (𝑍1 (𝑗−π‘š) )).
i.e. 𝑆𝑑,(−πœ€) and 𝑆𝑑,πœ€ are Stieltjes sums of the function log((1 − πœ€)π‘žΜ… (𝑍11 )) and log((1 + πœ€)π‘žΜ…(𝑍11 )), respectively,
with respect to the measure 𝐹1 over the sum of intervals of continuity of 𝑓1 (π‘₯) and 𝑓2 (π‘₯) in which π‘žΜ…(π‘₯) > 0.
Since in any interval in which π‘žΜ…(π‘₯) is positive, 𝑍1 (𝑗+π‘š) − 𝑍1 (𝑗−π‘š) → 0 as 𝑛1 → ∞ uniformly over π‘š ∈
∞
[𝑛1 0.5+𝛿 , 𝑛11−𝛿 ], δ ∈ (0,1/4), and uniformly over 𝑍1 , 𝑆𝑑,(−πœ€) converges in probability to ∫−∞ log ((1 −
3
πœ€)π‘žΜ…(𝑍11 )) 𝑑𝑄(𝑍11 ) = 𝐸{log((1 − πœ€)π‘žΜ…(𝑍11 ))} as 𝑛1 → ∞. Furthermore, this convergence is uniformly over j
and 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0,1/4). Similarly, 𝑆𝑑,πœ€ converges in probability to 𝐸{log((1 + πœ€)π‘žΜ…(𝑍11 ))},
uniformly over j and 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0,1/4).
Therefore,
2π‘š
1
𝐸{log((1 − πœ€)π‘žΜ…(𝑍11 ))} ≤
∑ 𝑆𝑑 ≤ 𝐸{log((1 + πœ€)π‘žΜ…(𝑍11 ))},
2π‘š
𝑑=1
as 𝑛1 → ∞, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0,1/4).
Recalling from (A1.1.5), we find
𝑄(𝑍1 (𝑗+π‘š) )−𝑄(𝑍1 (𝑗−π‘š) )
𝑛
1
(𝑛1 + 𝑛2 )−1 ∑𝑗=1
log (
𝑍1 (𝑗+π‘š) −𝑍1 (𝑗−π‘š)
𝑃
𝛾
) → 1+𝛾 𝐸{log(π‘žΜ… (𝑍11 ))},
(A1.1.6)
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0,1/4).
Similarly, we have
𝐹1 (𝑍1 (𝑗+π‘š) )−𝐹1 (𝑍1 (𝑗−π‘š) )
𝑛
1
(𝑛1 + 𝑛2 )−1 ∑𝑗=1
log (
𝑍1 (𝑗+π‘š) −𝑍1 (𝑗−π‘š)
𝑃
𝛾
) → 1+𝛾 𝐸{log(𝑓1 (𝑍11 ))},
(A1.1.7)
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0, 1/4).
Combining the results of (A1.1.4), (A1.1.6), and (A1.1.7) yields
𝑛1
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
(𝑛1 + 𝑛2 )−1 ∑ log (
)
𝐹1 (𝑍1 (𝑗+π‘š) ) − 𝐹1 (𝑍1 (𝑗−π‘š) )
𝑗=1
𝑃
π‘žΜ…(𝑍 )
𝛾
𝛾
𝛾
1
𝑓 (𝑍 )
→ 1+𝛾 𝐸 (log (𝑓 (𝑍11 ))) = 1+𝛾 𝐸 log {1+𝛾 + 1+𝛾 (𝑓2 (𝑍11 ))},
1
11
1
11
(A1.1.8)
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0, 1/4).
Now, we consider the second term in the right-hand side of the equation (A1.1.3). By Theorem A in Serfling
[31], we know that for 0 ≤ πœ– ≤ 𝛿/2,
𝑛1 →∞
Pr ( sup |𝐹1 (π‘₯) − 𝐹𝑛1 (π‘₯)| > 𝑛1 −0.5+πœ– ) →
0,
−∞<π‘₯<∞
and
𝑛2 →∞
Pr ( sup |𝐹2 (π‘₯) − 𝐹𝑛2 (π‘₯)| > 𝑛2 −0.5+πœ– ) →
−∞<π‘₯<∞
4
0,
𝑛1 →∞,𝑛2 →∞,𝑛1 ⁄𝑛2 →𝛾
implying that Pr ( sup |𝐹2 (π‘₯) − 𝐹𝑛2 (π‘₯)| > (2𝑛1 /𝛾)−0.5+πœ– ) →
0.
−∞<π‘₯<∞
𝑛1 →∞,𝑛2 →∞
Hence, Pr ( sup |𝑄(π‘₯) − 𝐺𝑛1 +𝑛2 (π‘₯)| > 𝑛1 −0.5+2πœ– ) →
0, for 0 ≤ πœ– ≤ 𝛿/2.
−∞<π‘₯<∞
Now we consider the case when
sup |𝑄(π‘₯) − 𝐺𝑛1 +𝑛2 (π‘₯)| ≤ 𝑛1 −0.5+2πœ– . According to the definition of
−∞<π‘₯<∞
𝐺𝑛1 +𝑛2 (π‘₯), we have the inequality
𝐺𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) ) ≥ 𝑛1 (𝑛1 + 𝑛2 )−1 2π‘š(𝑛1 )−1 = 2π‘š/(𝑛1 + 𝑛2 ).
Thus, for the case of
sup |𝑄(π‘₯) − 𝐺𝑛1 +𝑛2 (π‘₯)| ≤ 𝑛1 −0.5+2πœ– , we have
−∞<π‘₯<∞
𝑛1
1
∑ log (
𝑛1 + 𝑛2
𝐺
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) )
𝑗=1
)
𝑛
1
𝐺𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) ) + 𝑛1 −0.5+𝛿/2
1
≤
∑ log (
)
𝑛1 + 𝑛2
𝐺
(𝑍
)−𝐺
(𝑍
)
𝑗=1
𝑛1 +𝑛2
1 (𝑗+π‘š)
𝑛1 +𝑛2
𝛿
𝑛1
1 (𝑗−π‘š)
𝑛1
1
𝑛1 −0.5+2
1
𝑛1 −0.5+𝛿/2
1
≤
∑ log (1 +
)≤
∑(
)=
→ 0,
0.5+𝛿
𝑛1 + 𝑛2
2π‘š/(𝑛1 + 𝑛2 )
𝑛1 + 𝑛2
2𝑛1
/(𝑛1 + 𝑛2 )
2𝑛1 𝛿/2
𝑗=1
𝑗=1
for a sufficiently large 𝑛1 and π‘š ∈ [𝑛1 0.5+𝛿 , 𝑛11−𝛿 ].
Also, note that
𝑛1
𝑄 (𝑍1 (𝑗+π‘š) ) − 𝑄 (𝑍1 (𝑗−π‘š) )
1
∑ log (
𝑛1 + 𝑛2
𝐺
𝑗=1
𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) )
)
𝑛
1
𝐺𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) ) − 𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) ) − 𝑛1 −0.5+𝛿/2
1
≥
∑ log (
)
𝑛1 + 𝑛2
𝐺
(𝑍
)−𝐺
(𝑍
)
𝑗=1
𝑛1
𝑛1 +𝑛2
1 (𝑗+π‘š)
𝑛1 +𝑛2
𝛿
1 (𝑗−π‘š)
𝑛1
1
𝑛1 −0.5+2
1
2𝑛1 −0.5+𝛿/2
1
≥
∑ log (1 −
) ≥−
∑(
) = − 𝛿/2 → 0,
0.5+𝛿
𝑛1 + 𝑛2
2π‘š/(𝑛1 + 𝑛2 )
𝑛1 + 𝑛2
𝑛1
2𝑛1
/(𝑛1 + 𝑛2 )
𝑗=1
𝑗=1
5
for a sufficiently large 𝑛1 and π‘š ∈ [𝑛1 0.5+𝛿 , 𝑛11−𝛿 ]. Hence, we prove that the second term in the right-hand side
of the equality (A1.1.3) converges to zero in probability. That is,
1
𝑛1 +𝑛2
𝑃
𝑄(𝑍1 (𝑗+π‘š) )−𝑄(𝑍1 (𝑗−π‘š) )
1
∑𝑛𝑗=1
log (
𝐺𝑛1 +𝑛2 (𝑍1 (𝑗+π‘š) )−𝐺𝑛1 +𝑛2 (𝑍1 (𝑗−π‘š) )
) → 0,
(A1.1.9)
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ .
Finally, using the result of Lemma 1 of Vasicek [29], the last term in the right-hand side of the equality of
(A1.1.3) also converges to zero in probability. That is,
𝑛1 [𝐹1 (𝑍1 (𝑗+π‘š) )−𝐹1 (𝑍1 (𝑗−π‘š) )]
𝑛
1
−(𝑛1 + 𝑛2 )−1 ∑𝑗=1
log (
2π‘š
𝑃
) → 0,
(A1.1.10)
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0,1/4).
By (A1.1.8), (A1.1.9), and (A1.1.10), we show that
𝑃
(𝑛1 + 𝑛2 )−1 𝑉𝑛∗1 π‘š → −
𝛾
1+𝛾
𝛾
1
𝑓 (𝑍 )
𝐸 log {1+𝛾 + 1+𝛾 (𝑓2 (𝑍11 ))},
1
11
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛1 0.5+δ ≤ π‘š ≤ 𝑛11−δ , δ ∈ (0, 1/4).
Likewise, following the same procedure as shown in the proof of 𝑉𝑛∗1 π‘š , we have
𝑛2
(𝑛1 + 𝑛2 )−1 𝑉𝑛∗∗2 π‘˜ = (𝑛1 + 𝑛2 )−1 ∑ [log (
𝑗=1
−
2π‘˜
π‘˜+1 𝑃
) + log (1 −
)] →
𝑛2 πœ‘π‘˜,𝑗
2𝑛2
1
𝛾
𝑓1 (𝑍21 )
1
𝐸 log {
(
)+
},
1+𝛾
1 + 𝛾 𝑓2 (𝑍21 )
1+𝛾
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0, uniformly over 𝑛2 0.5+δ ≤ π‘˜ ≤ 𝑛21−δ , δ ∈ (0,1/4).
This and (A1.1.11) conclude that
𝑝
𝐻
(𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴1
𝑛2 ) → −
−
𝛾
𝛾
1
𝑓2 (𝑍11 )
𝐸 log {
+
(
)}
1+𝛾
1 + 𝛾 1 + 𝛾 𝑓1 (𝑍11 )
1
𝛾
𝑓1 (𝑍21 )
1
𝐸 log {
(
)+
},
1+𝛾
1 + 𝛾 𝑓2 (𝑍21 )
1+𝛾
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0.
Hence, under 𝐻0 ,
6
(A1.1.11)
𝑓2 (𝑍11 ) (𝑓𝑍2 (𝑍11 ) + 𝑓𝑍2 (−𝑍11 ))⁄2 𝑓𝑍2 (𝑍11 )
=
=
,
𝑓1 (𝑍11 ) (𝑓 (𝑍 ) + 𝑓 (−𝑍 ))⁄2 𝑓𝑍1 (𝑍11 )
𝑍1
11
𝑍1
11
𝑓1 (𝑍21 ) (𝑓𝑍1 (𝑍21 ) + 𝑓𝑍1 (−𝑍21 ))⁄2 𝑓𝑍1 (𝑍21 )
=
=
,
𝑓2 (𝑍21 ) (𝑓 (𝑍 ) + 𝑓 (−𝑍 ))⁄2 𝑓𝑍2 (𝑍21 )
𝑍2
21
𝑍2
𝑝
𝐻
(𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴1
𝑛2 ) → −
−
21
𝑓𝑍 (𝑍11 )
𝛾
𝛾
1
𝐸𝐻0 log {
+
( 2
)}
1+𝛾
1 + 𝛾 1 + 𝛾 𝑓𝑍1 (𝑍11 )
𝑓𝑍 (𝑍21 )
1
𝛾
1
𝐸𝐻0 log {
( 1
)+
} = 0,
1+𝛾
1 + 𝛾 𝑓𝑍2 (𝑍21 )
1+𝛾
and under 𝐻𝐴1 ,
𝐻
𝑝
(𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴1
𝑛2 ) → −
−
≥−
𝛾
𝛾
1
𝑓2 (𝑍11 )
𝐸𝐻𝐴1 log {
+
(
)}
1+𝛾
1 + 𝛾 1 + 𝛾 𝑓1 (𝑍11 )
1
𝛾
𝑓1 (𝑍21 )
1
𝐸𝐻𝐴1 log {
(
)+
}
1+𝛾
1 + 𝛾 𝑓2 (𝑍21 )
1+𝛾
𝛾
𝛾
1
𝑓2 (𝑍11 )
1
𝛾
𝑓1 (𝑍21 )
1
log {
+
𝐸𝐻𝐴1 (
)} −
log {
𝐸𝐻𝐴1 (
)+
}
1+𝛾
1+𝛾 1+𝛾
𝑓1 (𝑍11 )
1+𝛾
1+𝛾
𝑓2 (𝑍21 )
1+𝛾
≥ 0, as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0.
We complete the proof of Proposition 1 for the case of 𝑑 = 1, i.e. the consistency related to the proposed Test 1.
A1.2 Proposed test 2
Here, we will consider the case of 𝑑 = 2. That is, we will show that
𝐻
𝑝
(𝑛1 + 𝑛2 )−1 log(𝑉𝑛1𝐴2
𝑛2 ) → −
−
𝛾
𝛾
1
𝑓2 (𝑍11 )
𝐸 log {
+
(
)}
1+𝛾
1 + 𝛾 1 + 𝛾 𝑓1 (𝑍11 )
1
𝛾
𝑓1 (𝑍21 )
1
𝐸 log {
(
)+
},
1+𝛾
1 + 𝛾 𝑓2 (𝑍21 )
1+𝛾
as 𝑛1 → ∞, 𝑛2 → ∞, 𝑛1 ⁄𝑛2 → 𝛾 > 0.
𝑝
It is clear that if one can show that log(π›¬π‘˜π‘›2 ) → 0 as 𝑛2 → ∞, where π›¬π‘˜π‘›2 is defined by (12), the rest of the proof
𝐻
is similar to the proof shown in Section A1.1 regarding the test statistic of the proposed Test 1, log(𝑉𝑛1𝐴1
𝑛2 ). To
consider log(π›¬π‘˜π‘›2 ), as 𝑛2 → ∞, we begin with a proof that
7
𝑛2
1
𝐹̃𝑍2 (𝑍2 (𝑛2 ) ) − 𝐹̃𝑍2 (𝑍2 (1) ) =
∑ [𝐼 (𝑍2𝑗 ≤ 𝑍2 (𝑛2 ) ) + 𝐼 (−𝑍2𝑗 ≤ 𝑍2 (𝑛2 ) )]
2𝑛2
𝑗=1
𝑛2
−
𝑝
1
∑ [𝐼 (𝑍2𝑗 ≤ 𝑍2 (1) ) + 𝐼 (−𝑍2𝑗 ≤ 𝑍2 (1) )] → 1, as 𝑛2 → ∞.
2𝑛2
𝑗=1
To this end, we apply Theorem A of Serfling [31], having that for πœ– ∈ (0, 1/2),
sup |𝐹̃𝑍2 (𝑒) − 𝐹𝑍2 (𝑒)| = π‘œ(𝑛2 −0.5+πœ– ) as 𝑛2 → ∞.
−∞<𝑒<∞
Thus, 𝐹̃𝑍2 (𝑍2 (𝑛2 ) ) − 𝐹̃𝑍2 (𝑍2 (1) ) = 𝐹𝑍2 (𝑍2 (𝑛2 ) ) − 𝐹𝑍2 (𝑍2 (1) ) + π‘œ(𝑛2 −0.5+πœ– ).
It is obvious that 𝐹𝑍2 (𝑍2 (𝑛2 ) ) → 1 and 𝐹𝑍2 (𝑍2 (1) ) → 0 as 𝑛2 → ∞.
Hence,
𝑝
𝐹̃𝑍2 (𝑍2 (𝑛2 ) ) − 𝐹̃𝑍2 (𝑍2 (1) ) → 1 as 𝑛2 → ∞.
(A1.2.1)
𝑝
𝑛2
−1
Μƒ
Μƒ
Next, we will show that the part of π›¬π‘˜π‘›2 , ∑π‘˜−1
π‘Ÿ=1 (2π‘˜) (π‘˜ − π‘Ÿ) ∑𝑗=1 [𝐹𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹𝑍2 (𝑍2 (π‘Ÿ) )] → 0 as 𝑛2 → ∞.
Let 𝐹̃−𝑍2 (𝑒) denote the empirical distribution function of
−𝑍2 distributed with (1 − 𝐹𝑍2 (−𝑒)) (Here the symmetry of Z2 distribution under 𝐻0 and 𝐻𝐴2 is used). Then
π‘˜−1
∑
π‘Ÿ=1
(π‘˜ − π‘Ÿ)
[𝐹̃𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹̃𝑍2 (𝑍2 (π‘Ÿ) )]
2π‘˜
π‘˜−1
𝑛2
π‘Ÿ=1
𝑗=1
(π‘˜ − π‘Ÿ)
1
=
∑
∑ [𝐼 (𝑍2𝑗 ≤ 𝑍2 (π‘Ÿ+1) ) + 𝐼 (−𝑍2𝑗 ≤ 𝑍2 (π‘Ÿ+1) ) − 𝐼 (𝑍2𝑗 ≤ 𝑍2 (π‘Ÿ) ) − 𝐼 (−𝑍2𝑗 ≤ 𝑍2 (π‘Ÿ) )]
2𝑛2
2π‘˜
=
(π‘˜−π‘Ÿ)
4𝑛2
+ ∑π‘˜−1
π‘Ÿ=1
(π‘˜−π‘Ÿ)
2π‘˜
[𝐹̃−𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹̃−𝑍2 (𝑍2 (π‘Ÿ) )].
(A1.2.2)
Since the first term of (A1.2.2), (4𝑛2 )−1 (π‘˜ − π‘Ÿ), vanishes to zero as 𝑛2 → ∞, we focus on the remaining terms
of the equation (A1.2.2), which can be reorganized as follows:
π‘˜−1
π‘˜−1
π‘Ÿ=1
π‘Ÿ=1
(π‘˜ − π‘Ÿ)
(π‘˜ − (π‘Ÿ − 1))
π‘˜
∑
[𝐹̃−𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹̃−𝑍2 (𝑍2 (π‘Ÿ) )] = ∑
𝐹̃−𝑍2 (𝑍2 (π‘Ÿ) ) −
𝐹̃ (𝑍 )
2π‘˜
2π‘˜
2π‘˜ −𝑍2 2 (1)
π‘˜−1
(π‘˜ − π‘Ÿ)
(π‘˜ − (π‘˜ − 1))
+
𝐹̃−𝑍2 (𝑍2 (π‘˜) ) − ∑
𝐹̃−𝑍2 (𝑍2 (π‘Ÿ) )
2π‘˜
2π‘˜
π‘Ÿ=1
1
1
1
Μƒ
Μƒ
Μƒ
= 2π‘˜ ∑π‘˜−1
π‘Ÿ=1 𝐹−𝑍2 (𝑍2 (π‘Ÿ) ) − 2 𝐹−𝑍2 (𝑍2 (1) ) + 2π‘˜ 𝐹−𝑍2 (𝑍2 (π‘˜) ).
8
(A1.2.3)
In respect to the empirical distribution function, 𝐹̃−𝑍2 (𝑒), appeared in (A1.2.3), again by virtue of Theorem A of
Serfling [31], we have that for πœ– ∈ (0, 1/2),
π‘˜−1
∑
π‘Ÿ=1
1
(π‘˜ − π‘Ÿ)
[𝐹̃−𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹̃−𝑍2 (𝑍2 (π‘Ÿ) )]
2π‘˜
1
1
−0.5+πœ– ).
= 2π‘˜ ∑π‘˜−1
π‘Ÿ=1 𝐹−𝑍2 (𝑍2 (π‘Ÿ) ) − 2 𝐹−𝑍2 (𝑍2 (1) ) + 2π‘˜ 𝐹−𝑍2 (𝑍2 (π‘˜) ) + π‘œ(𝑛2
(A1.2.4)
Clearly, 𝐹−𝑍2 (𝑍2 (1) )⁄2 → 0 and 𝐹−𝑍2 (𝑍2 (π‘˜) )⁄2π‘˜ → 0 as 𝑛2 → ∞. Now, we prove that the first item of
(A1.2.4) converges to zero in probability as 𝑛2 → ∞.
Since the distribution of 𝑍21 , … , 𝑍2𝑛2 is symmetric under 𝐻0 and the statistic, π›¬π‘˜π‘›2 , is based on 𝐼 (−𝑍2𝑗 ≤ 𝑍2 (π‘Ÿ) )
under 𝐻0 and 𝐻𝐴2 , the distribution of 𝑍21 , … , 𝑍2𝑛2 can be taken as the uniform distribution on the interval [-1,
1]. Thus, we obtain 𝐹−𝑍2 (𝑍2 (π‘Ÿ) ) = (1 + 𝑍2 (π‘Ÿ) )⁄2, where π‘ˆ(π‘Ÿ) = (1 + 𝑍2 (π‘Ÿ) )⁄2 is the rth order statistic based on
a standard uniformly distributed, Unif[0,1], random variable. Since
π‘˜−1
𝐸 {(2π‘˜)−1 ∑ π‘ˆ(π‘Ÿ) } =
π‘Ÿ=1
π‘˜(π‘˜ − 1)
→ 0, as 𝑛2 → ∞,
4π‘˜(𝑛2 + 1)
𝑝
applying the Chebyshev's inequality yields (2π‘˜)−1 ∑π‘˜−1
π‘Ÿ=1 π‘ˆ(π‘Ÿ) → 0 as 𝑛2 → ∞.
Combining (A1.2.2)-( A1.2.4), we conclude that
∑π‘˜−1
π‘Ÿ=1
(π‘˜−π‘Ÿ)
2π‘˜
𝑝
[𝐹̃𝑍2 (𝑍2 (π‘Ÿ+1) ) − 𝐹̃𝑍2 (𝑍2 (π‘Ÿ) )] → 0 as 𝑛2 → ∞.
(A1.2.5)
Similarly, one can show that
∑π‘˜−1
π‘Ÿ=1
(π‘˜−π‘Ÿ)
2π‘˜
𝑝
[𝐹̃𝑍2 (𝑍2 (𝑛2 −π‘Ÿ+1) ) − 𝐹̃𝑍2 (𝑍2 (𝑛2 −π‘Ÿ) )] → 0 as 𝑛2 → ∞.
(A1.2.6)
𝑝
The results of (A1.2.1), (A1.2.5), and (A1.2.6) complete the proof of log(π›¬π‘˜π‘›2 ) → 0 as 𝑛2 → ∞.
A2. Mathematical derivation of maximum likelihood ratio tests
A2.1 Maximum likelihood ratio test statistic for Test 1
Assume 𝑍𝑖𝑗 ~𝑖. 𝑖. 𝑑. 𝑁(πœ‡π‘π‘– , πœŽπ‘2𝑖 ), where πœ‡π‘π‘– and πœŽπ‘2𝑖 , 𝑖 =1,2, are unknown. The following null hypothesis, 𝐻0𝑀𝐿𝑅 ,
is equivalent to the null hypothesis, 𝐻0 , that presented in the article
𝐻0𝑀𝐿𝑅 : πœ‡π‘1 = πœ‡π‘2 = 0; πœŽπ‘21 = πœŽπ‘22 = 𝜎 2 .
Hence, the corresponding hypothesis of interest for Test 1 using the maximum likelihood ratio test is 𝐻0𝑀𝐿𝑅
vs. 𝐻1𝑀𝐿𝑅 : not 𝐻0𝑀𝐿𝑅 . Under normal assumptions, the MLR test statistic is given by
9
𝑛1
max ∏𝑗=1
(2πœ‹πœŽπ‘21 )
𝑀𝐿𝑅𝐴1 =
−1⁄2 −
πœ‡π‘1 , πœŽπ‘21
𝑒
(𝑍1𝑗 −πœ‡π‘1 )2
2πœŽπ‘21
𝑛2
max ∏𝑗=1
(2πœ‹πœŽπ‘22 )
πœ‡π‘2 , πœŽπ‘22
2
𝑍1𝑗
− 2
𝑛1
⁄
2
−1
2
∏𝑗=1(2πœ‹πœŽ )
max
𝑒 2𝜎
𝜎2
=
−1⁄2 −
𝑒
(𝑍2𝑗 −πœ‡π‘2 )2
2πœŽπ‘22
2
𝑍2𝑗
− 2
𝑛2
⁄
2
−1
2
∏𝑗=1(2πœ‹πœŽ )
𝑒 2𝜎
(2πœ‹πœŽΜ‚π‘21 )−𝑛1⁄2 (2πœ‹πœŽΜ‚π‘22 )−𝑛2⁄2 𝑒 −(𝑛1 +𝑛2 )⁄2
(2πœ‹πœŽΜ‚ 2 )−(𝑛1 +𝑛2 )⁄2 𝑒 −(𝑛1 +𝑛2 )⁄2
=
(πœŽΜ‚π‘21 )−𝑛1⁄2 (πœŽΜ‚π‘22 )−𝑛2⁄2
(πœŽΜ‚ 2 )−(𝑛1 +𝑛2 )⁄2
,
where the associated maximum likelihood estimators (MLEs) of πœ‡π‘1 , πœ‡π‘2 , πœŽπ‘21 , πœŽπ‘22 , and 𝜎 2 are πœ‡Μ‚ 𝑍1 =
𝑛2
𝑛1
𝑛2
1
∑𝑛𝑗=1
𝑍1𝑗 ⁄𝑛1 = 𝑍1Μ… , πœ‡Μ‚ 𝑍2 = ∑𝑗=1
𝑍2𝑗 ⁄𝑛2 = 𝑍̅2 , πœŽΜ‚π‘21 = ∑𝑗=1
(𝑍1𝑗 − 𝑍1Μ… )2⁄𝑛1 , πœŽΜ‚π‘22 = ∑𝑗=1
(𝑍2𝑗 − 𝑍̅2 )2⁄𝑛2 , and
𝑛
𝑖
πœŽΜ‚ 2 = ∑2𝑖=1 ∑𝑗=1
𝑍𝑖𝑗 2 ⁄(𝑛1 + 𝑛2 ), respectively.
A2.2 Maximum likelihood ratio test statistic for Test 2
Under the assumption that 𝑍𝑖𝑗 ~𝑖. 𝑖. 𝑑. 𝑁(πœ‡π‘π‘– , πœŽπ‘2𝑖 ), where πœ‡π‘π‘– and πœŽπ‘2𝑖 , 𝑖 =1,2, are unknown, the hypotheses 𝐻0
vs. 𝐻𝐴2 are equivalent to the following hypotheses:
𝐻0𝑀𝐿𝑅 vs. 𝐻𝐴𝑀𝐿𝑅
: πœ‡π‘1 ≠ 0, πœ‡π‘2 = 0; πœŽπ‘21 ≠ πœŽπ‘22 .
2
Thus, the maximum likelihood ratio for Test 2 can be formulated by
𝑛1
max ∏𝑗=1
(2πœ‹πœŽπ‘21 )
𝑀𝐿𝑅𝐴2 =
−1⁄2 −
πœ‡π‘1 , πœŽπ‘21
𝑒
(𝑍1𝑗 −πœ‡π‘1 )2
2πœŽπ‘21
2
𝑍1𝑗
− 2
𝑛1
⁄
2
−1
2
∏𝑗=1(2πœ‹πœŽ )
max
𝑒 2𝜎
𝜎2
2
𝑍2𝑗
− 2
⁄
−1
2
2
∏𝑛𝑗=1
max
(2πœ‹πœŽπ‘22 )
𝑒 2πœŽπ‘2
πœŽπ‘22
2
𝑍2𝑗
− 2
𝑛2
⁄
2
−1
2
∏𝑗=1(2πœ‹πœŽ )
𝑒 2𝜎
.
Substituting the associated MLEs of πœ‡π‘1 , πœŽπ‘21 , and 𝜎 2 into the above likelihood ratio, 𝑀𝐿𝑅𝐴2 , yields the
following maximum likelihood ratio test statistic for Test 2:
𝑀𝐿𝑅𝐴2 = (πœŽΜ‚π‘21 )−𝑛1 ⁄2 (πœŽΜ‚π‘22 )−𝑛2 ⁄2 (πœŽΜ‚ 2 )(𝑛1 +𝑛2 )⁄2
𝑛
𝑛
𝑛
2
1
1
2
⁄𝑛2 and πœŽΜ‚ 2 =
where πœ‡Μ‚ 𝑍1 = ∑𝑗=1
𝑍1𝑗 ⁄𝑛1 = 𝑍1Μ… , πœŽΜ‚π‘21 = ∑𝑗=1
(𝑍1𝑗 − 𝑍1Μ… )2⁄𝑛1 , πœŽΜ‚π‘22 = ∑𝑗=1
𝑍2𝑗
𝑖
∑2𝑖=1 ∑𝑛𝑗=1
𝑍𝑖𝑗 2 ⁄(𝑛1 + 𝑛2 ).
A2.3 Maximum likelihood ratio test statistic for the Test 3
Assume 𝑍𝑖𝑗 ~𝑖. 𝑖. 𝑑. 𝑁(πœ‡π‘π‘– , πœŽπ‘2𝑖 ), where πœ‡π‘π‘– and πœŽπ‘2𝑖 , 𝑖 =1,2, are unknown. The hypotheses: 𝐻0 vs. 𝐻𝐴3 are
equivalent to the following hypotheses:
𝐻0𝑀𝐿𝑅 vs. 𝐻𝐴𝑀𝐿𝑅
: πœ‡π‘1 = πœ‡π‘2 = πœ‡1 ≠ 0; πœŽπ‘21 = πœŽπ‘22 = 𝜎12 .
3
Accordingly, the corresponding MLR test statistic is
10
𝑀𝐿𝑅𝐴3 =
−
𝑛1
(2πœ‹πœŽ12 )−1⁄2 𝑒
max2 ∏𝑗=1
πœ‡1 ,𝜎1
(𝑍1𝑗 −πœ‡1 )2
2𝜎12
2
𝑍1𝑗
−
𝑛1
∏𝑗=1(2πœ‹πœŽ 2 )−1⁄2 𝑒 2𝜎2
max
𝜎2
−
2
∏𝑛𝑗=1
(2πœ‹πœŽ12 )−1⁄2 𝑒
(𝑍2𝑗 −πœ‡1 )2
2𝜎12
2
𝑍2𝑗
−
𝑛2
∏𝑗=1(2πœ‹πœŽ 2 )−1⁄2 𝑒 2𝜎2
.
Replacing the parameters of πœ‡1 , 𝜎12 , and 𝜎 2 by their MLEs, the following maximum likelihood ratio test statistic
for the Test 3 can be formulated by
𝑀𝐿𝑅𝐴3 = (πœŽΜ‚12 ⁄πœŽΜ‚ 2 )−(𝑛1 +𝑛2 )⁄2 ,
𝑛𝑖
𝑛𝑖
where πœ‡Μ‚ 1 = ∑2𝑖=1 ∑𝑗=1
𝑍𝑖𝑗 ⁄(𝑛1 + 𝑛2 ) = 𝑍̅, πœŽΜ‚12 = ∑2𝑖=1 ∑𝑗=1
(𝑍𝑖𝑗 − 𝑍̅)2⁄(𝑛1 + 𝑛2 ), and πœŽΜ‚ 2 =
𝑖
∑2𝑖=1 ∑𝑛𝑗=1
𝑍𝑖𝑗 2 ⁄(𝑛1 + 𝑛2 ).
S2: R Codes applied to the Monte Carlo Simulations.
###################################
############## Test 1 #############
###################################
#The next codes present computations of the test-1-statistic (9)
# number of the Monte Carlo iterations
k<-50000
# sample sizes
n1<-10
n2<-10
# delta value used in the definitions (7) and (8)
delta<-0.1
# Storage for the values of the proposed test statistic
EntrF<-array()
for(i in 1:k)
{
#generation of Sample 1 (paired data z1)
z1<-rnorm(n1,0,1)
#generation of Sample 2 (paired data z2)
z2<-rnorm(n2,0,1)
z<-c(z1,z2)
# combination of the samples, called z
sz1<-sort(z1)
sz2<-sort(z2)
sz<-sort(z)
# sorting of the generated paired data z1
# sorting of the generated paired data z2
# sorting of the combined sample z
# density-based test statistic (log of eq. (7)) based on Sample 1 (z1)
11
LogM<-array()
# loop for each value of m
for(m in round(n1^(delta+0.5)):min(c(round((n1)^(1-delta)),round(n1/2))))
{
Log<-0
for(j in 1:n1)
{
D<-1*(j-m<1)+(j-m)*(j-m>=1)
U<-n1*(j+m>n1)+(j+m)*(j+m<=n1)
Uz<-length(sz[sz<=sz1[U]])+length(sz[-sz<=sz1[U]])
Dz<-length(sz[sz<=sz1[D]])+length(sz[-sz<=sz1[D]])
Delt<-(Uz-Dz)/(2*(n1+n2))
#Similarly to Canner (J.Am.Stat.Assoc. 70, 209-211(1975)), we will
#arbitrarily define Delt=1/(n1+n2), if Uz=Dz
if (Delt==0) Delt<-1/(n1+n2)
Log<-Log-2*log(n1)-log(Delt)+log(m)+log(2*n1-m-1)
}
LogM[m-round(n1^(delta+0.5))+1]<-Log
}
EntrF[i]<-min(LogM)
# density-based test statistic (log of eq. (8)) based on Sample 2 (z2)
LogM<-array()
for(m in round(n2^(delta+0.5)):min(c(round((n2)^(1-delta)),round(n2/2))))
# loop for each value of m
{
Log<-0
for(j in 1:n2)
{
D<-1*(j-m<1)+(j-m)*(j-m>=1)
U<-n2*(j+m>n2)+(j+m)*(j+m<=n2)
Uz<-length(sz[sz<=sz2[U]])+length(sz[-sz<=sz2[U]])
Dz<-length(sz[sz<=sz2[D]])+length(sz[-sz<=sz2[D]])
Delt<-(Uz-Dz)/(2*(n1+n2))
if (Delt==0) Delt<-1/(n1+n2)
Log<-Log-2*log(n2)-log(Delt)+log(m)+log(2*n2-m-1)
}
LogM[m-round(n2^(delta+0.5))+1]<-Log
}
EntrF[i]<-min(LogM)+EntrF[i]
# the proposed test statistic
}#end of the MC repetitions
### Calculate critical values of the density-based EL test statistic (9)
### for Test 1 #####
quantile(EntrF, 0.99) # alpha=0.01
quantile(EntrF, 0.95) # alpha=0.05
quantile(EntrF, 0.9) # alpha=0.1
12
###################################
############## Test 2 #############
###################################
#The next codes present computations of the test-2-statistic
#based on arrays sz, sz1, sz2 mentioned above.
#Density-based test statistic based on Sample 1 (log of eq. (10))
LogM<-array()
for(m in round(n1^(delta+0.5)):min(c(round((n1)^(1-delta)),round(n1/2))))
#loop for each value of m
{
Log<-0
for(j in 1:n1)
{
D<-1*(j-m<1)+(j-m)*(j-m>=1)
U<-n1*(j+m>n1)+(j+m)*(j+m<=n1)
Uz<-length(sz[sz<=sz1[U]])+length(sz[-sz<=sz1[U]])
Dz<-length(sz[sz<=sz1[D]])+length(sz[-sz<=sz1[D]])
Delt<-(Uz-Dz)/(2*(n1+n2))
if (Delt==0) Delt<-1/(n1+n2)
Log<-Log-2*log(n1)-log(Delt)+log(m)+log(2*n1-m-1)
}
LogM[m-round(n1^(delta+0.5))+1]<-Log
}
EntrF[i]<-min(LogM) #here “i” is Monte Carlo index
#density-based test statistic based on Sample 2
LogM<-array()
for(m in round(n2^(delta+0.5)):min(c(round((n2)^(1-delta)),round(n2/2))))
# loop for each value of m
{
Log<-0
for(j in 1:n2)
{
D<-1*(j-m<1)+(j-m)*(j-m>=1)
U<-n2*(j+m>n2)+(j+m)*(j+m<=n2)
Uz<-length(sz[sz<=sz2[U]])+length(sz[-sz<=sz2[U]])
Dz<-length(sz[sz<=sz2[D]])+length(sz[-sz<=sz2[D]])
Delt<-(Uz-Dz)/(2*(n1+n2))
if (Delt==0) Delt<-1/(n1+n2)
d<-c()
dd<-c()
tuz<-length(sz2[-sz2<=sz2[n2]])-length(sz2[-sz2<=sz2[1]])
for (r in 1:m-1)
{
d[r]<-length(sz2[-sz2<=sz2[n2-r+1]])-length(sz2[-sz2<=sz2[n2r]])+length(sz2[-sz2<=sz2[r+1]])-length(sz2[-sz2<=sz2[r]])
dd[r]<-((m-r)/(2*m))*d[r]
}
tud<-sum(dd)
a<-(tuz-tud+n2-1-(m-1)/2)/(2*n2)
Log<-Log-log(n2)-log(Delt)+log(2)+log(m)+log(a)
13
}
LogM[m-round(n2^(delta+0.5))+1]<-Log
}
#Test statistic at (15)
EntrF[i]<-min(LogM)+EntrF[i] #here “i” is Monte Carlo index
###################################
############## Test 3 #############
###################################
#The next codes present computations of the test-3-statistic(log of (16))
N<-n1+n2
# total sample size
LogM<-array()
for(m in round(N^(delta+0.5)):min(c(round((N)^(1-delta)),round(N/2))))
{
Log<-0
for(j in 1:N)
{
D<-1*(j-m<1)+(j-m)*(j-m>=1)
U<-N*(j+m>N)+(j+m)*(j+m<=N)
Uz<-length(sz[sz<=sz[U]])+length(sz[-sz<=sz[U]])
Dz<-length(sz[sz<=sz[D]])+length(sz[-sz<=sz[D]])
Delt<-(Uz-Dz)/(2*(n1+n2))
if (Delt==0) Delt<-1/(n1+n2)
Log<-Log-2*log(N)-log(Delt)+log(m)+log(2*N-m-1)
}
LogM[m-round(N^(delta+0.5))+1]<-Log
}
EntrF[i]<-min(LogM) #here “i” is Monte Carlo index
}
14
Download