View source: R/transformations.R
| get_W | R Documentation |
Estimates the anchor transformation for the Anchor-Objective.
The anchor transformation is W = I-(1-\sqrt{\gamma}))\Pi_A,
where \Pi_A = A(A^TA)^{-1}A^T. For \gamma = 1 this is just the identity.
For \gamma = 0 this corresponds to residuals after orthogonal projecting onto A.
For large \gamma this is close to the orthogonal projection onto A, scaled by \gamma.
The estimator \text{argmin}_f ||W(Y - f(X))||^2 corresponds to the Anchor-Regression Estimator
\insertCiteRothenhausler2021AnchorCausalitySDModels, \insertCiteBuhlmann2020InvarianceRobustnessSDModels.
get_W(A, gamma, intercept = FALSE, gpu = FALSE)
A |
Numerical Anchor of class |
gamma |
Strength of distributional robustness, |
intercept |
Logical, whether to include an intercept in the anchor. |
gpu |
If |
W of class matrix, the anchor transformation matrix.
Markus Ulmer
set.seed(1)
n <- 50
X <- matrix(rnorm(n * 1), nrow = n)
Y <- 3 * X + rnorm(n)
W <- get_W(X, gamma = 0)
resid <- W %*% Y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.