
Bayesian Unfolding with Slice Sampling and L-BFGS Optimization
Source:R/bayesunfold.R
bayesunfold.Rd
The bayesunfold
function performs Bayesian unfolding using slice sampling and L-BFGS optimization.
It estimates the positions of stimuli and individuals in a lower-dimensional space,
allowing for the analysis of preference data with missing values.
Usage
bayesunfold(
input,
dims = 2,
nsamp = 2000,
burnin = 1000,
cred.level = 0.9,
slice.starts = c("lbfgs", "random"),
print.lbfgs = "console",
print.slice = "console",
...
)
Arguments
- input
A numeric matrix representing the input data, where rows correspond to respondents and columns correspond to stimuli. Missing values (NA) are allowed.
- dims
An integer specifying the number of dimensions to estimate. Default is 2.
- nsamp
An integer specifying the number of samples to draw from the posterior distribution. Default is 2000.
- burnin
An integer specifying the number of burn-in iterations for the sampler. Default is 1000.
- cred.level
A numeric value specifying the credible interval level (between 0 and 1). Default is 0.9.
- slice.starts
A character string specifying the starting points for the slice sampler. Options are
"lbfgs"
(default) for using the L-BFGS result as the starting point, or"random"
for random starts.- print.lbfgs
A character string specifying the output method for L-BFGS results. Options are
"console"
(default) or a file path to save the results.- print.slice
A character string specifying the output method for slice sampling results. Options are
"console"
(default) or a file path to save the results.- ...
Additional arguments passed to the
smacofRect
function for SMACOF metric unfolding.
Value
A list of class bayesunfold
containing:
- retained.obs
A logical vector indicating which rows (respondents) were retained based on the cutoff criteria.
- smacof.result
The result of SMACOF metric unfolding for comparison purposes.
- lbfgs.result
A list with the L-BFGS estimated positions for stimuli and individuals.
- samples
The raw samples from the slice sampler.
- result4
The result object from the slice sampler.
- sigma_squared_hat
The estimated variance from the slice sampler.
- sigma_squared_hat_sd
The standard deviation of the estimated variance from the slice sampler.
- unrotated
A list containing unrotated results for stimuli and individuals, including means and credible intervals.
- rotated
A list containing Procrustes-rotated results for stimuli and individuals, including means and credible intervals.
Details
The bayesunfold
function implements a Bayesian approach to unfolding analysis,
where respondents' preferences are modeled in a latent space. The method combines L-BFGS optimization for initial estimates and slice sampling for posterior inference.
The function handles missing data by excluding respondents with insufficient responses and imputing missing values for the remaining data.
The L-BFGS and slice sampling steps can be configured to either print results to the console or save them to specified files.
Examples
if (FALSE) { # \dontrun{
# Load the ANES1968 dataset
data(anes.input)
# Perform Bayesian unfolding
result <- bayesunfold(anes.input, dims = 2,
nsamp = 20, burnin = 5, cred.level = 0.9, slice.starts = "lbfgs")
} # }