# mlr: Bayesian Multinomial Logistic Regression In bayesCL: Bayesian Inference on a GPU using OpenCL

## Description

Inference for Bayesian multinomial logistic regression models by Gibbs sampling from the Bayesian posterior distribution.

## Usage

 ```1 2 3 4``` ```mlr(y, X, n=rep(1,nrow(as.matrix(y))), m.0=array(0, dim=c(ncol(X), ncol(y))), P.0=array(diag(0, ncol(X)), dim=c(ncol(X),ncol(X),ncol(y))), samp=1000, burn=500, float=0, device=0, parameters=NULL) ```

## Arguments

 `y` an N x J-1 dimensional matrix; y_{ij} is the average response for category j at x_i. `X` an N x P dimensional design matrix; x_i is the ith row. `n` an N dimensional vector; n_i is the total number of observations at each x_i. `m.0` a P x J-1 matrix with the β_j's prior means. `P.0` a P x P x J-1 array of matrices with the β_j's prior precisions. `samp` the number of MCMC iterations saved. `burn` the number of MCMC iterations discarded. `float` a number representing the degree of precision to use: for single-precision floating point use 0, for or double-precision floating point use 1. `device` if no external pointer is provided to function, we can provide the ID of the device to use. `parameters` a 9 dimensional vector of parameters to tune the GPU implementation.

## Details

Classic multinomial logistic regression for classifiction.

We assume that β_J = 0 for purposes of identification.

## Value

`mlr` returns a list.

 `beta` a samp x P x J-1 array; the posterior sample of the regression coefficients. `w` a samp x N' x J-1 array; the posterior sample of the latent variable. WARNING: N' may be less than N if data is combined. `y` the response matrix–different than input if data is combined. `X` the design matrix–different than input if data is combined. `n` the number of samples at each observation–different than input if data is combined.

`rpg,lasso`
 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## Use the iris dataset. data(iris) N <- nrow(iris) P <- ncol(iris) J <- nlevels(iris\$Species) X <- model.matrix(Species ~ ., data=iris); y.all <- model.matrix(~ Species - 1, data=iris); y <- y.all[,-J]; out <- mlr(y, X, samp=1000, burn=100, device=0); ```