HCR.fast: The Fast Version for Fitting Hidden Compact Representation...

Description Usage Arguments Value Examples

View source: R/fit_model.R

Description

A fast implementation for fitting the HCR model. This implementation caches all intermediate results to speed up the greedy search. The basic idea is that if there are two categories need to be combined, for instance, X=1 and X=2 mapping to the same Y'=1, then the change of the score only depend on the frequency of the data where X=1 and X=2. Therefore, after combination, if the increment of the likelihood is greater than the penalty, then we will admit such combination.

Usage

1
HCR.fast(X, Y, score_type = "bic", ...)

Arguments

X

The data of cause.

Y

The data of effect.

score_type

You can choose "bic","aic","aicc","log" as the type of score to fit the HCR model. Default: bic

...

Other arguments passed on to methods. Not currently used.

Value

The fitted HCR model and its score.

Examples

1
2
3
4
5
6
7
8
9
library(data.table)
set.seed(1)
data=simuXY(sample_size=2000)
r1=HCR.fast(data$X,data$Y)
r2=HCR.fast(data$Y,data$X)
# The canonical hidden representation
unique(r1$data[,c("X","Yp")])
# The recovery of hidden representation
unique(data.frame(data$X,data$Yp))

HCR documentation built on May 2, 2019, 10:15 a.m.