fvcc: Clustering Variying Coefficients with a Pitman-Yor Process

View source: R/fvcc.R

fvccR Documentation

Clustering Variying Coefficients with a Pitman-Yor Process

Description

Clustering Variying Coefficients with a Pitman-Yor Process

Usage

fvcc(
  ID,
  W,
  X = NULL,
  Z,
  t,
  Y,
  num_knots = 30,
  K_max,
  num_iters = 10000,
  thinning_unit = 5,
  nu = 1,
  Psi = NULL,
  beta = NULL,
  kappa = 1000,
  return_var_coefs = TRUE
)

Arguments

ID

A vector of subjects' IDs.

W

A part of design matrix for varying coefficients

X

A part of design matrix for time-invariant fixed effects

Z

A part of design matrix for random effects

t

A vector of time observations

Y

A vector of binary responses

num_knots

The number of knot candidates for the basis splines

K_max

The upper bound of the number of clusters for the stick-breaking process

num_iters

The number of iterations for the partially collapsed Gibbs sampler

thinning_unit

Thinning unit of the pcg sampler

nu

The concentration parameter

Psi

An initial covariance matrix of the random effects

beta

An initial vector of the fixed effects

Examples

library(fvcc)

#SimulationData is an example dataset.

ID <- SimulationData$ID
W <- SimulationData[c('W1','W2')]
X <- SimulationData[c('X1','X2')]
Z <- SimulationData[c('Z1','Z2')]
t <- SimulationData$t
Y <- SimulationData$Y

output <- fcvarpyp(ID = ID,
               W = W,
               X = X,
               Z = Z,
               t = t,
               Y = Y,
               num_knots = 15,
               K_max = 10,
               num_iters = 10000)

plot(output$fixed_effect, position = 1)
plot(output$random_effect, row_position = 1, col_position = 1)
plot(output$cluster)
plot(output$varying_coefficient, cluster_number = 5, variable_number = 1)
plot(output$latent_location, cluster_number = 5, variable_number = 1, time_range = output$time_range, knot_position = output$knot_position)
plot(output$nu)
plot(output$lambda)


Jwsohn612/cvarpyp documentation built on Oct. 12, 2024, 7:57 p.m.