Skip to content

Commit

Permalink
Getters: coef, vcov, predict #53
Browse files Browse the repository at this point in the history
  • Loading branch information
cchoirat committed Dec 11, 2014
1 parent 389a338 commit 3d28d72
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions R/model-zelig.R
Expand Up @@ -335,6 +335,36 @@ z$methods(
}
)

z$methods(
getcoef = function() {
result <- try(lapply(.self$zelig.out$z.out, coef), silent = TRUE)
if ("try-error" %in% class(result))
stop("'coef' method' not implemented for model '", .self$name, "'")
else
return(result)
}
)

z$methods(
getvcov = function() {
result <- lapply(.self$zelig.out$z.out, vcov)
if ("try-error" %in% class(result))
stop("'vcov' method' not implemented for model '", .self$name, "'")
else
return(result)
}
)

z$methods(
getpredict = function() {
result <- lapply(.self$zelig.out$z.out, predict)
if ("try-error" %in% class(result))
stop("'predict' method' not implemented for model '", .self$name, "'")
else
return(result)
}
)

z$methods(
toJSON = function() {
if (!is.list(.self$json))
Expand All @@ -345,10 +375,6 @@ z$methods(
.self$json$"explanatory" <- list(modelingType = .self$explanatory)
.self$json$"vignette.url" <- .self$vignette.url
.self$json$"wrapper" <- .self$wrapper
# tree <- c(class(.self)[1], .self$.refClassDef@refSuperClasses)
# tree <- tree[tree != "envRefClass"]
# if (tail(tree, 1) != "Zelig")
# tree <- c(tree, "Zelig")
tree <- c(class(.self)[1], .self$.refClassDef@refSuperClasses)
.self$json$tree <- head(tree, match("Zelig", tree) - 1)
.self$ljson <- .self$json
Expand Down Expand Up @@ -408,6 +434,25 @@ setMethod("plot", "Zelig",
}
)

setMethod("vcov", "Zelig",
function(object, ...) {
object$getvcov()
}
)

setMethod("coef", "Zelig",
function(object, ...) {
object$getcoef()
}
)

setMethod("predict", "Zelig",
function(object, ...) {
object$getpredict()
}
)


# idx <- match(names(.self$setx.labels),
# names(.self$sim.out),
# nomatch = 0)
Expand Down

0 comments on commit 3d28d72

Please sign in to comment.