tboot (version 0.2.0)

tboot_bmr: Function tboot_bmr

Description

Bootstrap nrow rows of dataset using the given row-level weights.

Usage

tboot_bmr(nrow, weights_bmr, tol_rel_sd = 0.01)

Arguments

nrow

number of rows in the new bootstrapped dataset.

weights_bmr

an object of class 'tweights' output from the 'tweights' function.

tol_rel_sd

An error will be called if for some simulation if the target is not achievable with the data. However, the error will only be called if max absolute difference releative to the marginal standard is greater than specified.

Value

A simulated dataset with 'nrow' rows. The underlying 'true' posterior parameter value is an attribute which can be extracted useing attr(ret, "post_bmr") where 'ret' is the matrix.

Details

Simulates a dataset by first simulating from the posterior distribution of the column means and then simulating a dataset with that underlying mean. Details a further documented in the vignette.

See Also

tweights

Examples

Run this code
# NOT RUN {
#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)
sample_data = tboot_bmr(1000, weights = w)

# }

Run the code above in your browser using DataLab