Skip to content

Commit 2a8d78e

Browse files
committed
apply proper ssr documentation
1 parent a460b61 commit 2a8d78e

25 files changed

+560
-421
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ License: Apache License (>= 2)
3737
BugReports: https://github.com/pachadotdev/capybara/issues
3838
URL: https://pacha.dev/capybara/, https://github.com/pachadotdev/capybara
3939
LazyData: true
40-
RoxygenNote: 7.3.1
40+
RoxygenNote: 7.3.2
4141
Encoding: UTF-8
4242
NeedsCompilation: yes
4343
LinkingTo: cpp11, cpp11armadillo

R/apes.R

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
#' srr_stats (tests)
2+
#' @srrstats {G1.0} Statistical Software should list at least one primary
3+
#' reference from published academic literature.
4+
#' @srrstats {G2.3} For univariate character input:
5+
#' @srrstats {G2.3a} Use `match.arg()` or equivalent where applicable to only
6+
#' permit expected values.
7+
#' @srrstats {G2.3b} Either: use `tolower()` or equivalent to ensure input of
8+
#' character parameters is not case dependent; or explicitly document that
9+
#' parameters are strictly case-sensitive.
10+
#' @noRd
11+
NULL
12+
113
#' @title Compute average partial effects after fitting binary choice models
214
#' with a 1,2,3-way error component
315
#'
@@ -10,10 +22,6 @@
1022
#'
1123
#' \strong{Remark:} The routine currently does not allow to compute average
1224
#' partial effects based on functional forms like interactions and polynomials.
13-
#'
14-
#' @srrstats {G2.3} *For univariate character input:*
15-
#' @srrstats {G2.3a} *Use `match.arg()` or equivalent where applicable to only permit expected values.*
16-
#' @srrstats {G2.3b} *Either: use `tolower()` or equivalent to ensure input of character parameters is not case dependent; or explicitly document that parameters are strictly case-sensitive.*
1725
#'
1826
#' @param object an object of class \code{"bias_corr"} or \code{"feglm"};
1927
#' currently restricted to \code{\link[stats]{binomial}}.
@@ -46,8 +54,6 @@
4654
#'
4755
#' @return The function \code{\link{apes}} returns a named list of class
4856
#' \code{"apes"}.
49-
#'
50-
#' @srrstats {G1.0} *Statistical Software should list at least one primary reference from published academic literature.*
5157
#'
5258
#' @references Cruz-Gonzalez, M., I. Fernández-Val, and M. Weidner (2017). "Bias
5359
#' corrections for probit and logit models with two-way fixed effects". The

