Title: | Semiparametric Bayesian Gaussian Copula Estimation and Imputation |
---|---|
Description: | Estimation and inference for parameters in a Gaussian copula model, treating the univariate marginal distributions as nuisance parameters as described in Hoff (2007) <doi:10.1214/07-AOAS107>. This package also provides a semiparametric imputation procedure for missing multivariate data. |
Authors: | Peter Hoff |
Maintainer: | Peter Hoff <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.980 |
Built: | 2025-02-14 03:24:31 UTC |
Source: | https://github.com/pdhoff/sbgcop |
Estimation and inference for parameters in a Gaussian copula model, treating univariate marginal distributions as nuisance parameters as described in Hoff (2007) <doi:10.1214/07-AOAS107>. This pacakge also provides a semiparametric imputation procedure for missing multivariate data.
Package: | sbgcop |
Type: | Package |
Version: | 0.980 |
Date: | 2018-05-25 |
License: | GPL Version 2 or later |
This function produces MCMC samples from the posterior distribution of a correlation matrix, using a scaled inverse-Wishart prior distribution and an extended rank likelihood. It also provides imputation for missing values in a multivariate dataset.
Peter Hoff <[email protected]>
Hoff (2007) “Extending the rank likelihood for semiparametric copula estimation”
fit<-sbgcop.mcmc(swiss) summary(fit) plot(fit)
fit<-sbgcop.mcmc(swiss) summary(fit) plot(fit)
Computes the log of the multivariate normal density
ldmvnorm(Y, S)
ldmvnorm(Y, S)
Y |
an n x p matrix |
S |
a p x p positive definite matrix |
This function computes the log density of the data matrix Y
under the
model that the rows are independent samples from a mean-zero multivariate
normal distribution with covariance matrix S
.
A real number.
Peter Hoff
Y<-matrix(rnorm(9*7),9,7) ldmvnorm(Y,diag(7))
Y<-matrix(rnorm(9*7),9,7) ldmvnorm(Y,diag(7))
Plots 95
plotci.sA(sA, ylabs = colnames(sA[, , 1]), mgp = c(1.75, 0.75, 0))
plotci.sA(sA, ylabs = colnames(sA[, , 1]), mgp = c(1.75, 0.75, 0))
sA |
a p x p x nsamp array |
ylabs |
a p x 1 vector of names for plotting labels |
mgp |
margin parameters |
Peter Hoff
fit<-sbgcop.mcmc(swiss) plotci.sA(fit$C.psamp)
fit<-sbgcop.mcmc(swiss) plotci.sA(fit$C.psamp)
Computes quantiles along the third dimension of a 3-d array.
qM.sM(sM, quantiles = c(0.025, 0.5, 0.975))
qM.sM(sM, quantiles = c(0.025, 0.5, 0.975))
sM |
an m x n x s array |
quantiles |
quantiles to be computed |
an array of dimension m x n x l, where l is the length of
quantiles
Peter Hoff
Generate a random sample from the Wishart distribution.
rwish(S0, nu)
rwish(S0, nu)
S0 |
a positive definite matrix |
nu |
a positive integer |
Return the sum of nu i.i.d. rank-one matrices generated as z%*%t(z)
,
where z
is a sample from a multivariate normal distribution with
covariance S0
. The resulting random variable has mean nu*S0
.
a positive definite matrix.
Peter Hoff
sbgcop.mcmc
is used to semiparametrically estimate the parameters of
a Gaussian copula. It can be used for posterior inference on the copula
parameters, and for imputation of missing values in a matrix of ordinal
and/or continuous values.
sbgcop.mcmc(Y, S0 = diag(dim(Y)[2]), n0 = dim(Y)[2] + 2, nsamp = 100, odens = max(1, round(nsamp/1000)), impute = any(is.na(Y)), plugin.threshold = 100, plugin.marginal = (apply(Y, 2, function(x) { length(unique(x)) }) > plugin.threshold), seed = 1, verb = TRUE)
sbgcop.mcmc(Y, S0 = diag(dim(Y)[2]), n0 = dim(Y)[2] + 2, nsamp = 100, odens = max(1, round(nsamp/1000)), impute = any(is.na(Y)), plugin.threshold = 100, plugin.marginal = (apply(Y, 2, function(x) { length(unique(x)) }) > plugin.threshold), seed = 1, verb = TRUE)
Y |
an n x p matrix. Missing values are allowed. |
S0 |
a p x p positive definite matrix |
n0 |
a positive integer |
nsamp |
number of iterations of the Markov chain. |
odens |
output density: number of iterations between saved samples. |
impute |
save posterior predictive values of missing data(TRUE/FALSE)? |
plugin.threshold |
if the number of unique values of a variable exceeds this integer, then plug-in the empirical distribution as the marginal. |
plugin.marginal |
a logical of length p. Gives finer control over which margins to use the empirical distribution for. |
seed |
an integer for the random seed |
verb |
print progress of MCMC(TRUE/FALSE)? |
This function produces MCMC samples from the posterior distribution of a correlation matrix, using a scaled inverse-Wishart prior distribution and an extended rank likelihood. It also provides imputation for missing values in a multivariate dataset.
An object of class psgc
containing the following components:
C.psamp |
an array of size p x p x |
Y.pmean |
the original datamatrix with imputed values replacing missing data |
Y.impute |
an
array of size n x p x |
LPC |
the log-probability of the latent variables at each saved sample. Used for diagnostic purposes. |
Peter Hoff
http://www.stat.washington.edu/hoff/
fit<-sbgcop.mcmc(swiss) summary(fit) plot(fit)
fit<-sbgcop.mcmc(swiss) summary(fit) plot(fit)
Compute an array of regression parameters from an array of correlation parameters.
sR.sC(sC)
sR.sC(sC)
sC |
a p x p x nsamp array of, made up of nsamp correlation matrices. |
For each of the nsamp correlation matrices C, a matrix of regression
parameters is computed via R[j,-j]<- C[j,-j]%*%solve(C[-j,-j])
a p x p x nsamp array of regression parameters.
Peter Hoff
fit<-sbgcop.mcmc(swiss) plotci.sA(sR.sC(fit$C.psamp))
fit<-sbgcop.mcmc(swiss) plotci.sA(sR.sC(fit$C.psamp))