tweights_bmr {tboot} | R Documentation |
Function tweights_bmr
Description
Set up the needed prerequisites in order to prepare for Bayesian marginal reconstruction (including a call to tweights). Takes as input simulations from the posterior marginal distribution of variables in a dataset.
Usage
tweights_bmr(dataset, marginal, distance = "klqp", maxit = 1000,
tol = 1e-08, warningcut = 0.05, silent = FALSE, Nindependent = 1)
Arguments
dataset |
Data frame or matrix to use to find row weights. |
marginal |
Must be a named list with each element a vector of simulations of the marginal distribution of the posterior mean of data in the dataset. |
distance |
The distance to minimize. Must be either 'euchlidean,' 'klqp' or 'klpq' (i.e. Kullback-Leibler). 'klqp' which is exponential tilting is recommended. |
maxit |
Defines the maximum number of iterations for optimizing 'kl' distance. |
tol |
Tolerance. If the achieved mean is too far from the target (i.e. as defined by tol) an error will be thrown. |
warningcut |
Sets the cutoff for determining when a large weight will trigger a warning. |
silent |
Allows silencing of some messages. |
Nindependent |
Assumes the input also includes 'Nindependent' samples with independent columns. See details. |
Details
Reconstructs a correlated joint posterior from simulations from a marginal posterior. The algorithm is summarized more fully in the vignettes. The 'Nindependent' option augments the dataset by assuming some additional specified number of patients. These patients are assumed to made up of a random bootstrapped sample from the dataset for each variable marginally leading to independent variables.
Value
An object of type tweights
. This object conains the following components:
- Csqrt
Matrix square root of the covariance.
- tweights
Result from the call to tweigths.
- marginal
Input marginal simulations.
- dataset
Formatted dataset.
- target
Attempted target.
- distance,maxit,tol, Nindependent, warningcut
Inputed values to 'tweights_bmr'.
- Nindependent
Inputed 'Nindependent' option.
- augmentWeights
Used for 'Nindependent' option weights for each variable.
- weights
Tilted weights for resampling
- originalTarget
Will be null if target was not changed.
- marginal_sd
Standard deviation of the marginals.
See Also
Examples
#Use winsorized marginal to keep marginal simulation within feasible bootstrap region
winsor=function(marginalSims,y) {
l=min(y)
u=max(y)
ifelse(marginalSims<l,l,ifelse(marginalSims>u,u, marginalSims))
}
#Create an example marginal posterior
marginal = list(Sepal.Length=winsor(rnorm(10000,mean=5.8, sd=.2),iris$Sepal.Length),
Sepal.Width=winsor(rnorm(10000,mean=3,sd=.2), iris$Sepal.Width),
Petal.Length=winsor(rnorm(10000,mean=3.7,sd=.2), iris$Petal.Length)
)
#simulate
w = tweights_bmr(dataset = iris, marginal = marginal, silent = TRUE)
post1 = post_bmr(1000, weights = w)