Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just to show diff in quf.cpp #8

Closed
wants to merge 24 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -15,3 +15,5 @@
^_AUTO_BENCHMARK$
^CONTRIBUTORS\.md$
^.vscode
^dev$
^vscode-install.r$
@@ -1,7 +1,7 @@
Package: fixest
Type: Package
Title: Fast Fixed-Effects Estimations
Version: 0.10.6
Version: 0.11.0
Authors@R:
c(person(given = "Laurent",
family = "Berge",
@@ -15,19 +15,18 @@ Authors@R:
role = "ctb",
email = "grantmcd@uoregon.edu",
comment = c(ORCID = "0000-0001-7883-8573")))
Imports: stats, graphics, grDevices, tools, utils, methods, numDeriv, nlme, sandwich, Rcpp(>= 1.0.5), dreamerr(>= 1.2.3)
Imports: stats, graphics, grDevices, tools, utils, methods, numDeriv, nlme, sandwich, dreamerr(>= 1.2.3)
Suggests: knitr, rmarkdown, data.table, plm, MASS, pander, ggplot2, lfe, tinytex, pdftools
LinkingTo: Rcpp
LinkingTo: cpp11
SystemRequirements: C++11
Depends: R(>= 3.5.0)
Description: Fast and user-friendly estimation of econometric models with multiple fixed-effects. Includes ordinary least squares (OLS), generalized linear models (GLM) and the negative binomial.
The core of the package is based on optimized parallel C++ code, scaling especially well for large data sets. The method to obtain the fixed-effects coefficients is based on Berge (2018) <https://wwwen.uni.lu/content/download/110162/1299525/file/2018_13>.
Further provides tools to export and view the results of several estimations with intuitive design to cluster the standard-errors.
License: GPL-3
BugReports: https://github.com/lrberge/fixest/issues
URL: https://lrberge.github.io/fixest/, https://github.com/lrberge/fixest
SystemRequirements: C++11
VignetteBuilder: knitr
LazyData: true
RoxygenNote: 7.1.2
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
@@ -21,6 +21,8 @@ export(check_conv_feols)
export(did_means)
# graph
export(coefplot, iplot)
# small funs
export(coeftable, se, tstat, pvalue)
# dof
export(dof, ssc, degrees_freedom)
# Lag related
@@ -29,34 +31,15 @@ export(panel, unpanel, f, l, d, lag_fml)
export(i, bin, ref)
# macro
export(xpd)
# multiple estimations
export(models)
# utilities
export(to_integer, demean, obs)
export(as.dict)
# setters & getters
exportPattern("^(s|g)etFixest")

# coeftable and co
export(coeftable, se, pvalue, tstat)
S3method(coeftable, default)
S3method(coeftable, fixest)
S3method(coeftable, fixest_multi)
S3method(se, default)
S3method(se, matrix)
S3method(se, fixest)
S3method(se, fixest_multi)
S3method(pvalue, default)
S3method(pvalue, fixest)
S3method(pvalue, fixest_multi)
S3method(tstat, default)
S3method(tstat, fixest)
S3method(tstat, fixest_multi)

# VCOV funs
export(vcov_cluster, vcov_DK, vcov_NW, vcov_conley)

# Data manipulation
# other stuff
export(n_unik, osize, sample_df)

# dsb
@@ -82,6 +65,7 @@ S3method("[", fixest_panel) # Lag related
# fixest_multi
S3method("[", fixest_multi)
S3method("[[", fixest_multi)
S3method("$", fixest_multi)
S3method(print, fixest_multi)
S3method(summary, fixest_multi)
S3method(as.list, fixest_multi)
@@ -147,8 +131,7 @@ export(estfun, bread)

importFrom(stats, cor, dnorm, lm, nlminb, optim,
pnorm, qnorm, as.formula, var, sd, formula,
na.omit, model.frame, "na.pass", poisson, pt, hatvalues,
quasibinomial)
na.omit, model.frame, "na.pass", poisson, pt, hatvalues)

