Skip to content

Commit 33116f5

Browse files
committed
Formatted all R package code with air
1 parent 58d221c commit 33116f5

File tree

10 files changed

+4388
-4389
lines changed

10 files changed

+4388
-4389
lines changed

R/calibration.R

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
#' sigma2hat <- mean(resid(lm(y~X))^2)
2323
#' mean(var(y)/rgamma(100000, nu, rate = nu*lambda) < sigma2hat)
2424
calibrateInverseGammaErrorVariance <- function(
25-
y,
26-
X,
27-
W = NULL,
28-
nu = 3,
29-
quant = 0.9,
30-
standardize = TRUE
25+
y,
26+
X,
27+
W = NULL,
28+
nu = 3,
29+
quant = 0.9,
30+
standardize = TRUE
3131
) {
32-
# Compute regression basis
33-
if (!is.null(W)) {
34-
basis <- cbind(X, W)
35-
} else {
36-
basis <- X
37-
}
38-
# Standardize outcome if requested
39-
if (standardize) {
40-
y <- (y - mean(y)) / sd(y)
41-
}
42-
# Compute the "regression-based" overestimate of sigma^2
43-
sigma2hat <- mean(resid(lm(y ~ basis))^2)
44-
# Calibrate lambda based on the implied quantile of sigma2hat
45-
return((sigma2hat * qgamma(1 - quant, nu)) / nu)
32+
# Compute regression basis
33+
if (!is.null(W)) {
34+
basis <- cbind(X, W)
35+
} else {
36+
basis <- X
37+
}
38+
# Standardize outcome if requested
39+
if (standardize) {
40+
y <- (y - mean(y)) / sd(y)
41+
}
42+
# Compute the "regression-based" overestimate of sigma^2
43+
sigma2hat <- mean(resid(lm(y ~ basis))^2)
44+
# Calibrate lambda based on the implied quantile of sigma2hat
45+
return((sigma2hat * qgamma(1 - quant, nu)) / nu)
4646
}

R/config.R

Lines changed: 483 additions & 483 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)