ppcaard: Perform a probabilistic PCA with ARD

Description Usage Arguments Value Examples

View source: R/ppcaard.R

Description

This function performs a probabilistic principal component analysis with automatic relevance determination.

Usage

1
2
ppcaard(xdf, k, chains = 2, iter = 500,
  cores = max(parallel::detectCores() - 1, 1), ...)

Arguments

xdf

the data set to perform the analysis on

k

the number of latent factors to consider

chains

the number of chains to use which defaults to 2

iter

the number of samples to pull which defaults to 1000

cores

the number of cores to use which defaults to max(parallel::detectCores()-1, 1)

...

other arguments passed to the sampling method in rstan

Value

the stanfit from the sampled changepoint model

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ggplot2)
library(mvtnorm)
library(tibble)
library(dplyr)
tmpdf <- mvtnorm::rmvnorm(400, sigma = matrix(c(1,0.8,0.8,1),2,2))
ggplot2::qplot(tmpdf[,1], tmpdf[,2])
a<-ppcaard(as.data.frame(tmpdf), 2)
adf <- as.data.frame(a)
compdf <- tibble::tibble(z1=adf[,grep("z\\[1,", colnames(adf), value=TRUE)] %>% colMeans(),
                 z2=adf[,grep("z\\[2,", colnames(adf), value=TRUE)] %>% colMeans())

DoktorMike/bayesian-model-zoo documentation built on May 23, 2019, 11:32 p.m.