{"id":32157498,"url":"https://github.com/fixedeffects/interactivefixedeffectmodels.jl","last_synced_at":"2025-10-21T12:50:00.981Z","repository":{"id":35156630,"uuid":"39391781","full_name":"FixedEffects/InteractiveFixedEffectModels.jl","owner":"FixedEffects","description":"Interactive Fixed Effect Models — Bai (2009)","archived":false,"fork":false,"pushed_at":"2025-05-06T16:04:02.000Z","size":710,"stargazers_count":31,"open_issues_count":2,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T12:49:51.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"zeusees/HyperDL-Tutorial","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FixedEffects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-07-20T15:24:00.000Z","updated_at":"2025-10-14T07:31:06.000Z","dependencies_parsed_at":"2023-11-30T18:55:24.306Z","dependency_job_id":null,"html_url":"https://github.com/FixedEffects/InteractiveFixedEffectModels.jl","commit_stats":{"total_commits":420,"total_committers":9,"mean_commits":"46.666666666666664","dds":0.5214285714285714,"last_synced_commit":"58a8f702ad59f0cb37e0c38e1a4b85bcd42fc6b5"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/FixedEffects/InteractiveFixedEffectModels.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FixedEffects%2FInteractiveFixedEffectModels.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FixedEffects%2FInteractiveFixedEffectModels.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FixedEffects%2FInteractiveFixedEffectModels.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FixedEffects%2FInteractiveFixedEffectModels.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FixedEffects","download_url":"https://codeload.github.com/FixedEffects/InteractiveFixedEffectModels.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FixedEffects%2FInteractiveFixedEffectModels.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280264173,"owners_count":26300771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-21T12:49:57.013Z","updated_at":"2025-10-21T12:50:00.975Z","avatar_url":"https://github.com/FixedEffects.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status](https://github.com/FixedEffects/InteractiveFixedEffectModels.jl/workflows/CI/badge.svg)](https://github.com/FixedEffects/InteractiveFixedEffectModels.jl/actions)\n[![Coverage Status](https://coveralls.io/repos/matthieugomez/InteractiveFixedEffectModels.jl/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/matthieugomez/InteractiveFixedEffectModels.jl?branch=master)\n\n## Installation\nThe package is registered in the [`General`](https://github.com/JuliaRegistries/General) registry and so can be installed at the REPL with \n\n`] add InteractiveFixedEffectModels`.\n\n## Motivation\nThis package implements a novel, fast and robust algorithm to estimate interactive fixed effect models. \n\nThe definition of interactive fixed effects follows Bai (2009).Formally, denote `T(i)` and `I(i))` the two categorical dimensions associated with observation `i` (typically time and id).  This package estimates the set of coefficients `β`, of factors `(f1, .., fr)` and of loadings `(λ1, ..., λr)` in the model\n\n![minimization](img/minimization.png)\n\n```julia\nusing DataFrames, RDatasets, InteractiveFixedEffectModels\ndf = dataset(\"plm\", \"Cigar\")\nregife(df, @formula(Sales ~ Price + ife(State, Year, 2) + fe(State)))\n#                  Interactive Fixed Effect Model\n# ================================================================\n# Number of obs:             1380  Degree of freedom:           47\n# R2:                       0.976  R2 within:                0.435\n# Iterations:                 436  Converged:                 true\n# ================================================================\n#         Estimate Std.Error  t value Pr(\u003e|t|) Lower 95% Upper 95%\n# ----------------------------------------------------------------\n# Price  -0.425372 0.0132871 -32.0139    0.000 -0.451438 -0.399306\n# ================================================================\n```\n\n\n## Syntax\n- Formula\n\n\t- Interactive fixed effects are indicated with the function  `ife`. For instance, to specify a factor model with id variable `State`, time variable `Year`, and rank 2, use `ife(State, Year, 2)`.\n\n\t- High-dimensional Fixed effects can be used, as in `fe(State)` but only for the variables specified in the factor model. See [FixedEffectModels.jl](https://github.com/matthieugomez/FixedEffectModels.jl) for more information\n\n\t\t```julia\n\t\tregife(df, @formula(Sales ~ Price + ife(State, Year, 2)))\n\t\tregife(df, @formula(Sales ~ Price + ife(State, Year, 2) + fe(State)))\n\t\t```\n\n\tTo construct formula programatically, use\n\t```julia\n\tregife(df, Term(:Sales) ~ Term(:Price) + ife(Term(:State), Term(:Year), 2) + fe(Term(:State)))\n\t```\n- Standard errors are indicated as follows\n\t```julia\n\tVcov.robust()\n\tVcov.cluster(:State)\n\tVcov.cluster(:State, :Year)\n\t```\n- The option `weights` can add weights\n\t```julia\n\tweights = :Pop\n\t```\n\t\n- The option `method` can be used to choose between two algorithms:\n\t- `:levenberg_marquardt`\n\t- `:dogleg` \n\n- The option `save = true` saves a new dataframe storing residuals, factors, loadings and the eventual fixed effects. Importantly, the returned dataframe is aligned with the initial dataframe (rows not used in the estimation are simply filled with `missing`s).\n\n\n## FAQ\n\n\n#### Local minimum vs global minimum\nThe algorithm can estimate models with missing observations per id x time, multiple observations per id x time, and weights.\n\nHowever, in these cases, the optimization problem may have local minima. The algorithm tries to catch these cases, and, if need be, restart the optimization until the global minimum is reached. However I am not sure that all the cases are caught. \n\n\n#### Does the package estimate PCA / factor models?\n\nYes. Factor models are a particular case of interactive fixed effect models. \n\nTo estimate a factor model without any demeaning\n```julia\nusing DataFrames, RDatasets, InteractiveFixedEffectModels\ndf = dataset(\"plm\", \"Cigar\")\nregife(df, @formula(Sales ~ 0 + ife(State, Year, 2)), save = true)\n```\n\nTo demean with respect to one dimension, use \n```julia\nusing DataFrames, RDatasets, InteractiveFixedEffectModels\ndf = dataset(\"plm\", \"Cigar\")\nregife(df, @formula(Sales ~ ife(State, Year, 2) + fe(State)), save = true)\n```\n\nThe algorithm used in this package allows one to estimate models with multiple (or missing) observations per id x time.\n\n#### When should one use interactive fixed effects models?\nSome litterature using this estimation procedure::\n\n- Eberhardt, Helmers, Strauss (2013) *Do spillovers matter when estimating private returns to R\u0026D?*\n- Hagedorn, Karahan, Manovskii (2015) *Unemployment Benefits and Unemployment in the Great Recession: The Role of Macro Effects*\n- Hagedorn, Karahan, Manovskii (2015) *The impact of unemployment benefit extensions on employment: the 2014 employment miracle?* \n- Totty (2015) *The Effect of Minimum Wages on Employment: A Factor Model Approach*\n\n#### How are standard errors computed?\nErrors are obtained by regressing y on x and covariates of the form `i.id#c.year` and `i.year#c.id`. This way of computing standard errors is hinted in section 6 of of Bai (2009).\n\n#### Does this command implement the bias correction term in Bai (2009)?\nIn presence of cross or time correlation beyond the factor structure, the estimate for beta is consistent but biased (see Theorem 3 in Bai 2009, which derives the correction term in special cases). However, this package does not implement any correction. You may want to check that your residuals are approximately i.i.d (in which case there is no need for bias correction).\n\n\n## Related Packages\n- https://github.com/joidegn/FactorModels.jl : fits and predict factor models on matrices\n- https://github.com/madeleineudell/LowRankModels.jl : fits general low rank approximations on matrices\n- https://github.com/aaw/IncrementalSVD.jl: implementation of the backpropagation algorithm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffixedeffects%2Finteractivefixedeffectmodels.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffixedeffects%2Finteractivefixedeffectmodels.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffixedeffects%2Finteractivefixedeffectmodels.jl/lists"}