-
Notifications
You must be signed in to change notification settings - Fork 43
/
model-glm.R
executable file
·33 lines (30 loc) · 1.16 KB
/
model-glm.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#' Generalized Linear Model object for inheritance across models in Zelig
#'
#' @import methods
#' @export Zelig-glm
#' @exportClass Zelig-glm
#'
#' @include model-zelig.R
zglm <- setRefClass("Zelig-glm",
contains = "Zelig",
fields = list(family = "character",
link = "character",
linkinv = "function"))
zglm$methods(
initialize = function() {
callSuper()
.self$fn <- quote(stats::glm)
.self$packageauthors <- "R Core Team"
.self$acceptweights <- FALSE # "Why glm refers to the number of trials as weight is a trick question to the developers' conscience."
}
)
zglm$methods(
zelig = function(formula, data, ..., weights = NULL, by = NULL, bootstrap = FALSE) {
.self$zelig.call <- match.call(expand.dots = TRUE)
.self$model.call <- .self$zelig.call
.self$model.call$family <- call(.self$family, .self$link)
callSuper(formula = formula, data = data, ..., weights = weights, by = by, bootstrap = bootstrap)
rse <- lapply(.self$zelig.out$z.out, (function(x) vcovHC(x, type = "HC0")))
.self$test.statistics <- list(robust.se = rse)
}
)