# stats methods
importFrom(stats, model.matrix, sigma, deviance, weights, terms,
186 NEWS.md
@@ -1,190 +1,4 @@

# fixest 0.10.5

## Bug fixes

- fix bug in function `coef()` leading to methods to throw errors in R devel. Thanks to @vincentarelbundock for reporting ([#291](https://github.com/lrberge/fixest/issues/291)).

- fix bug in the `predict` method when applied to objects estimated with `feNmlm`. Thanks again to @vincentarelbundock for reporting ([#292](https://github.com/lrberge/fixest/issues/292))!

- fix missing variable names in the VCOV matrix of `feNmlm` models. Thanks (yet again!) to @vincentarelbundock for reporting ([#293](https://github.com/lrberge/fixest/issues/293)). Comme on dit : jamais deux sans trois !

- fix display bug in cluster names in `etable`.

- fix bug in IV estimations with no exogenous variable and no fixed-effect (thanks to Kyle Butts [#296](https://github.com/lrberge/fixest/issues/296)).

- fix bug panel vs panel.id behaving differently in terms of default type of VCOV when the estimation did not contained lags.

- fix bug in `confint.fixest` when only one variable was estimated (thanks to @joachim-gassen [#296](https://github.com/lrberge/fixest/issues/296)).

- fix several bugs in predict when using `i()`, in particular when used in combination with a factor or `poly()` (reported by @rfbressan [#301](https://github.com/lrberge/fixest/issues/301)).

- fix bug in `etable` relating to ampersands not being correctly escaped.

## New functions

- new function `degrees_freedom_iid` which is a more user-friendly version of `degrees_freedom`.

## Multiple estimations

- new internal algorithm leading to an object very much like a plain list, much easier to interact with.

- new function `models` to extract the matrix of informing on which model has been estimated.

- in multiple estimations: all warnings are turned to notes and all notes are delayed and stacked.

- `coef.fixest_multi`: Now reports the model of each estimation in the first columns. Also gains the arguments `collin`, `long` (to display the results in a long format) and `na.rm`.

- new methods: `coeftable.fixest_multi`, `se.fixest_multi`, `tstat.fixest_multi`, `pvalue.fixest_multi` to easily extract the results from multiple estimations.

## xpd

- new argument `add` to facilitate adding elements to the formula.

- new argument `frame` to tell where to fetch the values of the variables expanded with the dot square bracket operator.

- regex values can be negated: just start with a `!`:
```R
xpd(am ~ ..("!^am"), data = mtcars)
#> am ~ mpg + cyl + disp + hp + drat + wt + qsec + vs + gear + carb
```

- auto-completion of variables names is now enabled with the '..' suffix.
```R
base = setNames(iris, c("y", "x1", "x2", "x3", "species"))
xpd(y ~ x.., data = base)
#> y ~ x1 + x2 + x3
feols(y ~ x.., base)
#> OLS estimation, Dep. Var.: y
#> Observations: 150
#> Standard-errors: IID
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.855997 0.250777 7.40098 9.8539e-12 ***
#> x1 0.650837 0.066647 9.76538 < 2.2e-16 ***
#> x2 0.709132 0.056719 12.50248 < 2.2e-16 ***
#> x3 -0.556483 0.127548 -4.36293 2.4129e-05 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 0.310327 Adj. R2: 0.855706
```

- when using `xpd` in non-fixest functions, the algorithm tries to guess the `data` so that calls to `..("regex")` or auto-completion can be used seamlessly.
```R
lm(xpd(y ~ x..), base)
#> Call:
#> lm(formula = xpd(y ~ x..), data = base)
#>
#> Coefficients:
#> (Intercept) x1 x2 x3
#> 1.8560 0.6508 0.7091 -0.5565
```

- the dot-square-bracket operator in `xpd` also expands one-sided formulas:
```R
x_all = ~sepal + petal
xpd(color ~ .[x_all])
#> color ~ sepal + petal
```

## etable

- in the argument `fitstat`, the formula is now automatically expanded with `xpd`. This means that you can set fit statistics macro which can be summoned from `etable`. Useful to set default fit statistics for: IVs, GLMs, etc.
```R
base = setNames(iris, c("y", "x1", "x2", "x3", "species"))
est = feols(y ~ csw(x.[,1:3]), base)

# setting the macro
setFixest_fml(..fit_ols = ~ n + ar2 + my)

# summoning it
etable(est, fitstat = ~..fit_ols)
#> est.1 est.2 est.3
#> Dependent Var.: y y y
#>
#> Constant 6.526*** (0.4789) 2.249*** (0.2480) 1.856*** (0.2508)
#> x1 -0.2234 (0.1551) 0.5955*** (0.0693) 0.6508*** (0.0667)
#> x2 0.4719*** (0.0171) 0.7091*** (0.0567)
#> x3 -0.5565*** (0.1275)
#> _______________ _________________ __________________ ___________________
#> S.E. type IID IID IID
#> Observations 150 150 150
#> Adj. R2 0.00716 0.83800 0.85571
#> Dep. Var. mean 5.8433 5.8433 5.8433
```
- now there is support for models with no coefficient (only fixed-effects).

- the application of markdown markup is now more robust and can also be escaped with a backslash. The escaping has been ported to c++.

## coeftable

- it gains the argument `list`. If `TRUE`, then the result is returned in a list form. Useful in Rmarkdown documents for quick reference to specific values.
```R
est = feols(mpg ~ cyl + drat + wt, mtcars)
ct = coeftable(est, list = TRUE)
ct$constant$coef
#> Estimate
#> 39.76766
ct$wt$se
#> Std. Error
#> 0.8293065
```

## All estimations

- arguments `split` and `fsplit` gain the `%keep%` and `%drop%` operators which allow to split the sample only on a subset of elements. All estimations also gain the arguments `split.keep` and `split.drop` which do the same thing as the previous operators.
```
base = setNames(iris, c("y", "x1", "x2", "x3", "species"))
est = feols(y ~ x.[1:3], base, fsplit = ~species %keep% c("set", "vers"))
etable(est)
#> model 1 model 2 model 3
#> Sample (species) Full sample setosa versicolor
#> Dependent Var.: y y y
#>
#> (Intercept) 1.856*** (0.2508) 2.352*** (0.3929) 1.896*** (0.5071)
#> x1 0.6508*** (0.0667) 0.6548*** (0.0925) 0.3869. (0.2045)
#> x2 0.7091*** (0.0567) 0.2376 (0.2080) 0.9083*** (0.1654)
#> x3 -0.5565*** (0.1275) 0.2521 (0.3469) -0.6792 (0.4354)
#> ________________ ___________________ __________________ __________________
#> S.E. type IID IID IID
#> Observations 150 50 50
#> R2 0.85861 0.57514 0.60503
#> Adj. R2 0.85571 0.54743 0.57927
```

## Other

- remove warnings when a binomial family is used with weights in `feglm`.

- add the arguments `y`, `X`, `weights`, `endo`, `inst` to the function `est_env` to make it more user-friendly.

- fix documentation typos (thanks to Caleb Kwon).

- `etable` now returns a `data.frame` whose first column is the variables names (before this was contained in the row names).

- fix environment problems when `lean = TRUE`, leading to large objects when saved on disk.

- `print.fixest` now displays the information on the sample/subset/offset/weights.

- add a new way to create dictionaries with `as.dict`:
```R
x = "
# Main vars
mpg: Miles per gallon
hp: Horsepower

# Categorical variables
cyl: Number of cylinders; vs: Engine"

as.dict(x)
#> mpg hp cyl vs
#> "Miles per gallon" "Horsepower" "Number of cylinders" "Engine"

# setFixest_dict works directly with x
setFixest_dict(x)
```
- `setFixest_dict`: i) now the dictionary only grows, ii) you can define variables directly in the arguments of `setFixest_dict`, iii) `as.dict` is applied to the dictionary if relevant, iv) there's a new argument `reset`.


# fixest 0.10.4

## Hot fix