# Reliability and PEV

For single trait model, multiple traits model and solving mixed model equation, HIBLUP can calculate the reliability and prediction error variance (PEV) of all random effects. The mathematical formula for reliability calculation is as follows:

\begin{equation}
\begin{aligned}
r^{2} &= 1-\frac{PEV}{\sigma^{2}}
\end{aligned}
\end{equation}

where \sigma^{2} is the estimated variance from REML analysis for the random effect of interest. The prediction error variance PEV can be obtained from the following equation:

\begin{equation}
\begin{aligned}
PEV &= C_{ii}*\sigma_{e}^{2}
\end{aligned}
\end{equation}

where \sigma_e^{2} is the estimated residual variance. C_{ii} is the i_{th} diagonal element of the inverse matrix of left hand side (LHS) of mixed model equation.

By default, HIBLUP does not calculate and output those statistics, as the reliability estimation usually takes longer than whole REML process, thus please add flag --r2 only if you really want to get the reliability.

Taking single trait model for an example, the script to obtain the reliability is as follows:

./hiblup --single-trait
--pheno demo.phe
--pheno-pos 8
--dcovar 2,3       #fixed effect
--qcovar 4,5       #covariates
--rand 7           #non-genetic (environmental) random effect
--bfile demo       #genetic random effect
--r2               #to calculate the reliability
--out demo 
ID      dam       dam_SE   dam_PEV  dam_R2    GA        GA_SE    GA_PEV   GA_R2     residuals  residuals_SE residuals_PEV residuals_R2
IND1004 0.674833  3.53678  12.5088  0.341566  -0.682836 4.70199  22.1087  0.727651  0.9083     4.17824      17.4577       0.228936