Type: Package
Title: Kernel Density Estimation with a Markov Chain Monte Carlo Sample
Version: 0.0.1
Date: 2025-04-21
Maintainer: Juhee Lee <ljh988488@gmail.com>
Description: Provides methods for selecting the optimal bandwidth in kernel density estimation for dependent samples, such as those generated by Markov chain Monte Carlo (MCMC). Implements a modified biased cross-validation (mBCV) approach that accounts for sample dependence, improving the accuracy of estimated density functions.
License: GPL (≥ 3)
Depends: R (≥ 3.5.0)
Imports: Rcpp, methods
LinkingTo: Rcpp, RcppArmadillo
LazyData: true
RcppModules: cKDEmodule
NeedsCompilation: yes
RoxygenNote: 7.3.2
Packaged: 2025-04-21 09:44:43 UTC; user
Author: Juhee Lee [aut, cre], Hang J. Kim [aut], Young-Min Kim [aut]
Repository: CRAN
Date/Publication: 2025-04-24 07:30:01 UTC

Internal S4 Class for Bandwidth Estimation

Description

An internal S4 class used in the implementation of kernel density bandwidth estimation using MCMC samples. This class is not intended to be used directly by package users.

Objects from the Class

Objects of this class are created internally by C++ functions exposed via Rcpp. End users should not create or manipulate instances of this class.

Slots

This class does not expose any user-accessible slots.


RCPP Implementation of the Library

Description

Rcpp_cKDE-class

Value

No return value


Calculate Optimal Bandwidth in Kernel Density Estimation

Description

Calculate the optimal bandwidth for the kernel density estimator with a Markov chain Monte Carlo sample using modified biased cross-validation method.

Usage

mBCV(Y_in)

## S3 method for class 'mBCV_obj'
print(x, ...)

Arguments

Y_in

data from which the estimate is to be computed.

x

object of class mBCV_obj; result of a call to mBCV().

...

further arguments passed to or from other methods.

Value

mBCV returns a list of the following conmponents:

bw

optimal bandwidth.

IACT

intergrated autocorrelation time.

Y_in

input data.

Examples

res = mBCV(simMCMC)
den = density(res$Y_in, bw=res$bw)
hist(res$Y_in, xlim=range(den$x), freq=FALSE, 
      main="Histogram and Density Estimates", xlab="")
lines(den$x, den$y, col='blue', lwd=2)

Plot Kernel Density Result from mBCV_obj

Description

draw a histogram and density curve of the results.

Usage

## S3 method for class 'mBCV_obj'
plot(x, main=NULL, xlab="", ...)

Arguments

x

mBCV_obj object.

main

title of plot.

xlab

title for the x axis.

...

arguments to be paseed to methods.

Value

No return value. Called for its side effects (generates a plot).


Simulated Markov Chain Monte Carlo Sample

Description

a simulated data from the Gibbs sampler.

Usage

data("simMCMC")

Format

a numeric vector of length 1000.

Examples

data(simMCMC)