Learn R Programming

selectiongain (version 1.0)

calculatefromalpha: calculate the quantile for given alpha

Description

this function can be considered as similar as qmvnorm. but for qmvnorm, a uniform alpha is given and the uniform quantiles are calculated for this alpha. in our function a vector of alpha is given, and the quantiles are calculate one by one to satisfy thesis given alpha. e.g. alpha2= pmvnorm(quantile1,quantile2) now given alpha2, quantile1. we want to know quantile2. this is kind of Recursion Procedure.

Usage

calculatefromalpha(alpha, dim, corr)

Arguments

alpha
Probability vector for random variable X. $alpha(i)= pmvnorm(quantile(1),..., quantile(i)) $ in plants breeding, it is also called selection fraction. here we have $alpha(i)=N_(i+1)/N(i)$, which is the elimation rate from generation $i$ to gene
dim
dimesion of the random variable X.
corr
correlation matrix

Value

  • the out come is a vector for the quantiles

Details

more details

References

Tallis 1961, Utz1969

See Also

selectiongain()

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(alpha,dim,corr)
{

    qnormbar<-function(kwanted,koutput,corr,howmanyk,alpha)
   {   
        corr2dim=corr[1:howmanyk,1:howmanyk] 
        
        tempofk1=koutput[1:c(howmanyk-1)]
          
        alphatotal=1
        for (i in 1:howmanyk)
        {
           alphatotal=alphatotal*alpha[i]
        }

        pmvnorm(lower = c(tempofk1,kwanted), upper = rep(Inf,howmanyk), mean = rep(0,howmanyk),
                   corr = corr2dim) - alphatotal   
   }
     
    koutput=0
    for (i in  1: dim )
       {
    
         if (i == 1)     
         {
           koutput[1]= qnorm(alpha[1],lower.tail = FALSE)[[1]][1]
  
         }else
         {

           koutput[i]= uniroot(qnormbar,interval=c(-100,100),koutput=koutput,corr,i,alpha)[[1]][1]  
         }
     }

koutput
  }

Run the code above in your browser using DataLab