From 57f19d59da77911ef59c1ce503c6799f2c613271 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Nov 2024 12:07:37 +0100 Subject: [PATCH] fix --- R/methods_fixest.R | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/R/methods_fixest.R b/R/methods_fixest.R index 83cd8c444..8f02249b1 100644 --- a/R/methods_fixest.R +++ b/R/methods_fixest.R @@ -78,11 +78,13 @@ standard_error.fixest <- function(model, vcov = NULL, vcov_args = NULL, ...) { SE <- as.vector(stats$se) # sometimes, the correct SEs are in the `coeftable`. In this case, # SE from summary have different length - stats <- model$coeftable - SE_ct <- .safe(as.vector(stats[, "Std. Error"])) - # if this fails extract from summary - if (!is.null(SE_ct) && length(SE_ct) < length(SE)) { - SE <- SE_ct + if (length(SE) != nrow(params)) { + SE <- NULL + stats <- model$coeftable + SE_ct <- .safe(as.vector(stats[, "Std. Error"])) + if (!is.null(SE_ct) && length(SE_ct) == nrow(params)) { + SE <- SE_ct + } } } else { # we don't want to wrap this in a tryCatch because the `fixest` error is @@ -91,6 +93,11 @@ standard_error.fixest <- function(model, vcov = NULL, vcov_args = NULL, ...) { SE <- sqrt(diag(V)) } + if (is.null(SE)) { + SE <- NA + insight::format_alert("Could not extract standard errors. Please file an issue at https://github.com/easystats/parameters/issues/") + } + .data_frame( Parameter = params$Parameter, SE = SE