Description Usage Arguments Value Author(s) References Examples
This function is used after the unmasked data have been obtained from the unmask function. If the Data Provider supplies all the means, standard deviations and the correlation matrix of the original data then these can be used as arguments. Otherwise, these are calculated using the mean of noise sample from and the mean of the vector created by squaring each element of the noise sample.
1 2 3 4 | getSampleFromMarginalDistributionOfUnmaskedData(xLengths, meansOfNoises,
meansOfSquaredNoises, xStars, Vx, mu, s, rho_X, maxSize,
choleskySpeed = TRUE, cores = 1, size,
returnJointDensity = FALSE, verbose = -1)
|
xLengths |
List of integer number of points from which to sample the fitted density functions of each respective variable |
meansOfNoises |
Used to calculate mu, s and rho_X if any of them are not supplied |
meansOfSquaredNoises |
Used to calculate mu, s and rho_X if any of them are not supplied |
xStars |
List of masked vectors |
Vx |
List of unmasked vectors |
mu |
List of means of unmasked vectors - if not supplied will be calculated using meansOfNoises and meansOfSquaredNoises |
s |
List of standard deviations of unmasked vectors - if not supplied will be calculated using meansOfNoises and meansOfSquaredNoises |
rho_X |
Correlation matrix of unmasked vectors - if not supplied will be calculated using meansOfNoises and meansOfSquaredNoises |
maxSize |
Passed to generalizedJointF |
choleskySpeed |
Passed to generalizedJointF |
cores |
Passed to generalizedJointF |
size |
Passed to actualPosition |
returnJointDensity |
If TRUE, then the joint density function calculated in an intermediate step by generalizedJointF is returned as the second element in the list. If FALSE, then the returned list has only one element. |
verbose |
If greater than 0 output is printed to tell the user at what stage the function is in, is also passed to many internal functions and will give more detailed output from them if it is greater than 1 |
List with first element equal to the samples from the marginal densities of the unmasked variables. If returnJointDensity is TRUE then returns a second element that is the jointDensityFunction of the unmasked variables.
Luke Mazur
no references
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ##---- 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 (xLengths, meansOfNoises, meansOfSquaredNoises, xStars,
Vx, mu, s, rho_X, maxSize, choleskySpeed = TRUE, cores = 1,
size, returnJointDensity = FALSE, verbose = -1)
{
n <- length(xLengths)
if (missing(mu)) {
mu <- lapply(1:n, FUN = function(i) {
mean(xStars[[i]])/meansOfNoises[[i]]
})
}
if (missing(s)) {
s <- lapply(1:n, FUN = function(i) {
sqrt((mean(xStars[[i]]^2) - (meansOfSquaredNoises[[i]]) *
mean(xStars[[i]])^2/(meansOfNoises[[i]])^2)/(meansOfSquaredNoises[[i]]))
})
}
if (missing(rho_X)) {
rho_X <- matrix(1, n, n)
for (i in 1:n) {
for (j in 1:n) {
if (i != j) {
rho_X[i, j] <- (cov(xStars[[i]], xStars[[j]])/((meansOfNoises[[i]]) *
(meansOfNoises[[j]])))/(s[[i]] * s[[j]])
rho_X[j, i] <- rho_X[i, j]
}
}
}
}
if (verbose > 1) {
print(mu)
print(s)
print(rho_X)
}
if (verbose > 0) {
print("finished estimating mu, s and rho_X if missing")
}
testBoundary <- lapply(1:n, FUN = function(i) {
return(c(min(Vx[[i]]), max(Vx[[i]])))
})
testX <- lapply(1:n, FUN = function(i) {
return(seq(from = (testBoundary[[i]])[1], to = (testBoundary[[i]])[2],
by = ((testBoundary[[i]])[2] - (testBoundary[[i]])[1])/xLengths[[i]]))
})
G_Point7 <- c(-3.75043971768, -2.36675941078, -1.1544053948,
0, 1.1544053948, 2.36675941078, 3.75043971768)
GH_Quadrature <- c(0.000548268858737, 0.0307571239681, 0.240123178599,
0.457142857143, 0.240123178599, 0.0307571239681, 0.000548268858737)
if (verbose > 0) {
print("calculating jointDensityFunction")
}
jointDensityFunction <- generalizedJointF(testX, Vx, mu,
s, rho_X, G_Point7, GH_Quadrature, maxSize = floor(sqrt(1450000)),
choleskySpeed, cores, verbose)
if (verbose > 0) {
print("finished calculation of jointDensityFunction")
}
boundaryVec <- unlist(testBoundary)
finalOutput <- actualPosition(dim(jointDensityFunction),
jointDensityFunction, boundaryVec, size = size)
if (returnJointDensity) {
return(list(sample = finalOutput, jointDensityFunction = jointDensityFunction))
}
return(list(sample = finalOutput))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.