Description Usage Arguments Details Value Note Author(s) References See Also Examples
~~ A concise (1-5 lines) description of what the function does. ~~
1 | MAsim.uneqvar(ng = 10000, n = 3, n1 = n, n2 = n, p0 = 0.9, d01 = 10, s2_01 = 1, v0m = 1, v0var = 1, p0var = 0.7)
|
ng |
~~Describe |
n |
~~Describe |
n1 |
~~Describe |
n2 |
~~Describe |
p0 |
~~Describe |
d01 |
~~Describe |
s2_01 |
~~Describe |
v0m |
~~Describe |
v0var |
~~Describe |
p0var |
~~Describe |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
~~further notes~~
~Make other sections like Warning with .... ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ##---- 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 (ng = 10000, n = 3, n1 = n, n2 = n, p0 = 0.9,
d01 = 10, s2_01 = 1, v0m = 1, v0var=1, p0var=0.7)
{
nn = n1 + n2
group = rep(c(0, 1), c(n1, n2))
s2 = d01*s2_01/rchisq(ng, df = d01)
s2_g1 = s2*exp(rnorm(ng,mean=0,sd= sqrt(v0var)))
s2_g2 = s2*exp(rnorm(ng,mean=0,sd= sqrt(v0var)))
eqvar = runif(ng)< p0var # equal variance
s2_g1[eqvar] = s2[eqvar]
s2_g2[eqvar] = s2[eqvar]
s2_g = (n1*s2_g1 + n2*s2_g2)/(n1+n2) # average variance
xdat1 = matrix(rnorm(ng*n1, sd = sqrt(s2_g1)), ncol = n1)
ndx = runif(ng) > p0
nde = sum(ndx)
xmean2 = rep(0, ng)
xmean2[ndx] = rnorm(nde, mean = 0, sd = sqrt(v0m * s2_g))
xdat2 = matrix(rnorm(ng*n2, sd = sqrt(s2_g2)), ncol = n2) + xmean2
xdat = cbind(xdat1, xdat2)
colnames(xdat) = as.character(group)
des = des.var = rep(FALSE, ng) # DE status for mean and variance
des[ndx] = TRUE
des.var[!eqvar] = TRUE
attr(xdat, "DE") = des
attr(xdat, "DE.var") = des.var
xdat
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.