| latent_factors | R Documentation |
Extract latent factor posteriors from fit
latent_factors(fit, ...)
## Default S3 method:
latent_factors(fit, summary = TRUE, probs = c(0.025, 0.5, 0.975), ...)
fit |
A fit sampled with latent factors: its draw matrix ( |
... |
Passed to methods. |
summary |
Logical; if TRUE, return summary statistics. If FALSE, return full posterior draws. |
probs |
Quantiles for summary. Default is c(0.025, 0.5, 0.975). |
If summary = TRUE, a data frame with columns for observation,
factor, and summary statistics. If summary = FALSE, a matrix of
posterior draws.
# A fit sampled with latent factors comes from a model package (tulpaRatio
# reads the latent_factor() spec). The accessor reads two things off it:
# draw columns named factor[observation,factor] and the latent layout. Here
# both are simulated for three observations on two factors.
set.seed(1)
cols <- sprintf("factor[%d,%d]", rep(1:3, 2), rep(1:2, each = 3))
draws <- matrix(rnorm(200 * 6, mean = rep(c(-1, 0, 1), 2), sd = 0.3),
200, 6, byrow = TRUE, dimnames = list(NULL, cols))
fit <- structure(
list(draws = draws,
.internal = list(latent_info = list(type = "latent", n_factors = 2L,
n_obs = 3L))),
class = "tulpa_fit")
latent_factors(fit)
dim(latent_factors(fit, summary = FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.