Giter VIP home page Giter VIP logo

rstan-package-test's Introduction

copulafa R package

The package contains several factor analysis methods, with emphasis to count data. The main methods rely on copulas to estimate the residual covariance, not explained by the latent structure. Additionally, the package contains four data sets for empirical evaluation and one baseline model. The methods use RStan for inference, the only exception is the iPoiss method where we use conjugate posterior.

Installation

Use devtools to install the package directly from the repository. The package needs to compile the models in C++ so a compiler is required.

library(devtools)
devtools::install_github("gregorp90/RStan-package-test")

You may have trouble installing the 32-bit and 64-bit versions on Windows. In that case only install one version with

devtools::install_github("gregorp90/RStan-package-test", INSTALL_opts = c("--no-multiarch"))

which will automatically install the arch that is used in your current RStudio session. If it still does not install, you may need to check your system Path, where the compiler for the desired version should be before the compiler for the other version.

Use

The main functionality of the package is training and predicting with different factor analysis methods. For that, you only need to use functions starting with train_ and pred_. Additionally there are four sports count data sets that can be used for the training and evaluation. The data are from the English association football Premier League (EPL), National Basketball Association (NBA), National Football League (NFL), and esports League of Legends Champions Korea (LCK).

For example, to train, predict, and evaluate the copula negative binomial factor analysis method on EPL data, use

data(EPL_data)
train_ind <- EPL_data$splits[ ,1] == 2
test_ind  <- EPL_data$splits[ ,1] == 1
train_dat <- EPL_data$fa_data[train_ind, ]
train_grp <- EPL_data$group[train_ind]
test_dat  <- EPL_data$fa_data[test_ind, ]
test_grp  <- EPL_data$group[test_ind]

my_model <- train_CNBFA2(train_dat, train_grp)
my_eval  <- pred_CNBFA2(my_model, test_grp, test_dat)
mean(my_eval$likelihoods)
my_eval$predictions # get predictions for all observations in the test set

Inputs to other methods are similar, for details see documentation.

rstan-package-test's People

Contributors

gregorp90 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.