Skip to content

The Julia package for estimating and testing a generalized linear mixed model with normal mixture random effects

License

Notifications You must be signed in to change notification settings

panlanfeng/LatentGaussianMixtureModel.jl

Repository files navigation

LatentGaussianMixtureModel

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 levels
  • model_response returns the response Y
  • coef returns the fixed effects β
  • ranef! return the predict random effects
  • stderror gives the standard error of fixed effects
  • confint calculates the confidence interval
  • coeftable prints the fixed effects and their p values
  • loglikelihood calculates the log marginal likelihood
  • vcov returns the covariance matrix of fixed effects
  • asymptoticdistribution returns the simulated asymptotic distribution of the restricted likelihood ratio test
  • predict computes the probability of Y being 1 at given new data
  • FDR detect the "outstanding" random effects while controlling the False Discovery Rate.

For example,

coef(m)
coeftable(m)
loglikelihood(m)

About

The Julia package for estimating and testing a generalized linear mixed model with normal mixture random effects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages