inst/doc/enbin.R

### R code from vignette source 'enbin.Rnw'

###################################################
### code chunk number 1: preliminaries
###################################################
options(width = 70, prompt = "R> ", continue = "+  ")
library("enbin")
library("MASS")
library("Formula")
library("numDeriv")


###################################################
### code chunk number 2: MASS
###################################################
library(MASS)
data("RecreationDemand", package = "AER")
m1 <- glm.nb(trips ~ ., data = RecreationDemand)
summary(m1)


###################################################
### code chunk number 3: 2ndmodel
###################################################
m2 <- glm.nb(trips ~ . - income, data = RecreationDemand)
summary(m2)
library(lmtest)
lrtest(m2, m1)


###################################################
### code chunk number 4: comparison
###################################################
library(enbin)
m3 <- enbin(trips ~ . - income, data = RecreationDemand)
summary(m3)


###################################################
### code chunk number 5: varying
###################################################
m4 <- enbin(trips ~ . - income | . - income, data = RecreationDemand)
summary(m4)
AIC(m3, m4)


###################################################
### code chunk number 6: contd
###################################################
BIC(m3, m4)
lrtest(m3, m4)

Try the enbin package in your browser

Any scripts or data that you put into this service are public.

enbin documentation built on May 2, 2019, 5:57 p.m.