R/FitHGLMBC.R
hglmbc.Rd
hglmbc
is used to fit hierarchical generalized linear models using h-likelihood
with bias correction in small area estimation (SAE) for exponential
family distributions with normally distributed random effects.
hglmbc( data, mformula = NULL, dom = NULL, y.family = "binomial", rand.family = "gaussian", tol = 1e-05, ... )
data | a data frame. |
---|---|
mformula | an object of class |
dom | a domain/cluster/small area to specify the random effect. e.g. numeric zipcode, county, or state code, and also name of the county or name of the state. |
y.family | a distribution from _exponential family_ to describe the error distribution. See
|
rand.family | a discription of the distribution of random effects. |
tol | predefined tolerance value. Default value is tol=1e-10. |
... | other arguments, See details section. |
An object of class hglmbc
consists of the hierarchical maximum likelihood estimates (HMLEs)
of fixed effects, random effects, and variance parameters with other values,
HMLE of fixed effects.
HMLE of the random effects.
HMLE of the dispersion parameter for the random effects.
the estimated variance-covariance matrix of the fixed effects.
the estimated vaiance-covaraince matrix of the random effects.
number of iterations at convergence.
A list of likelihood values for model selection purposes,where AIC
is
the AIC
value, BIC is the BIC
value ("AIC"
), hLik
is the h-likelihood
value.
a summary object of the fitted model.
A typical model has the form response ~ terms
where the response is the (numeric)
vector and terms
is a series of terms which specifies a linear predictor for response
.
A terms are specified as a linear combination of predictors, in Small Area Estiamtion (SAE), it is
a vector of fixed effects. e.g. y ~ x1 + x2 + as.factor(x3)
.
If a formula
is not defined, the user can input the response variable, resp
, a vector
of fixed effects, such as fe.disc
for categorical variables and fe.cont
for continuous
variables. If not, the user can define the resp
, then, it will automatically select the
fixed effects
based on the variable types.
The hglmbc
function also has the flexibility to use different reference category for factor
variables. e.g. ref.group
can be defined for each categorical variable. By default the
reference group will be considered in alphebetical order or numerical order. In order to use a different
reference group, ref.group
needs to be defined. e.g. for categorical variables
age (groups: 1, 2, 3), if the prefered reference group is 2, then set ref.group = "age2"
.
if (FALSE) { # Using ever use of smoke data set. Discrete and continuous variables are defined. 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" hglmbc.fit <- hglmbc(data=eversmoke, mformula, dom = "county", y.family="binomial") # mformula is not defined, resp <- "smoke_ever" dom <- "county" catX <- c("year","gender","race","age") contX <- "povt_rate" hglmbc.fit <- hglmbc(data = eversmoke, resp, dom = "county",fe.disc = catX, fe.cont = contX, y.family = "binomial") # Poisson-Normal HGLM N = 1000 p = 20 nVars = 5 x = matrix(rnorm(N * p), N, p) beta = rnorm(nVars) f = x[, seq(nVars)] %*% beta mu = exp(f) y = rpois(N, mu) }