knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

hglmbc2

Travis build status AppVeyor build status Codecov test coverage R-CMD-check CRAN status

The goal of hglmbc2 is to make inferences in Small Area Estimation based on Hierarchical $(h-)$likelihood approach with bias correction. The model parameters are obtained through an iterative approximation based on Newton Raphson method combined with bias correction of estimates. The bias correction approach enhances the accuracy of maximum hierarchical likelihood estimates (MHLEs). This R package can be used to obtain improved MHLEs for fixed effects, random effects, and dispersion parameters for exponential family distributions with random effect $u\sim N(0, \sigma^2)$.

Installation

You can install the released version of hglmbc2 from CRAN with:

install.packages("hglmbc2")

or, you can install the development version of hglmbc2 using devtools with:

# devtools::install_github("niroshar/hglmbc2", force = TRUE)

Example: method 1

Binomial-Normal HGLM is also known as the mixed logit model in GLM family with the binary response variable and the random effect $u \sim N(0,\sigma^2)$.

library(hglmbc2)

# basic example code
data <- eversmoke
mformula <- "smoke_ever ~ as.factor(age) + as.factor(gender) + as.factor(race) + as.factor(year) + povt_rate"
dom <- "county"
y.family <- "binomial"
rand.family <- "gaussian"

# Fit the model
hglmbc.fit <- hglmbc(data = eversmoke, mformula, dom = "county", y.family = "binomial")

## MHLEs of fixed effects
hglmbc.fit$est.fe


# The distribution of y|u not defined,
hglmbc.fit1 <- hglmbc(data = eversmoke, mformula, dom = "county")

# Model fit summary
hglmbc.fit1$summary

Example: method 2

# mformula is not defined,
data <- eversmoke
resp <- "smoke_ever"
dom <- "county"
fe.disc <- c("year","gender","race","age")
fe.cont <- "povt_rate"

# hglmbc.fit <- hglmbc(data = eversmoke, resp = "smoke_ever", dom = "county",fe.disc = fe.disc,fe.cont = fe.cont, y.family = "binomial")
# hglmbc.fit


niroshar/hglmbc2 documentation built on Oct. 27, 2020, 2:22 a.m.