Description Usage Arguments Details Examples
View source: R/samplePosteriorLGLFM.R
This function samples from the posterior distribution of the linear Gaussian latent feature model (LGLFM) using an Indian buffet process (IBP) or an Attraction Indian Buffet Distribution (AIBD) prior over possible feature allocations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | samplePosteriorLGLFM(
featureAllocation,
distribution,
X,
precisionX,
precisionA,
sdX = 1/sqrt(precisionX),
sdA = 1/sqrt(precisionA),
massPriorShape = -1,
massPriorRate = -1,
nPerShuffle = 0L,
temperaturePriorShape = -1,
temperaturePriorRate = -1,
maxStandardDeviationX = sd(X),
maxStandardDeviationA = maxStandardDeviationX,
sdProposedTemperature = -1,
sdProposedStandardDeviationX = -1,
sdProposedStandardDeviationA = -1,
corProposedSdXSdA = 0,
newFeaturesTruncationDivisor = 1000,
nOtherUpdatesPerAllocationUpdate = 10L,
nSamples = 1L,
thin = 1L,
rankOneUpdates = FALSE,
verbose = TRUE
)
|
featureAllocation |
An N-by-K binary feature allocation matrix. |
distribution |
A prior distribution of feature allocations, i.e., a
result from |
X |
An N-by-D matrix of observed data. |
precisionX |
The scalar precision of the data error variance. This must
be specified if |
precisionA |
The scalar precision of a latent feature. This must be
specified if |
sdX |
The scalar standard deviation of the data error variance. This
must be specified if |
sdA |
The scalar precision of a latent feature. This must be specified
if |
massPriorShape |
Shape parameter of the gamma prior on the mass
parameter, where the prior expected value is
|
massPriorRate |
Rate parameter of the gamma prior on the mass parameter,
where the expected value if |
nPerShuffle |
Number of items to randomly select and permute when
proposing an update to the permutation associated with the attraction
Indian buffet distribution (AIBD). The prior on the permutation is the
discrete uniform, but one can set |
temperaturePriorShape |
Shape parameter of the gamma prior on the
temperature parameter, where the prior expected value is
|
temperaturePriorRate |
Rate parameter of the gamma prior on the
temperature parameter, where the prior expected value is
|
maxStandardDeviationX |
Maximum value parameter of the uniform prior
distribution on the standard deviation of |
maxStandardDeviationA |
Maximum value parameter of the uniform prior
distribution on the standard deviation of |
sdProposedTemperature |
Standard deviation of the Gaussian random walk update for the standard deviation of the temperature. |
sdProposedStandardDeviationX |
Standard deviation of the Gaussian random
walk update for the standard deviation of |
sdProposedStandardDeviationA |
Standard deviation of the Gaussian random
walk update for the standard deviation of |
corProposedSdXSdA |
Correlation of the multivariate Gaussian random walk
updates for the standard deviations of |
newFeaturesTruncationDivisor |
While in theory a countable infinite
number of new features may be allocated to an item, the posterior
simulation needs to limit the number of new features that are considered.
The value of this argument controls when to stop considering additional
features. Starting with 0 and 1 new features, the posterior probabilities
are computed. Additional new features are considered but the algorithm
stops when the posterior probabilities of the current number of new
features is less than the maximum posterior probability (among the previous
number of new features) divided by |
nOtherUpdatesPerAllocationUpdate |
This parameter controls how many
additional MCMC updates occur for all other random model parameters for one
update of the |
nSamples |
Number of feature allocations to return. The actual number
of iterations of the algorithm is |
thin |
Only save 1 in |
rankOneUpdates |
Should rank one updates for the inverse and determinant be used? In some cases, this may be faster. |
verbose |
Should a progress bar and information regarding lapse time and acceptance rates be displayed? |
The default values for some of the tuning parameters governing the MCMC
updates of the various parameters are -1
, which effectively leaves
those parameters fixed. These default values for the tuning parameters can
be changed to treat the associated parameters as random. Likewise,
nPerShuffle=0
implies a fixed permutation.
1 2 3 4 5 6 7 8 9 10 11 12 | # Regardless of size, the initial warmup can exceed CRAN's 5 seconds threshold
mass <- 1
sigx <- 0.1
siga <- 1.0
dimA <- 1
nItems <- 8
dist <- ibp(mass, nItems)
Z <- matrix(c(1,0,1,1,0,1,0,0),byrow=TRUE,nrow=nItems,ncol=2)
A <- matrix(rnorm(ncol(Z)*dimA,sd=siga),nrow=ncol(Z),ncol=dimA)
e <- rnorm(nrow(Z)*ncol(A),0,sd=sigx)
X <- Z %*% A + e
samples <- samplePosteriorLGLFM(Z, dist, X, sdX=sigx, sdA=siga, nSamples=1000, thin=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.