|
| 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 | + |
1 | 53 | #' @title GLM fitting with high-dimensional k-way fixed effects
|
2 | 54 | #'
|
3 | 55 | #' @description \code{\link{feglm}} can be used to fit generalized linear models
|
|
8 | 60 | #' \strong{Remark:} The term fixed effect is used in econometrician's sense of
|
9 | 61 | #' having intercepts for each level in each category.
|
10 | 62 | #'
|
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 |
| -#' |
27 | 63 | #' @param formula an object of class \code{"formula"}: a symbolic description of
|
28 | 64 | #' the model to be fitted. \code{formula} must be of type \code{y ~ x | k},
|
29 | 65 | #' where the second part of the formula refers to factors to be concentrated
|
|
51 | 87 | #' linear dependence between one or more regressors and a fixed effects
|
52 | 88 | #' category. In this case, you should carefully inspect your model
|
53 | 89 | #' 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.* |
57 | 90 | #'
|
58 | 91 | #' @return A named list of class \code{"feglm"}. The list contains the following
|
59 | 92 | #' fifteen elements:
|
|
75 | 108 | #' observations}
|
76 | 109 | #' \item{family}{the family used in the model}
|
77 | 110 | #' \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.* |
80 | 111 | #'
|
81 | 112 | #' @references Gaure, S. (2013). "OLS with Multiple High Dimensional Category
|
82 | 113 | #' Variables". Computational Statistics and Data Analysis, 66.
|
@@ -163,8 +194,9 @@ feglm <- function(
|
163 | 194 | p <- NA
|
164 | 195 | model_response_(data, formula)
|
165 | 196 |
|
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) |
168 | 200 |
|
169 | 201 | # Extract weights if required ----
|
170 | 202 | if (is.null(weights)) {
|
|
0 commit comments