From 3d28d72aabb37408c96e4d10106be8b7e65570fa Mon Sep 17 00:00:00 2001 From: cchoirat Date: Wed, 10 Dec 2014 19:15:00 -0500 Subject: [PATCH] Getters: coef, vcov, predict #53 --- R/model-zelig.R | 53 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/R/model-zelig.R b/R/model-zelig.R index db15f55b..15df6b52 100755 --- a/R/model-zelig.R +++ b/R/model-zelig.R @@ -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)) @@ -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 @@ -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)