View source: R/SKAT_Get_TruncatedNormal.R
1 | SKAT_Get_TruncatedNormal(n, mu, sigma, c1, c2, nSet, nUpper = n/2)
|
n |
|
mu |
|
sigma |
|
c1 |
|
c2 |
|
nSet |
|
nUpper |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ##---- 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 (n, mu, sigma, c1, c2, nSet, nUpper = n/2)
{
prob1 <- 1 - pnorm(c1, mean = mu, sd = sigma)
prob2 <- pnorm(c2, mean = mu, sd = sigma)
prob <- prob1/(prob1 + prob2)
temp.b <- rbinom(n * nSet, 1, rep(prob, nSet))
lower = rep(-10^5, n * nSet) * (1 - temp.b) + c1
upper = rep(10^5, n * nSet) * temp.b + c2
re <- rtnorm(n * nSet, mean = mu, sd = sigma, lower = lower,
upper = upper)
re.M <- matrix(re, ncol = nSet, byrow = FALSE)
cutoff <<- cbind(lower, upper, temp.b, mu)
rm(re)
rm(lower)
rm(upper)
return(re.M)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.