inst/doc/htobit-tex.R

### R code from vignette source 'htobit-tex.Rnw'

###################################################
### code chunk number 1: preliminaries
###################################################
options(width = 70, prompt = "R> ", continue = "+  ")
library("htobit")
library("car")
library("crch")
library("lmtest")
library("memisc")


###################################################
### code chunk number 2: verbeek
###################################################
data("AlcoholTobacco", package = "htobit")
library("htobit")
ma <- htobit(alcohol ~ (age + adults) * log(expenditure) + oldkids + youngkids,
  data = AlcoholTobacco)
summary(ma)


###################################################
### code chunk number 3: restrictions
###################################################
library("car")
linearHypothesis(ma, "oldkids = youngkids")
linearHypothesis(ma, "oldkids = adults")


###################################################
### code chunk number 4: alternative
###################################################
AlcoholTobacco$persons <- with(AlcoholTobacco, adults + oldkids + youngkids)
ma2 <- htobit(alcohol ~ (age + adults) * log(expenditure) + oldkids + youngkids |
  (age + adults) * log(expenditure) + oldkids + youngkids, data = AlcoholTobacco)
ma3 <- htobit(alcohol ~ age + log(expenditure) + persons | age +
  log(expenditure) + persons, data = AlcoholTobacco)
BIC(ma, ma2, ma3)


###################################################
### code chunk number 5: lrtest
###################################################
library("lmtest")
lrtest(ma, ma2, ma3)


###################################################
### code chunk number 6: crch
###################################################
library("crch")
ca3 <- crch(alcohol ~ age + log(expenditure) + persons | age +
  log(expenditure) + persons, data = AlcoholTobacco, left = 0)


###################################################
### code chunk number 7: mtable (eval = FALSE)
###################################################
## library("memisc")
## mtable("htobit" = ma3, "crch" = ca3)


###################################################
### code chunk number 8: mtable-latex
###################################################
toLatex(mtable("htobit" = ma3, "crch" = ca3))

Try the htobit package in your browser

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

htobit documentation built on June 19, 2019, 3 a.m.