Skip to content

Commit

Permalink
fix bug in hatvalues.ivreg(); correct some @exportS3Method markup
Browse files Browse the repository at this point in the history
  • Loading branch information
john-d-fox committed Aug 21, 2024
1 parent 234b00e commit 7c697bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ivreg
Title: Instrumental-Variables Regression by '2SLS', '2SM', or '2SMM', with Diagnostics
Version: 0.6-3
Date: 2024-04-20
Version: 0.6-4
Date: 2024-08-21
Authors@R: c(person(given = "John", family = "Fox", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0002-1196-8012")),
person(given = "Christian", family = "Kleiber", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0002-6781-4733")),
person(given = "Achim", family = "Zeileis", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0918-3766")),
Expand Down Expand Up @@ -32,4 +32,4 @@ LazyData: true
VignetteBuilder: knitr
BugReports: https://github.com/zeileis/ivreg/issues/
URL: https://zeileis.github.io/ivreg/
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.6-4

* Fixed bug in computing larger of stage-1 and -2 hatvalues in `hatvalues.ivreg()` (reported by Vasilis Syrgkanis).

# Version 0.6-3

* Enhanced `predict.ivreg()` method, which optionally provides standard errors,
Expand Down
2 changes: 1 addition & 1 deletion R/ivregDiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ hatvalues.ivreg <- function(model, type = c("stage2", "both", "maximum", "stage1
# model$coefficients1)
# hat1 <- lm.influence(model)$hat/mean1
hat1 <- if (model$method == "OLS"){
hats[, "stage_1"]
hats[, "stage_1"]/mean1
} else {
nendog <- ncol(hats) - 1
if (type == "both"){
Expand Down
10 changes: 5 additions & 5 deletions R/ivregMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ confint.ivreg <- function (object, parm, level = 0.95,
}

#' @rdname ivregMethods
#' @exportS3Method sandwich::bread ivreg
#' @exportS3Method sandwich::bread
bread.ivreg <- function (x, ...)
x$cov.unscaled * x$nobs

#' @rdname ivregMethods
#' @importFrom stats weights
#' @exportS3Method sandwich::estfun ivreg
#' @exportS3Method sandwich::estfun
estfun.ivreg <- function (x, ...)
{
xmat <- model.matrix(x, component = "projected")
Expand All @@ -157,7 +157,7 @@ estfun.ivreg <- function (x, ...)
}

#' @rdname ivregMethods
#' @exportS3Method sandwich::vcovHC ivreg
#' @exportS3Method sandwich::vcovHC
vcovHC.ivreg <- function (x, ...) {
class(x) <- c("ivreg_projected", "ivreg")
sandwich::vcovHC.default(x, ...)
Expand Down Expand Up @@ -659,7 +659,7 @@ residuals.ivreg <- function(object, type=c("response", "projected", "regressors"

#' @rdname ivregMethods
#' @param focal.predictors Focal predictors for effect plot, see \code{\link[effects:effect]{Effect}}.
#' @exportS3Method effects::Effect ivreg
#' @exportS3Method effects::Effect
Effect.ivreg <- function (focal.predictors, mod, ...) {
mod$contrasts <- mod$contrasts$regressors
NextMethod()
Expand All @@ -680,7 +680,7 @@ formula.ivreg <- function(x, component = c("complete", "regressors", "instrument
}

#' @rdname ivregMethods
#' @exportS3Method insight::find_formula ivreg
#' @exportS3Method insight::find_formula
find_formula.ivreg <- function(x, ...) {
list(conditional=formula(x, "regressors"), instruments=formula(x, "instruments"))
}
Expand Down

0 comments on commit 7c697bd

Please sign in to comment.