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
?LGMModel
and see arguments for fit!
by
?fit!
The LGMModel
object is a subtype of RegressionModel
and the following methods are available:
nobs
returns the number of random effect levelsmodel_response
returns the responseY
coef
returns the fixed effectsβ
ranef!
return the predict random effectsstderror
gives the standard error of fixed effectsconfint
calculates the confidence intervalcoeftable
prints the fixed effects and their p valuesloglikelihood
calculates the log marginal likelihoodvcov
returns the covariance matrix of fixed effectsasymptoticdistribution
returns the simulated asymptotic distribution of the restricted likelihood ratio testpredict
computes the probability ofY
being 1 at given new dataFDR
detect the "outstanding" random effects while controlling the False Discovery Rate.
For example,
coef(m)
coeftable(m)
loglikelihood(m)