The Julia package for Generalized Linear Mixed Model with Normal Mixture random effects. It is named as LatentGaussianMixtureModel because we are fitting a Gaussian Mixture Model on the random effect which is latent.
To install this package, please run
Pkg.clone("https://github.com/panlanfeng/LatentGaussianMixtureModel.jl.git")To update to a new version, just run
Pkg.update()Currently this package only support single random effect on intercept with logistic link. The easiest way to use is constructing a LGMModel object via the following
using DataFrames
using LatentGaussianMixtureModel
df = readtable("data.csv")
#fit a two components mixture
m = latentgmm(Y~x1+x2+x3+(1|groupindex), df, 2)
#or
X = readcsv("X.csv");
Y=readcsv("Y.csv");
groupindex = readcsv("groupindex.csv");
m = LGMModel(X, Y, groupindex, 2)and then fit the model via the function fit!
fit!(m)The estimated parameters can accessed by
m.p, m.μ, m.σ, m.βTo do the restricted likelihood ratio test on the number of components, use the EMtest function, for example
EMtest(m)This will print out the test statistic and the p value.
See arguments available for constructing the LGMModel by running
?LGMModeland see arguments for fit! by
?fit!The LGMModel object is a subtype of RegressionModel and the following methods are available:
nobsreturns the number of random effect levelsmodel_responsereturns the responseYcoefreturns the fixed effectsβranef!return the predict random effectsstderrorgives the standard error of fixed effectsconfintcalculates the confidence intervalcoeftableprints the fixed effects and their p valuesloglikelihoodcalculates the log marginal likelihoodvcovreturns the covariance matrix of fixed effectsasymptoticdistributionreturns the simulated asymptotic distribution of the restricted likelihood ratio testpredictcomputes the probability ofYbeing 1 at given new dataFDRdetect the "outstanding" random effects while controlling the False Discovery Rate.
For example,
coef(m)
coeftable(m)
loglikelihood(m)