R/apes_bias_helpers.R

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
#' srr_stats (tests)
2+
#' @srrstats {G1.4a} All internal (non-exported) functions should also be
3+
#' documented in standard [`roxygen2`](https://roxygen2.r-lib.org/) format,
4+
#' along with a final `@noRd` tag to suppress automatic generation of `.Rd`
5+
#' files.
6+
#' @noRd
7+
NULL
8+
19
#' @title Checks if the object is an `feglm` object
210
#' @description Internal check
311
#' @param object Object to check
412
#' @param fun Function name (e.g., "apes")
5-
#' @srrstats {G1.4a} *All internal (non-exported) functions should also be documented in standard [`roxygen2`](https://roxygen2.r-lib.org/) format, along with a final `@noRd` tag to suppress automatic generation of `.Rd` files.*
613
#' @noRd
714
apes_bias_check_object_ <- function(object, fun) {
815
if (is.null(object)) {

R/bias_corr.R

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
#' srr_stats (tests)
2+
#' @srrstats {G1.0} Statistical Software should list at least one primary
3+
#' reference from published academic literature.
4+
#' @srrstats {G2.3} For univariate character input:
5+
#' @srrstats {G2.3a} Use `match.arg()` or equivalent where applicable to only
6+
#' permit expected values.
7+
#' @srrstats {G2.3b} Either: use `tolower()` or equivalent to ensure input of
8+
#' character parameters is not case dependent; or explicitly document that
9+
#' parameters are strictly case-sensitive.
10+
#' @noRd
11+
NULL
12+
113
#' @title Asymptotic bias correction after fitting binary choice models with a
214
#' 1,2,3-way error component
315
#'
@@ -7,10 +19,6 @@
719
#' obtain bias-corrected estimates of the structural parameters and is
820
#' currently restricted to \code{\link[stats]{binomial}} with 1,2,3-way fixed
921
#' effects.
10-
#'
11-
#' @srrstats {G2.3} *For univariate character input:*
12-
#' @srrstats {G2.3a} *Use `match.arg()` or equivalent where applicable to only permit expected values.*
13-
#' @srrstats {G2.3b} *Either: use `tolower()` or equivalent to ensure input of character parameters is not case dependent; or explicitly document that parameters are strictly case-sensitive.*
1422
#'
1523
#' @param object an object of class \code{"feglm"}.
1624
#' @param l unsigned integer indicating a bandwidth for the estimation of
@@ -28,8 +36,6 @@
2836
#' observed for several time periods. Default is \code{"classic"}.
2937
#'
3038
#' @return A named list of classes \code{"bias_corr"} and \code{"feglm"}.
31-
#'
32-
#' @srrstats {G1.0} *Statistical Software should list at least one primary reference from published academic literature.*
3339
#'
3440
#' @references Czarnowske, D. and A. Stammann (2020). "Fixed Effects Binary
3541
#' Choice Models: Estimation and Inference with Long Panels". ArXiv e-prints.

R/capybara-package.R

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
#' srr_stats (tests)
2+
#' @srrstats {G1.1} The algorithm is a full refactor with memory and speed
3+
#' improvements for a previous R implementation (Stammann, 2018).
4+
#' @srrstats {G1.2} Describes the current and anticipated future states of
5+
#' development.
6+
#' @srrstats {G1.4} The package uses [`roxygen2`](https://roxygen2.r-lib.org/)
7+
#' to document all functions (see ./DESCRIPTION).
8+
#' @noRd
9+
NULL
10+
111
#' @title Generalized Linear Models (GLMs) with high-dimensional k-way fixed
212
#' effects
3-
#'
4-
#' @srrstats {G1.1} *Statistical Software should document whether the algorithm(s) it implements are:* - *The first implementation of a novel algorithm*; or - *The first implementation within **R** of an algorithm which has previously been implemented in other languages or contexts*; or - *An improvement on other implementations of similar algorithms in **R***.
5-
#' @srrstats {G1.2} *Statistical Software should include a* Life Cycle Statement *describing current and anticipated future states of development.*
6-
#' @srrstats {G1.4} *Software should use [`roxygen2`](https://roxygen2.r-lib.org/) to document all functions.*
713
#'
814
#' @description
915
#' Provides a routine to partial out factors with many levels during the
@@ -34,6 +40,11 @@
3440
#' @useDynLib capybara, .registration = TRUE
3541
"_PACKAGE"
3642

43+
#' srr_stats (tests)
44+
#' @srrstats {G5.1} The panel is exported and used in the package examples.
45+
#' @noRd
46+
NULL
47+
3748
#' Trade Panel 1986-2006
3849
#'
3950
#' Aggregated exports at origin-destination-year level for 1986-2006.
@@ -54,5 +65,6 @@
5465
#' \item{exp_year}{Exporter ISO country code and year}
5566
#' \item{imp_year}{Importer ISO country code and year}
5667
#' }
68+
#'
5769
#' @source Advanced Guide to Trade Policy Analysis (ISBN: 978-92-870-4367-2)
5870
"trade_panel"

R/feglm.R

+55-23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
#' srr_stats (tests)
2+
#' @srrstats {G1.0} Statistical Software should list at least one primary
3+
#' reference from published academic literature.
4+
#' @srrstats {G1.3} All statistical terminology should be clarified and
5+
#' unambiguously defined.
6+
#' @srrstats {G2.3} For univariate character input:
7+
#' @srrstats {G2.3a} Use `match.arg()` or equivalent where applicable to only
8+
#' permit expected values.
9+
#' @srrstats {G2.3b} Either: use `tolower()` or equivalent to ensure input of
10+
#' character parameters is not case dependent; or explicitly document that
11+
#' parameters are strictly case-sensitive.
12+
#' @srrstats {RE4.4} The specification of the model, generally as a formula
13+
#' (via `formula()`)
14+
#' @srrstats {RE1.0} Regression Software should enable models to be specified
15+
#' via a formula interface, unless reasons for not doing so are explicitly
16+
#' documented.
17+
#' @srrstats {RE1.1} Regression Software should document how formula interfaces
18+
#' are converted to matrix representations of input data.
19+
#' @srrstats {RE1.2} Regression Software should document expected format (types
20+
#' or classes) for inputting predictor variables, including descriptions of
21+
#' types or classes which are not accepted.
22+
#' @srrstats {RE1.3} Regression Software which passes or otherwise transforms
23+
#' aspects of input data onto output structures should ensure that those output
24+
#' structures retain all relevant aspects of input data, notably including row
25+
#' and column names, and potentially information from other `attributes()`.
26+
#' @srrstats {RE1.3a} Where otherwise relevant information is not transferred,
27+
#' this should be explicitly documented.
28+
#' @srrstats {RE1.4} Regression Software should document any assumptions made
29+
#' with regard to input data; for example distributional assumptions, or
30+
#' assumptions that predictor data have mean values of zero. Implications of
31+
#' violations of these assumptions should be both documented and tested.
32+
#' @srrstats {RE2.3} Where applicable, Regression Software should enable data to
33+
#' be centred (for example, through converting to zero-mean equivalent values;
34+
#' or to z-scores) or offset (for example, to zero-intercept equivalent values)
35+
#' via additional parameters, with the effects of any such parameters clearly
36+
#' documented and tested.
37+
#' @srrstats {RE3.0} Issue appropriate warnings or other diagnostic messages for
38+
#' models which fail to converge.
39+
#' @srrstats {RE3.1} Enable such messages to be optionally suppressed, yet
40+
#' should ensure that the resultant model object nevertheless includes
41+
#' sufficient data to identify lack of convergence.
42+
#' @srrstats {RE3.2} Ensure that convergence thresholds have sensible default
43+
#' values, demonstrated through explicit documentation.
44+
#' @srrstats {RE3.3} Allow explicit setting of convergence thresholds, unless
45+
#' reasons against doing so are explicitly documented.
46+
#' @srrstats {RE4.0} Regression Software should return some form of "model"
47+
#' object, generally through using or modifying existing class structures for
48+
#' model objects (such as `lm`, `glm`, or model objects from other packages),
49+
#' or creating a new class of model objects.
50+
#' @noRd
51+
NULL
52+
153
#' @title GLM fitting with high-dimensional k-way fixed effects
254
#'
355
#' @description \code{\link{feglm}} can be used to fit generalized linear models
@@ -8,22 +60,6 @@
860
#' \strong{Remark:} The term fixed effect is used in econometrician's sense of
961
#' having intercepts for each level in each category.
1062
#'
11-
#' @srrstats {G2.3} *For univariate character input:*
12-
#' @srrstats {G2.3a} *Use `match.arg()` or equivalent where applicable to only permit expected values.*
13-
#' @srrstats {G2.3b} *Either: use `tolower()` or equivalent to ensure input of character parameters is not case dependent; or explicitly document that parameters are strictly case-sensitive.*
14-
#' @srrstats {RE4.4} *The specification of the model, generally as a formula (via `formula()`)*
15-
#' @srrstats {RE1.0} *Regression Software should enable models to be specified via a formula interface, unless reasons for not doing so are explicitly documented.*
16-
#' @srrstats {RE1.1} *Regression Software should document how formula interfaces are converted to matrix representations of input data.*
17-
#' @srrstats {RE1.2} *Regression Software should document expected format (types or classes) for inputting predictor variables, including descriptions of types or classes which are not accepted.*
18-
#' @srrstats {RE1.3} *Regression Software which passes or otherwise transforms aspects of input data onto output structures should ensure that those output structures retain all relevant aspects of input data, notably including row and column names, and potentially information from other `attributes()`.*
19-
#' @srrstats {RE1.3a} *Where otherwise relevant information is not transferred, this should be explicitly documented.*
20-
#' @srrstats {RE1.4} *Regression Software should document any assumptions made with regard to input data; for example distributional assumptions, or assumptions that predictor data have mean values of zero. Implications of violations of these assumptions should be both documented and tested.*
21-
#' @srrstats {RE2.3} *Where applicable, Regression Software should enable data to be centred (for example, through converting to zero-mean equivalent values; or to z-scores) or offset (for example, to zero-intercept equivalent values) via additional parameters, with the effects of any such parameters clearly documented and tested.*
22-
#' @srrstats {RE3.0} *Issue appropriate warnings or other diagnostic messages for models which fail to converge.*
23-
#' @srrstats {RE3.1} *Enable such messages to be optionally suppressed, yet should ensure that the resultant model object nevertheless includes sufficient data to identify lack of convergence.*
24-
#' @srrstats {RE3.2} *Ensure that convergence thresholds have sensible default values, demonstrated through explicit documentation.*
25-
#' @srrstats {RE3.3} *Allow explicit setting of convergence thresholds, unless reasons against doing so are explicitly documented.*
26-
#'
2763
#' @param formula an object of class \code{"formula"}: a symbolic description of
2864
#' the model to be fitted. \code{formula} must be of type \code{y ~ x | k},
2965
#' where the second part of the formula refers to factors to be concentrated
@@ -51,9 +87,6 @@
5187
#' linear dependence between one or more regressors and a fixed effects
5288
#' category. In this case, you should carefully inspect your model
5389
#' specification.
54-
#'
55-
#' @srrstats {G1.3} *All statistical terminology should be clarified and unambiguously defined.*
56-
#' @srrstats {RE4.0} *Regression Software should return some form of "model" object, generally through using or modifying existing class structures for model objects (such as `lm`, `glm`, or model objects from other packages), or creating a new class of model objects.*
5790
#'
5891
#' @return A named list of class \code{"feglm"}. The list contains the following
5992
#' fifteen elements:
@@ -75,8 +108,6 @@
75108
#' observations}
76109
#' \item{family}{the family used in the model}
77110
#' \item{control}{the control list used in the model}
78-
#'
79-
#' @srrstats {G1.0} *Statistical Software should list at least one primary reference from published academic literature.*
80111
#'
81112
#' @references Gaure, S. (2013). "OLS with Multiple High Dimensional Category
82113
#' Variables". Computational Statistics and Data Analysis, 66.
@@ -163,8 +194,9 @@ feglm <- function(
163194
p <- NA
164195
model_response_(data, formula)
165196

166-
# Check for linear dependence in 'x' ----
167-
check_linear_dependence_(x, p)
197+
# Check for linear dependence ----
198+
# check_linear_dependence_(x, p)
199+
check_linear_dependence_(cbind(y,x), p + 1L)
168200

169201
# Extract weights if required ----
170202
if (is.null(weights)) {

0 commit comments

Comments
 (0)