Skip to content

malloc error with fixef() #630

@pachadotdev

Description

@pachadotdev

Hi

Sorry the dumb issue but I keep getting this while comparing the slopes with base R, alpaca and capybara.

library(dplyr)
library(tidyr)
library(janitor)
library(haven)
library(fixest)

url <- "https://prod-dcd-datasets-cache-zipfiles.s3.eu-west-1.amazonaws.com/n67gft8fvm-1.zip"
zip <- "~/Documents/phd-thesis/capybara-benchmarks/The Tails of Gravity.zip"
dir <- "~/Documents/phd-thesis/capybara-benchmarks/The Tails of Gravity"

if (!file.exists(zip)) {
    download.file(url, destfile = zip, mode = "wb")
}

if (!file.exists(dir)) {
    unzip(zip, exdir = "~/Documents/phd-thesis/capybara-benchmarks/")
    zip2 <- "~/Documents/phd-thesis/capybara-benchmarks/The Tails of Gravity/Tails of Gravity data.zip"
    unzip(
        zip2,
        exdir = "~/Documents/phd-thesis/capybara-benchmarks/The Tails of Gravity"
    )
}

zip <- file.path(Sys.getenv("HOME"), "Documents/phd-thesis/capybara-benchmarks/The Tails of Gravity.zip")
exdir <- file.path(Sys.getenv("HOME"), "Documents/phd-thesis/capybara-benchmarks")
data_dta <- file.path(exdir, "The Tails of Gravity", "Tails of Gravity data.dta")

data_table4 <- haven::read_dta(data_dta)

# replicate the minimal preprocessing from the original script
data_table4 <- data_table4 %>%
  clean_names() %>%
  select(year, iso_o, iso_d, dist, contig, fta, trade = trade_x) %>%
  mutate(
    etfe = paste0(iso_o, year),
    itfe = paste0(iso_d, year),
    pair = paste0(iso_o, "_", iso_d)
  ) %>%
  filter(year %in% seq(min(year), max(year), 5)) %>%
  select(-c(iso_o, iso_d)) %>%
  drop_na() %>%
  filter(year <= quantile(data_table4$year, 0.75))

fit <- feglm(
  trade ~ log(dist) + contig + fta | etfe + itfe,
  data = data_table4,
  cluster = ~pair,
  family = "poisson"
)

fit$fixed_effects <- fixef(fit)

=> result malloc(): unsorted double linked list corrupted

I made sure I have sufficient free memory (it is not a quite large dataset)

here is my session info:

> sessionInfo()
R version 4.5.2 (2025-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Manjaro Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.12.0.backup 
LAPACK: /usr/lib/libopenblas.so.0.3;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/London
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] fixest_0.13.2  haven_2.5.5    janitor_2.2.1  tidyr_1.3.1    dplyr_1.1.4   
[6] devtools_2.4.6 usethis_3.2.1 

loaded via a namespace (and not attached):
 [1] compiler_4.5.2      Rcpp_1.1.0          tidyselect_1.2.1   
 [4] stringr_1.6.0       snakecase_0.11.1    fastmap_1.2.0      
 [7] lattice_0.22-7      R6_2.6.1            generics_0.1.4     
[10] Formula_1.2-5       forcats_1.0.1       tibble_3.3.0       
[13] lubridate_1.9.4     pillar_1.11.1       rlang_1.1.6        
[16] cachem_1.1.0        stringi_1.8.7       fs_1.6.6           
[19] stringmagic_1.2.0   pkgload_1.4.1       timechange_0.3.0   
[22] memoise_2.0.1       cli_3.6.5           magrittr_2.0.4     
[25] grid_4.5.2          remotes_2.5.0       hms_1.1.4          
[28] sandwich_3.1-1      nlme_3.1-168        lifecycle_1.0.4    
[31] vctrs_0.6.5         glue_1.8.0          numDeriv_2016.8-1.1
[34] zoo_1.8-14          sessioninfo_1.2.3   pkgbuild_1.4.8     
[37] dreamerr_1.5.0      purrr_1.2.0         tools_4.5.2        
[40] pkgconfig_2.0.3     ellipsis_0.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions