# _meta.shrinkage_: An R Package for Meta-Analyses for Simultaneously Estimating Individual Means
## 2 Background
### Estimators under Sparse Means  
We now consider discrete shrinkage schemes by pre-testing \(H_{0}:\mu_{i}=0\) vs. \(H_{1}:\mu_{i}\
eq 0\) for \(i=1,2,\ldots,G\). The idea was proposed by [PERSON] [36], who developed _pretest estimators_ (see also more recent works [20; 37; 38; 39; 40; 41; 42; 43]). In the meta-analytic context, [PERSON] et al. [20] adopted the _general pretest_ (GPT) estimator of [PERSON] et al. [41], which is defined as follows:  
\[\delta_{i}^{\rm GPT}=Y_{i}I\left(\left|\frac{Y_{i}}{\sigma_{i}}\right|>z_{ \mathfrak{s}_{1}/2}\right)+qY_{i}I\left(z_{\mathfrak{s}_{2}/2}<\left|\frac{Y_ {i}}{\sigma_{i}}\right|\leq z_{\mathfrak{s}_{1}/2}\right),\ \ \ \ \ i=1,2,\ldots,G.\]  
Here \(0\leq\alpha_{1}\leq\alpha_{2}\leq 1\), \(0<q<1\), and \(z_{p}\) is the upper \(p\)th quantile of \(N(0,1)\) for \(0<p<1\). To implement the GPT estimator, the values of \(\alpha_{1}\), \(\alpha_{2}\), and \(q\) must be chosen. For any value of \(\alpha_{1}\) and \(\alpha_{2}\), as well as a function \(q\), one can show that \(\delta^{\rm GPT}\equiv\left(\delta_{1}^{\rm GPT},\ldots,\delta_{G}^{\rm GPT}\right)\) has smaller WMSE and TMSE values than \(\mathbf{Y}\), provided \(\mathbf{\mu}\approx\mathbf{0}\)[20]. One may choose \(q=1/2\) (50% shrinkage), as suggested by [20; 41]. To facilitate the interpretability of the pretests, one may choose \(\alpha_{1}=0.05\) (5% level) and \(\alpha_{2}=0.10\) (10% level). The resultant estimator is  
\[\delta_{i}^{\rm GPT}=Y_{i}I\left(\left|\frac{Y_{i}}{\sigma_{i}}\right|>1.96 \right)+qY_{i}I\left(1.645<\left|\frac{Y_{i}}{\sigma_{i}}\right|\leq 1.96 \right),\ \ \ \ \ i=1,2,\ldots,G.\]  
The special case of \(\alpha_{1}=\alpha_{2}=\alpha=0.05\) leads to the usual pretest (PT) estimator  
\[\delta_{i}^{\rm PT}=Y_{i}I\left(\left|\frac{Y_{i}}{\sigma_{i}}\right|>1.96\right),\]In our R package, the function \"gpt(. )\" can compute \(\delta^{\text{PT}}\) and \(\delta^{\text{GPT}}\). The significance levels and the shrinkage parameter are flexibly chosen by the following arguments:  
* alpha1: significance level for \(\alpha_{1}\) (0 < alpha1 < 1);
* alpha2: significance level for \(\alpha_{2}\) (0 < alpha2 < 1);
* \(q\): degrees of shrinkage for \(q\) (0 < \(q\) < 1). If users do not specify them, the default values \(\alpha_{1}=0.05\), \(\alpha_{2}=0.10\), and \(q=0.5\) will be realized. The following is an example: y<<(-0.18312,-0.72266,-0.48507,-0.23961,-0.13226,-0.27228,-0.5867,-0.13969, -0.1004,-0.31143,-0.04949,-0.11685,-0.13044,0.04391) s<c(0.15372,0.28686,0.33192,0.21558,0.14691,0.14416,0.24885, 0.14542,0.16404,0.17038,0.19818,0.16476,0.19268,0.17632) gpt(y,s) > gpt(y,s) PT GPT 1 0.00000 0.000000 2 -0.72266 -0.722660 3 0.00000 0.00000 4 0.00000 0.0  
These scenarios were not considered by our previous simulation studies [20]. We generated normally distributed data \(\Upsilon_{i}\sim N\big{(}\mu_{i},\sigma_{i}^{2}\big{)}\) where \(\sigma_{i}^{2}\sim\chi_{df=1}^{2}/4\) was restricted (truncated) in \(\sigma_{i}^{2}\in[0.009,\,0.6]\), \(i=1,2,\ldots,G\), as previously considered [20; 44]. Using the data \(\mathbf{Y}\equiv(Y_{1},\ldots,Y_{G})\), we applied the proposed R package _meta.shrinkage_ to compute \(\delta^{\text{IS}}\), \(\delta^{\text{IS+}}\), \(\delta^{\text{RML}}\), \(\delta^{\text{RJS}}\), \(\delta^{\text{RJS+}}\), \(\delta^{\text{FT}}\), and \(\delta^{\text{GFT}}\) for estimating \(\mathbf{\mu}\). We examined how these estimators improved upon the standard estimator \(\mathbf{Y}\) in terms of the TMSE and WMSE. Our simulations were based on 10,000 repetitions using \(\mathbf{Y}^{(r)}\), where \(1\leq r\leq 10,000\). Let \(\delta\big{(}\mathbf{Y}^{(r)}\big{)}=\Big{(}\delta_{1}\big{(}\mathbf{Y}^{(r)}\big{)},\ldots,\delta_{G}\big{(}\mathbf{Y}^{(r)}\big{)}\Big{)}\) be one of the seven estimators in the \(r\)th repetition.