Learn R Programming

pglm (version 0.1-0)

pglm: Panel Estimators for Generalized Linear Models

Description

Estimation by maximum likelihood of glm (binomial and Poisson) and 'glm-like' models (Negbin and ordered) on longitudinal data

Usage

pglm(formula, data, subset, na.action,
     effect = c("individual", "time", "twoways"),
     model = c("random", "pooling", "within", "between"),
     family, other = NULL, index = NULL, start = NULL, R = 20,  ...)

Arguments

formula
a symbolic description of the model to be estimated,
data
the data: a pdata.frame object or an ordinary data.frame,
subset
an optional vector specifying a subset of observations,
na.action
a function which indicates what should happen when the data contains 'NA's,
effect
the effects introduced in the model, one of "individual", "time" or "twoways",
model
one of "pooling", "within", "between", "random",,
family
the distribution to be used,
other
for developper's use only,
index
the index,
start
a vector of starting values,
R
the number of function evaluation for the gaussian quadrature method used,
...
further arguments.

Value

  • An object of class "pglm", a list with elements:
  • coefficientsthe named vector of coefficients,
  • logLikthe value of the log-likelihood,
  • hessianthe hessian of the log-likelihood at convergence,
  • gradientthe gradient of the log-likelihood at convergence,
  • callthe matched call,
  • est.statsome information about the estimation (time used, optimisation method),
  • freqthe frequency of choice,
  • residualsthe residuals,
  • fitted.valuesthe fitted values,
  • formulathe formula (a mFormula object),
  • expanded.formulathe formula (a formula object),
  • modelthe model frame used,
  • indexthe index of the choice and of the alternatives.

Examples

Run this code
## an ordered probit example
data('Fairness', package = 'pglm')
op <- pglm(as.numeric(answer)~recurring+driving+education+rule+
          education:rule, Fairness[Fairness$good == 'parking',],
          family=ordinal('probit'), R=5, print.level=0,
          method='bfgs', index='id', iterlim=2, model="random")

## a binomial (logit) example
data('Unions', package = 'pglm')
anb <- pglm(union~wage+exper+rural, Unions, family=binomial('probit'),
model="pooling",  method = "bfgs", print.level=0, R = 5, iterlim=2)

## a gaussian example on unbalanced panel data
data(Hedonic, package = "plm")
ra <- pglm(mv~crim+zn+indus+nox+age+rm, Hedonic, family=gaussian,
model="random", print.level=0, method="nr",index="townid")

## some count data models
data("PatsRD", package="pglm")
la <- pglm(pat~lag(logr, 0:5)+scisect+logk+factor(year), PatsRD,
family=negbin,model="within", print.level=0, method="nr",
index=c('cusip', 'year'))
la <- pglm(pat~lag(logr, 0:5)+scisect+logk+factor(year), PatsRD,
family=poisson,model="pooling", index=c("cusip", "year"), print.level=0,
method="nr")

## a tobit example
data("HealthIns", package="pglm")
HealthIns$med2 <- HealthIns$med / 1000
HealthIns2 <- HealthIns[-2209, ]
la <- pglm(med~mdu+disease+age,HealthIns2,
model='random',family='tobit', print.level=0, method='nr', R=5)

Run the code above in your browser using DataLab