Skip to content

Commit

Permalink
WLS for feols() (#273)
Browse files Browse the repository at this point in the history
* add support for WLS
* speed up testing
* small documentation updates
  • Loading branch information
s3alfisc authored Jan 31, 2024
1 parent 24eafdd commit 8576859
Show file tree
Hide file tree
Showing 52 changed files with 702 additions and 10,412 deletions.
2 changes: 1 addition & 1 deletion docs/difference-in-differences.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<a class="nav-link" href="./replicating-the-effect.html">Replicating ‘The Effect’ with PyFixest</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./reference/index.qmd">Documentation</a>
<a class="nav-link" href="./reference/index.html">Documentation</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./news.html">Changelog</a>
Expand Down
8 changes: 4 additions & 4 deletions docs/news.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ <h2 class="anchored" data-anchor-id="pyfixest-0.14.0">PyFixest 0.14.0</h2>
</div>
<div class="cell-output cell-output-display">

<div id="LxCHXR"></div>
<div id="9KYwVr"></div>
<script type="text/javascript" data-lets-plot-script="library">
if(!window.letsPlotCallQueue) {
window.letsPlotCallQueue = [];
Expand All @@ -206,7 +206,7 @@ <h2 class="anchored" data-anchor-id="pyfixest-0.14.0">PyFixest 0.14.0</h2>
(function() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.2.0/js-package/distr/lets-plot.min.js";
script.src = "https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.0.1/js-package/distr/lets-plot.min.js";
script.onload = function() {
window.letsPlotCall = function(f) {f();};
window.letsPlotCallQueue.forEach(function(f) {f();});
Expand All @@ -219,9 +219,9 @@ <h2 class="anchored" data-anchor-id="pyfixest-0.14.0">PyFixest 0.14.0</h2>
var div = document.createElement("div");
div.style.color = 'darkred';
div.textContent = 'Error loading Lets-Plot JS';
document.getElementById("LxCHXR").appendChild(div);
document.getElementById("9KYwVr").appendChild(div);
};
var e = document.getElementById("LxCHXR");
var e = document.getElementById("9KYwVr");
e.appendChild(script);
})()
</script>
Expand Down
7 changes: 7 additions & 0 deletions docs/news.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# News

## PyFixest 0.15.0

- Adds support for weighted least squares for `feols()`.
- Reduces testing time drastically by running tests on fewer random data samples. Qualitatively,
the set of test remains identical.
- Some updates for future `pandas` compatibility.

## PyFixest 0.14.0

- Moves the documentation to [quartodoc](https://github.com/machow/quartodoc).
Expand Down
22 changes: 22 additions & 0 deletions docs/reference/demean.demean.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# demean.demean { #pyfixest.demean.demean }

`demean.demean(x, flist, weights, tol=1e-08, maxiter=100000)`

Workhorse for demeaning an input array `x` based on the specified fixed effects and weights
via the alternating projections algorithm.

## Parameters

| Name | Type | Description | Default |
|-----------|---------------------|----------------------------------------------------------------------------------------------------------------|------------|
| `x` | numpy.numpy.ndarray | Input array of shape (n_samples, n_features). Needs to be of type float. | _required_ |
| `flist` | numpy.numpy.ndarray | Array of shape (n_samples, n_factors) specifying the fixed effects. Needs to already be converted to integers. | _required_ |
| `weights` | numpy.numpy.ndarray | Array of shape (n_samples,) specifying the weights. | _required_ |
| `tol` | float | Tolerance criterion for convergence. Defaults to 1e-08. | `1e-08` |
| `maxiter` | int | Maximum number of iterations. Defaults to 100_000. | `100000` |

## Returns

| Type | Description |
|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| typing.Tuple\[numpy.numpy.ndarray, bool\] | A tuple containing the demeaned array of shape (n_samples, n_features) and a boolean indicating whether the algorithm converged successfully. |
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# detect_singletons { #pyfixest.detect_singletons }

`detect_singletons`



## Functions

| Name | Description |
| --- | --- |
| [detect_singletons](#pyfixest.detect_singletons.detect_singletons) | Detect singleton fixed effects in a dataset. |

### detect_singletons { #pyfixest.detect_singletons.detect_singletons }
# detect_singletons.detect_singletons { #pyfixest.detect_singletons.detect_singletons }

`detect_singletons.detect_singletons(ids)`

Expand All @@ -19,19 +7,19 @@ Detect singleton fixed effects in a dataset.
This function iterates over the columns of a 2D numpy array representing fixed effects to identify singleton fixed effects.
An observation is considered a singleton if it is the only one in its group (fixed effect identifier).

#### Parameters
## Parameters

| Name | Type | Description | Default |
|--------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| `ids` | numpy.numpy.ndarray | A 2D numpy array representing fixed effects, with a shape of (n_samples, n_features). Elements should be non-negative integers representing fixed effect identifiers. | _required_ |

#### Returns
## Returns

| Type | Description |
|---------------------|-----------------------------------------------------------------------------------------------------|
| numpy.numpy.ndarray | A boolean array of shape (n_samples,), indicating which observations have a singleton fixed effect. |

#### Notes
## Notes

The algorithm iterates over columns to identify fixed effects. After each column is processed, it updates the record of
non-singleton rows. This approach accounts for the possibility that removing an observation in one column can lead to the
Expand Down
Loading

0 comments on commit 8576859

Please sign in to comment.