Fix time-varying weights plot

This commit is contained in:
2025-06-22 09:33:05 +02:00
parent b49fa7d0db
commit a8f46db8a2
2 changed files with 380 additions and 385 deletions

File diff suppressed because one or more lines are too long

View File

@@ -795,17 +795,15 @@ Berrisch, J., & Ziel, F. [-@BERRISCH2023105221]. *Journal of Econometrics*, 237(
```{r, echo = FALSE, fig.height=8, cache = TRUE} ```{r, echo = FALSE, fig.height=8, cache = TRUE}
par(mfrow = c(3, 3), mar = c(2, 2, 2, 2)) par(mfrow = c(3, 3), mar = c(2, 2, 2, 2))
set.seed(1) set.seed(42)
# Data # Data
X <- matrix(ncol = 3, nrow = 15) X <- matrix(ncol = 2, nrow = 15)
X[, 1] <- seq(from = 8, to = 12, length.out = 15) + 0.25 * rnorm(15) X[, 1] <- seq(from = 8, to = 12, length.out = 15) + 0.4 * rnorm(15)
X[, 2] <- 10 + 0.25 * rnorm(15) X[, 2] <- seq(from = 12, to = 8, length.out = 15) + 0.4 * rnorm(15)
X[, 3] <- seq(from = 12, to = 8, length.out = 15) + 0.25 * rnorm(15)
# Weights # Weights
w <- matrix(ncol = 3, nrow = 15) w <- matrix(ncol = 2, nrow = 15)
w[, 1] <- sin(0.1 * 1:15) w[, 1] <- sin(0.1 * 1:15)
w[, 2] <- cos(0.1 * 1:15) w[, 2] <- seq(from = -2, 0.25, length.out = 15)^2
w[, 3] <- seq(from = -2, 0.25, length.out = 15)^2
w <- (w / rowSums(w)) w <- (w / rowSums(w))
# Vis # Vis
plot(X[, 1], plot(X[, 1],
@@ -825,27 +823,24 @@ plot(w[, 1],
xlab = "", xlab = "",
ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#80C684FF" ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#80C684FF"
) )
text(6, 0.5, TeX("$w_1(t)$"), cex = 2, col = "#80C684FF") text(6, 0.5, latex2exp::TeX("$w_1(t)$"), cex = 2, col = "#80C684FF")
arrows(13, 0.25, 15, 0.0, , lwd = 4, bty = "n", col = "#414141FF") arrows(13, 0.25, 15, 0.0, , lwd = 4, bty = "n", col = "#414141FF")
plot.new() plot.new()
plot.new() plot.new()
plot.new() plot.new()
text(6, 0.6, TeX("$w_2(t)$"), cex = 2, col = "#FFD44EFF")
arrows(13, 0.5, 15, 0.5, , lwd = 4, bty = "n", col = "#414141FF")
plot(rowSums(X * w), lwd = 4, type = "l", xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#D81A5FFF") plot(rowSums(X * w), lwd = 4, type = "l", xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#D81A5FFF")
plot(X[, 3], plot(X[, 2],
lwd = 4, lwd = 4,
type = "l", ylim = c(8, 12), type = "l", ylim = c(8, 12),
xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#FFD44EFF" xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#FFD44EFF"
) )
plot(w[, 3], plot(w[, 2],
lwd = 4, type = "l", lwd = 4, type = "l",
ylim = c(0, 1), ylim = c(0, 1),
xlab = "", xlab = "",
ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#FFD44EFF" ylab = "", xaxt = "n", yaxt = "n", bty = "n", col = "#FFD44EFF"
) )
text(6, 0.25, TeX("$w_2(t)$"), cex = 2, col = "#FFD44EFF") text(6, 0.25, latex2exp::TeX("$w_2(t)$"), cex = 2, col = "#FFD44EFF")
arrows(13, 0.75, 15, 1, , lwd = 4, bty = "n", col = "#414141FF") arrows(13, 0.75, 15, 1, , lwd = 4, bty = "n", col = "#414141FF")
``` ```