Assignment 1: Rolling estimation

A1. Read and clean the data

Note on returns. The TEJ file contains the monthly return ROI_Month (in percent) instead of an adjusted price, so the return is ROI_Month / 100. It is set to NA (never zero) when the previous month of the same stock is missing.

stock_raw <- read_any(stock_file)
stopifnot(all(c("CO_ID", "Date", "Market Cap.", "ROI_Month") %in% names(stock_raw)))

stock_all <- tibble(
  ticker = str_extract(str_trim(stock_raw$CO_ID), "^\\S+"),
  name   = if ("English Name" %in% names(stock_raw)) stock_raw[["English Name"]] else NA_character_,
  ym     = parse_ym(stock_raw$Date),
  mcap   = as.numeric(stock_raw[["Market Cap."]]),
  roi    = as.numeric(stock_raw$ROI_Month)
) %>%
  mutate(class = case_when(
    str_detect(ticker, "^0")                                  ~ "ETF / ETN (ticker starts with 0)",
    str_detect(ticker, "^91\\d{2}$")                          ~ "TDR (91xx)",
    !str_detect(ticker, "^[1-9]\\d{3}$")                      ~ "Other (preferred, warrants, non 4-digit)",
    !is.na(name) & str_detect(tolower(name), drop_name_pattern) ~ "Full-delivery (by name)",
    TRUE                                                      ~ "Ordinary stock"
  ))

removed <- stock_all %>%
  filter(class != "Ordinary stock") %>%
  group_by(class) %>%
  summarise(tickers_removed = n_distinct(ticker), rows_removed = n(), .groups = "drop")
kable(removed, caption = "Removed securities")
Removed securities
class tickers_removed rows_removed
Other (preferred, warrants, non 4-digit) 6 641
TDR (91xx) 4 432
cat("Raw rows:", nrow(stock_all), "| Removed rows:", sum(removed$rows_removed),
    "| Removed tickers:", sum(removed$tickers_removed), "\n")
## Raw rows: 107924 | Removed rows: 1073 | Removed tickers: 10
# duplicates (keep the first row) and return construction
n_dup <- sum(duplicated(stock_all[c("ticker", "ym")]))
cat("Duplicate stock-month rows dropped:", n_dup, "\n")
## Duplicate stock-month rows dropped: 0
stock <- stock_all %>%
  filter(class == "Ordinary stock") %>%
  distinct(ticker, ym, .keep_all = TRUE) %>%
  arrange(ticker, ym) %>%
  group_by(ticker) %>%
  mutate(prev_ok = !is.na(lag(ym)) & lag(ym) == ym %m-% months(1),
         ret     = if_else(prev_ok, roi / 100, NA_real_)) %>%
  ungroup() %>%
  filter(ym >= as.Date("2017-12-01"), ym <= as.Date("2025-12-01")) %>%
  select(ticker, name, ym, mcap, ret)
ff_raw <- read_any(ff_file)
key <- tolower(gsub("[^A-Za-z0-9]", "", names(ff_raw)))

# The TEJ factor file has several variants per month (CO_ID: Y8888, Y9999, Z9999, ...). Keep ONE.
id_col <- which(key == "coid")[1]
if (!is.na(id_col)) {
  ids <- str_extract(str_trim(as.character(ff_raw[[id_col]])), "^\\S+")
  cat("Factor variants found:", paste(unique(ids), collapse = ", "), "\n")
  use_id <- if (!is.na(ff_id)) ff_id else if ("Y9999" %in% ids) "Y9999" else unique(ids)[1]
  stopifnot(use_id %in% ids)
  ff_raw <- ff_raw[ids == use_id, , drop = FALSE]
  cat("Using factor variant:", use_id, "(", nrow(ff_raw), "rows )\n")
}
## Factor variants found: Y8888, Y8888L, Y9999, Y9999L, Z8888, Z8888L, Z9999, Z9999L 
## Using factor variant: Y9999 ( 108 rows )
pick <- function(pattern, what) {
  i <- which(grepl(pattern, key))[1]
  if (is.na(i)) stop("Column for ", what, " not found in the factor file. Columns are: ",
                     paste(names(ff_raw), collapse = " | "),
                     ". The file needs: market risk premium, size, book-to-market, profitability (RMW), ",
                     "investment (CMA) and the risk-free rate.")
  i
}
date_i <- which(grepl("date|ym|month|mdate", key))[1] %|||% 1

# RMW, CMA and rf are optional: they are not available in the TEJ file used here
pick_opt <- function(pattern) {
  i <- which(grepl(pattern, key))[1]
  if (is.na(i)) rep(NA_real_, nrow(ff_raw)) else as.numeric(ff_raw[[i]])
}
rf_raw  <- pick_opt("^rf|riskfree")
rmw_raw <- pick_opt("^rmw|profit")
cma_raw <- pick_opt("^cma|invest")
have_rf  <- !all(is.na(rf_raw))
have_ff5 <- !all(is.na(rmw_raw)) && !all(is.na(cma_raw))

ff <- tibble(
  ym     = parse_ym(ff_raw[[date_i]]),
  rf     = rf_raw,
  MKT_RF = as.numeric(ff_raw[[pick("marketrisk|^mkt|^rmrf|^rm$|marketexcess", "market risk premium")]]),
  SMB    = as.numeric(ff_raw[[pick("^smb|^size", "size factor (SMB)")]]),
  HML    = as.numeric(ff_raw[[pick("^hml|^booktomarket|^value", "book-to-market factor (HML)")]]),
  RMW    = rmw_raw,
  CMA    = cma_raw
) %>% arrange(ym)

if (anyDuplicated(ff$ym)) stop("The factor file still has more than one row per month. Set ff_id in the settings.")

in_percent <- max(abs(as.matrix(ff[, c("MKT_RF", "SMB", "HML")])), na.rm = TRUE) > 1
if (in_percent) ff <- ff %>% mutate(across(c(rf, MKT_RF, SMB, HML, RMW, CMA), ~ .x / 100))
if (!have_rf) ff$rf <- rf_annual_pct / 100 / 12      # constant monthly rf (see settings)
cat("Factors were in percent and divided by 100:", in_percent, "\n")
## Factors were in percent and divided by 100: TRUE
cat("rf in file:", have_rf, "| RMW and CMA in file (FF5 possible):", have_ff5, "\n")
## rf in file: FALSE | RMW and CMA in file (FF5 possible): FALSE
ff <- ff %>% filter(ym >= as.Date("2017-12-01"), ym <= as.Date("2025-12-01"))

Data note (risk-free rate). The factor file has no risk-free rate, so a constant annual rf of 0.00% (monthly 0.0000%) is used for excess returns and Sharpe ratios. With rf = 0 the excess return equals the raw return. Because rf is small in Taiwan, this only shifts alphas slightly, but it is a limitation.

Data note (FF5). The profitability (RMW) and investment (CMA) factors are not available in the TEJ data, so only the three-factor model (FF3) is estimated. The FF5 parts of the tasks (rolling_ff5, A5, D2) are skipped and explained in the text.

panel <- stock %>% inner_join(ff, by = "ym") %>% mutate(ex = ret - rf)
panel_list <- split(panel, panel$ticker)

# --- reports and checks
months_needed <- seq(as.Date("2017-12-01"), as.Date("2025-12-01"), by = "month")
checks_a1 <- tibble(
  check  = c("No duplicate ticker-month rows", "December 2017 rows exist",
             "Market caps are positive (where present)", "No factor month is missing",
             "Factor table has 97 rows"),
  passed = c(!anyDuplicated(stock[c("ticker", "ym")]) > 0,
             any(stock$ym == as.Date("2017-12-01")),
             all(stock$mcap[!is.na(stock$mcap)] > 0),
             all(months_needed %in% ff$ym),
             nrow(ff) == 97)
)
kable(checks_a1, caption = "A1 checks")
A1 checks
check passed
No duplicate ticker-month rows TRUE
December 2017 rows exist TRUE
Market caps are positive (where present) TRUE
No factor month is missing TRUE
Factor table has 97 rows TRUE
tibble(table = c("Cleaned stock table", "Factor table"),
       rows  = c(nrow(stock), nrow(ff)),
       first = c(min(stock$ym), min(ff$ym)),
       last  = c(max(stock$ym), max(ff$ym)),
       tickers = c(n_distinct(stock$ticker), NA)) %>% kable(caption = "Row counts and date ranges")
Row counts and date ranges
table rows first last tickers
Cleaned stock table 96777 2017-12-01 2025-12-01 1087
Factor table 97 2017-12-01 2025-12-01 NA
cat("NA returns:", sum(is.na(stock$ret)), "| NA market caps:", sum(is.na(stock$mcap)), "\n")
## NA returns: 178 | NA market caps: 0

A2. Monthly top-50 universe

form_months <- seq(first_form, last_form, by = "month")

top50 <- stock %>%
  filter(ym %in% form_months, !is.na(mcap), mcap > 0) %>%
  group_by(ym) %>%
  slice_max(mcap, n = n_top, with_ties = FALSE) %>%
  mutate(rank = row_number()) %>%
  ungroup() %>%
  select(ticker, ym, rank, mcap)

cat("top50 rows:", nrow(top50), "(expected", length(form_months) * n_top, ")\n")
## top50 rows: 3050 (expected 3050 )
cat("Different stocks in the top 50 at least once:", n_distinct(top50$ticker), "\n")
## Different stocks in the top 50 at least once: 85
sets <- top50 %>% group_by(ym) %>% summarise(s = list(ticker), .groups = "drop") %>% arrange(ym)
turn <- tibble(
  ym      = sets$ym[-1],
  entered = map_int(2:nrow(sets), ~ length(setdiff(sets$s[[.x]], sets$s[[.x - 1]]))),
  left    = map_int(2:nrow(sets), ~ length(setdiff(sets$s[[.x - 1]], sets$s[[.x]])))
)

turn %>% pivot_longer(c(entered, left)) %>%
  ggplot(aes(ym, value, fill = name)) +
  geom_col(position = "dodge") +
  labs(title = "Stocks entering and leaving the top 50 each month",
       x = NULL, y = "Number of stocks", fill = NULL) +
  theme_minimal()

A3. Rolling regressions

roll_one <- function(tk, tt, factors) {
  k    <- length(factors)
  b_nm <- paste0("b_", lab[factors]); t_nm <- paste0("t_", lab[factors])
  est  <- setNames(rep(NA_real_, k + 1), c("alpha", b_nm))
  tv   <- setNames(rep(NA_real_, k + 1), c("t_alpha", t_nm))
  adj  <- NA_real_; n <- 0L; ws <- we <- as.Date(NA)
  lo   <- tt %m-% months(win_len)               # window = months in (lo, tt]

  d <- panel_list[[tk]]
  if (!is.null(d)) {
    d <- d[d$ym > lo & d$ym <= tt, , drop = FALSE]
    d <- d[complete.cases(d[, c("ex", factors)]), , drop = FALSE]
    n <- nrow(d)
    if (n > 0) { ws <- min(d$ym); we <- max(d$ym) }
    if (n >= min_obs) {
      fit <- lm(reformulate(factors, "ex"), data = d)
      sm  <- summary(fit)
      rn  <- c("(Intercept)", factors)
      okr <- intersect(rn, rownames(sm$coefficients))
      est[match(okr, rn)] <- sm$coefficients[okr, 1]
      tv[match(okr, rn)]  <- sm$coefficients[okr, 3]
      adj <- sm$adj.r.squared
    }
  }
  # factor averages over the SAME calendar window (used for exp_ret in Assignment 2)
  fw  <- ff[ff$ym > lo & ff$ym <= tt, ]
  lam <- setNames(colMeans(fw[factors], na.rm = TRUE), paste0("lam_", lab[factors]))

  bind_cols(
    tibble(n_obs = n, ok = n >= min_obs, win_start = ws, win_end = we, adj_r2 = adj,
           n_lam = nrow(fw), lam_end = max(fw$ym)),
    as_tibble_row(est), as_tibble_row(tv), as_tibble_row(lam)
  )
}

roll_run <- function(factors) {
  res <- map2(top50$ticker, top50$ym, ~ roll_one(.x, .y, factors)) %>% list_rbind()
  bind_cols(top50 %>% transmute(form_ym = ym, ticker, rank, mcap), res)
}
rolling_ff3 <- roll_run(c("MKT_RF", "SMB", "HML"))
rolling_ff5 <- if (have_ff5) roll_run(c("MKT_RF", "SMB", "HML", "RMW", "CMA")) else NULL

saveRDS(rolling_ff3, "output/rolling_ff3.rds")
if (have_ff5) saveRDS(rolling_ff5, "output/rolling_ff5.rds")
saveRDS(top50,       "output/top50.rds")
saveRDS(stock,       "output/stock_clean.rds")
saveRDS(ff,          "output/factors.rds")

models <- list(FF3 = rolling_ff3, FF5 = rolling_ff5)
models <- models[!map_lgl(models, is.null)]
tibble(model = names(models),
       rows          = map_int(models, nrow),
       estimated     = map_int(models, ~ sum(.x$ok)),
       not_estimated = map_int(models, ~ sum(!.x$ok))) %>%
  kable(caption = "Stock-months estimated vs not (fewer than 30 valid months)")
Stock-months estimated vs not (fewer than 30 valid months)
model rows estimated not_estimated
FF3 3050 3024 26
chk3 <- function(x) tibble(
  check = c("No window uses data after its formation month",
            "No window longer than 36 months",
            "One row per ticker and month",
            "50 stocks in every formation month"),
  passed = c(all(x$win_end <= x$form_ym, na.rm = TRUE),
             all(x$n_obs <= win_len),
             !anyDuplicated(x[c("ticker", "form_ym")]) > 0,
             all(count(x, form_ym)$n == n_top)))
kable(bind_rows(map(models, chk3), .id = "model"), caption = "A3 checks")
A3 checks
model check passed
FF3 No window uses data after its formation month TRUE
FF3 No window longer than 36 months TRUE
FF3 One row per ticker and month TRUE
FF3 50 stocks in every formation month TRUE

A4. Factor loadings over time

by_year <- function(x) x %>% filter(ok) %>%
  group_by(year = year(form_ym)) %>%
  summarise(across(c(alpha, starts_with("b_"), adj_r2), ~ mean(.x, na.rm = TRUE)),
            n = n(), .groups = "drop")

yr3 <- by_year(rolling_ff3)
kable(yr3, digits = 4, caption = "FF3: average alpha, loadings and adjusted R2 by calendar year (formation month)")
FF3: average alpha, loadings and adjusted R2 by calendar year (formation month)
year alpha b_mkt b_smb b_hml adj_r2 n
2020 0.0033 0.8857 0.0686 0.2440 0.4094 49
2021 0.0059 0.9729 0.0883 0.3369 0.4039 588
2022 0.0040 0.9583 0.0801 0.3557 0.3981 595
2023 0.0060 0.9154 0.0498 0.2057 0.3464 600
2024 0.0052 0.9105 0.1231 0.2122 0.3155 599
2025 0.0072 0.9359 0.1864 0.1946 0.2935 593
if (have_ff5) {
  yr5 <- by_year(rolling_ff5)
  print(kable(yr5, digits = 4, caption = "FF5: average alpha, loadings and adjusted R2 by calendar year (formation month)"))
}

rolling_ff3 %>% filter(ok) %>% group_by(form_ym) %>%
  summarise(SMB = mean(b_smb), HML = mean(b_hml), .groups = "drop") %>%
  pivot_longer(c(SMB, HML)) %>%
  ggplot(aes(form_ym, value, colour = name)) +
  geom_hline(yintercept = 0, linetype = 2) +
  geom_line(linewidth = 1) +
  labs(title = "Average SMB and HML loadings of the top 50 (FF3)", x = "Formation month", y = "Loading", colour = NULL) +
  theme_minimal()

Interpretation (edit after reading the table and plot). Averaged over all windows, the SMB loading of the 50 largest stocks is 0.1, which is not negative, so the top 50 do not behave like a pure large-cap tilt in this sample. The average HML loading is 0.26. The yearly average SMB loading is lowest in 2023 and highest in 2025, and the HML loading is lowest in 2025 and highest in 2022, so the loadings are not stable. Windows formed around 2020 to 2022 contain the COVID shock, the 2021 electronics and shipping boom and the 2022 rate rise, which moved growth and value stocks in opposite directions and shifted the loadings. The pattern is therefore driven by what is inside each 36-month window and not by a permanent change in the firms.

A5. FF3 versus FF5

if (have_ff5) {
tab3 <- rolling_ff3 %>% filter(ok) %>% group_by(year = year(form_ym)) %>%
  summarise(adj_r2_ff3 = mean(adj_r2), abs_alpha_ff3 = mean(abs(alpha)),
            sig_alpha_ff3 = sig(t_alpha), .groups = "drop")
tab5 <- rolling_ff5 %>% filter(ok) %>% group_by(year = year(form_ym)) %>%
  summarise(adj_r2_ff5 = mean(adj_r2), abs_alpha_ff5 = mean(abs(alpha)),
            sig_alpha_ff5 = sig(t_alpha), sig_rmw = sig(t_rmw), sig_cma = sig(t_cma), .groups = "drop")
cmp_year <- left_join(tab3, tab5, by = "year") %>%
  mutate(diff_adj_r2 = adj_r2_ff5 - adj_r2_ff3)
print(kable(cmp_year, digits = 4, caption = "FF3 versus FF5 by year"))

cmp <- inner_join(
  rolling_ff3 %>% filter(ok) %>% select(form_ym, ticker, adj3 = adj_r2),
  rolling_ff5 %>% filter(ok) %>% select(form_ym, ticker, adj5 = adj_r2),
  by = c("form_ym", "ticker"))
tt1 <- t.test(cmp$adj5, cmp$adj3, paired = TRUE)
print(tt1)

# a more cautious version: one observation per month (cross-sectional mean difference)
cmp_m <- cmp %>% group_by(form_ym) %>% summarise(d = mean(adj5 - adj3), .groups = "drop")
tt2 <- t.test(cmp_m$d)
print(tt2)
}

FF3 versus FF5 not possible. The RMW and CMA factors are not available in the TEJ data, so rolling_ff5, the yearly FF3 versus FF5 comparison and the paired t-test could not be produced. If they had been, the test would treat the stock-month differences in adjusted R2 as independent although consecutive windows overlap by 35 of 36 months and stocks share the same market shocks. The effective sample size would be much smaller than the number of rows, so the standard error would be too small and the p-value too low (significance overstated).

A6. Discussion

FF5 could not be estimated because RMW and CMA are not in the TEJ data, so I cannot test with this data whether it describes large Taiwan stocks better than FF3. In theory the two extra factors (profitability and investment) could add explanatory power for profitable large firms, but with only 36 monthly observations each extra regressor adds estimation noise, and the adjusted R2 would not necessarily rise. For FF3 the average adjusted R2 of the top-50 regressions is 0.352, so most of the variation is explained by the market factor and the loadings on SMB and HML matter less.

Two reasons the estimates are noisy: (1) each regression has only 36 monthly observations for 4 or 6 parameters, so the standard errors of the loadings are large, and one or two extreme months (for example March 2020) can move the estimates a lot; (2) the Taiwan factor series are built from a small and concentrated market and the windows overlap by 35 months, so the loadings are strongly autocorrelated and look more stable than they truly are.

One limitation of using only the 50 largest stocks: the sample has little cross-sectional variation in size and value, with a few giants such as TSMC dominating the electronics sector, so the SMB and HML loadings are weakly identified and the results cannot be generalised to small or mid-cap stocks.

Assignment 2: Top-10 portfolios versus 0050

Read 0050

if (is.na(etf_file)) stop("0050 file not found in the 'extra data' folder. Put it there or set etf_file in the settings.")
etf_raw <- read_any(etf_file)
k2 <- tolower(gsub("[^A-Za-z0-9]", "", names(etf_raw)))
id_i   <- which(grepl("^coid|^id$|^ticker|^code|^stock", k2))[1]
date_i <- which(grepl("date|ym|month", k2))[1] %|||% 1
roi_i  <- which(grepl("^roi", k2))[1]
px_i   <- which(grepl("close|price|adj", k2))[1]

etf <- tibble(
  id = if (!is.na(id_i)) as.character(etf_raw[[id_i]]) else "0050",
  ym = parse_ym(etf_raw[[date_i]]),
  v  = as.numeric(gsub(",", "", as.character(etf_raw[[if (!is.na(px_i)) px_i else roi_i]])))
)
if (!is.na(id_i) && any(str_detect(etf$id, "^0050"))) etf <- filter(etf, str_detect(id, "^0050"))
etf <- etf %>% distinct(ym, .keep_all = TRUE) %>% arrange(ym)

if (!is.na(px_i)) {                       # adjusted price -> return
  etf <- etf %>% mutate(ret = if_else(!is.na(lag(ym)) & lag(ym) == ym %m-% months(1), v / lag(v) - 1, NA_real_))
} else {                                  # ROI in percent
  etf <- etf %>% mutate(ret = v / 100)
}
etf_ret <- etf %>% transmute(hold_ym = ym, ret = ret) %>% filter(hold_ym >= as.Date("2021-01-01"), hold_ym <= as.Date("2025-12-01"))
cat("0050 months:", nrow(etf_ret), "| worst monthly return:", round(min(etf_ret$ret, na.rm = TRUE), 4),
    "(a value near -0.75 in June 2025 would mean the split is NOT adjusted)\n")
## 0050 months: 60 | worst monthly return: -0.1202 (a value near -0.75 in June 2025 would mean the split is NOT adjusted)

C1. Signals

signals <- rolling_ff3 %>%
  filter(ok, form_ym <= as.Date("2025-11-01")) %>%
  mutate(exp_ret = b_mkt * lam_mkt + b_smb * lam_smb + b_hml * lam_hml) %>%
  select(form_ym, ticker, rank, mcap, alpha, exp_ret, n_lam, lam_end)

signals %>% count(year = year(form_ym), name = "stocks_with_signal") %>% kable(caption = "Stocks with a signal, by year")
Stocks with a signal, by year
year stocks_with_signal
2020 49
2021 588
2022 595
2023 600
2024 599
2025 544
kable(tibble(check = c("Factor averages use exactly 36 months", "Factor averages stop at the formation month"),
             passed = c(all(signals$n_lam == win_len), all(signals$lam_end == signals$form_ym))))
check passed
Factor averages use exactly 36 months TRUE
Factor averages stop at the formation month TRUE

C2. Selection

sel <- function(sig) signals %>%
  group_by(form_ym) %>% arrange(desc(.data[[sig]]), .by_group = TRUE) %>%
  slice_head(n = n_pick) %>% mutate(signal = sig, pick_rank = row_number()) %>% ungroup()

holdings <- bind_rows(sel("alpha"), sel("exp_ret")) %>%
  select(signal, form_ym, ticker, pick_rank, mcap, alpha, exp_ret)

overlap <- holdings %>% group_by(form_ym) %>%
  summarise(common = length(intersect(ticker[signal == "alpha"], ticker[signal == "exp_ret"])), .groups = "drop")
overlap %>% group_by(year = year(form_ym)) %>% summarise(avg_common_names = mean(common)) %>%
  kable(digits = 2, caption = "(a) Average number of common stocks in the two top-10 lists")
(a) Average number of common stocks in the two top-10 lists
year avg_common_names
2020 2.00
2021 3.50
2022 4.33
2023 3.33
2024 2.33
2025 3.36
turnover <- holdings %>% group_by(signal, form_ym) %>% summarise(nm = list(ticker), .groups = "drop") %>%
  arrange(signal, form_ym) %>% group_by(signal) %>%
  mutate(prev = lag(nm),
         turnover = map2_dbl(nm, prev, ~ if (is.null(.y) || all(is.na(.y))) NA_real_ else 1 - length(intersect(.x, .y)) / n_pick)) %>%
  ungroup()
turnover %>% group_by(signal) %>% summarise(avg_monthly_turnover = mean(turnover, na.rm = TRUE)) %>%
  kable(digits = 3, caption = "(b) Average monthly turnover (share of the 10 names replaced)")
(b) Average monthly turnover (share of the 10 names replaced)
signal avg_monthly_turnover
alpha 0.186
exp_ret 0.171

C3. Portfolio returns

hold_ret <- holdings %>%
  mutate(hold_ym = form_ym %m+% months(1)) %>%
  left_join(stock %>% select(ticker, hold_ym = ym, ret), by = c("ticker", "hold_ym"))

hold_ret %>% group_by(signal) %>%
  summarise(stock_months = n(), missing_return = sum(is.na(ret)), share_missing = mean(is.na(ret)),
            months_with_a_drop = n_distinct(form_ym[is.na(ret)])) %>%
  kable(digits = 4, caption = "How often a holding-month return is missing (stock is dropped, weights rescaled)")
How often a holding-month return is missing (stock is dropped, weights rescaled)
signal stock_months missing_return share_missing months_with_a_drop
alpha 600 0 0 0
exp_ret 600 0 0 0
w <- hold_ret %>% filter(!is.na(ret)) %>%
  group_by(signal, form_ym, hold_ym) %>%
  mutate(w_ew = 1 / n(), w_vw = mcap / sum(mcap)) %>% ungroup()

port <- w %>% group_by(signal, form_ym, hold_ym) %>%
  summarise(EW = sum(w_ew * ret), VW = sum(w_vw * ret),
            max_w_vw = max(w_vw), sum_w_ew = sum(w_ew), sum_w_vw = sum(w_vw), .groups = "drop")

port %>% group_by(signal) %>% summarise(avg_largest_weight_VW = mean(max_w_vw)) %>%
  kable(digits = 3, caption = "Average largest single weight in the value-weighted portfolios")
Average largest single weight in the value-weighted portfolios
signal avg_largest_weight_VW
alpha 0.376
exp_ret 0.308
kable(tibble(check = c("10 stocks per signal and month (before dropping)", "Equal weights add up to 1",
                       "Value weights add up to 1", "60 holding months per signal"),
             passed = c(all(count(holdings, signal, form_ym)$n == n_pick),
                        all(abs(port$sum_w_ew - 1) < 1e-9), all(abs(port$sum_w_vw - 1) < 1e-9),
                        all(count(port, signal)$n == 60))))
check passed
10 stocks per signal and month (before dropping) TRUE
Equal weights add up to 1 TRUE
Value weights add up to 1 TRUE
60 holding months per signal TRUE
pr_strat <- port %>%
  pivot_longer(c(EW, VW), names_to = "wt", values_to = "ret") %>%
  mutate(portfolio = paste0(if_else(signal == "alpha", "alpha", "exp"), "_", wt)) %>%
  select(portfolio, hold_ym, ret)

C4. Benchmarks

vw50 <- top50 %>%
  filter(ym <= as.Date("2025-11-01")) %>%
  mutate(hold_ym = ym %m+% months(1)) %>%
  left_join(stock %>% select(ticker, hold_ym = ym, ret), by = c("ticker", "hold_ym")) %>%
  filter(!is.na(ret)) %>%
  group_by(hold_ym) %>% summarise(ret = sum(mcap * ret) / sum(mcap), .groups = "drop") %>%
  mutate(portfolio = "VW50")

bench <- inner_join(vw50 %>% select(hold_ym, vw50 = ret), etf_ret %>% select(hold_ym, etf = ret), by = "hold_ym")
n_b <- nrow(bench)
tibble(months = n_b,
       correlation = cor(bench$vw50, bench$etf),
       tracking_error_ann = sd(bench$vw50 - bench$etf) * sqrt(12),
       cum_VW50 = prod(1 + bench$vw50) - 1,
       cum_0050 = prod(1 + bench$etf) - 1,
       cum_difference = (prod(1 + bench$vw50) - 1) - (prod(1 + bench$etf) - 1)) %>%
  kable(digits = 4, caption = "VW50 proxy versus 0050")
VW50 proxy versus 0050
months correlation tracking_error_ann cum_VW50 cum_0050 cum_difference
60 0.9899 0.0282 1.4881 1.4874 6e-04

The two series differ because the VW50 proxy ranks stocks by total market capitalisation every month and weights them by it, while 0050 follows its own index with float-adjusted weights, a periodic (not monthly) review and weight caps, and it pays management fees and has tracking error and cash drag. In addition, the 0050 adjusted price includes reinvested dividends whereas the stock returns come from TEJ’s monthly return series, and our top-50 list is a proxy and does not match the true 0050 holdings exactly.

C5. Performance and comparison

pr_all <- bind_rows(
  pr_strat,
  vw50 %>% select(portfolio, hold_ym, ret),
  etf_ret %>% mutate(portfolio = "0050")
) %>%
  filter(hold_ym >= as.Date("2021-01-01"), hold_ym <= as.Date("2025-12-01")) %>%
  left_join(ff %>% select(hold_ym = ym, rf, MKT_RF, SMB, HML), by = "hold_ym") %>%
  left_join(etf_ret %>% select(hold_ym, bench = ret), by = "hold_ym") %>%
  mutate(portfolio = factor(portfolio, levels = c("alpha_EW", "alpha_VW", "exp_EW", "exp_VW", "VW50", "0050")))

perf_fun <- function(d) {
  n <- nrow(d); wealth <- cumprod(1 + d$ret)
  ann <- prod(1 + d$ret)^(12 / n) - 1
  vol <- sd(d$ret) * sqrt(12)
  fit <- summary(lm(I(ret - rf) ~ MKT_RF + SMB + HML, data = d))
  diff <- d$ret - d$bench
  is_bm <- all(abs(diff) < 1e-12)
  ann_bm <- prod(1 + d$bench)^(12 / n) - 1
  tibble(months = n, ann_return = ann, ann_vol = vol,
         sharpe = mean(d$ret - d$rf) * 12 / vol,
         max_drawdown = min(wealth / cummax(c(1, wealth))[-1] - 1),
         cum_return = prod(1 + d$ret) - 1,
         ff3_alpha_monthly = fit$coefficients[1, 1], alpha_t = fit$coefficients[1, 3],
         active_return = if (is_bm) NA_real_ else ann - ann_bm,
         tracking_error = if (is_bm) NA_real_ else sd(diff) * sqrt(12),
         info_ratio = if (is_bm) NA_real_ else mean(diff) * 12 / (sd(diff) * sqrt(12)),
         beat_share = if (is_bm) NA_real_ else mean(d$ret > d$bench))
}

performance <- pr_all %>% group_by(portfolio) %>% group_modify(~ perf_fun(.x)) %>% ungroup()
kable(performance, digits = 4, caption = "Performance, January 2021 to December 2025")
Performance, January 2021 to December 2025
portfolio months ann_return ann_vol sharpe max_drawdown cum_return ff3_alpha_monthly alpha_t active_return tracking_error info_ratio beat_share
alpha_EW 60 0.1303 0.3155 0.5441 -0.5334 0.8449 -0.0060 -0.6843 -0.0696 0.2477 -0.1237 0.4833
alpha_VW 60 0.0755 0.2978 0.3919 -0.5055 0.4386 -0.0098 -1.2943 -0.1245 0.2115 -0.4046 0.4167
exp_EW 60 0.1977 0.2855 0.7731 -0.4112 1.4645 -0.0025 -0.3502 -0.0022 0.2292 0.0804 0.4833
exp_VW 60 0.1413 0.2916 0.5966 -0.4524 0.9361 -0.0056 -0.7183 -0.0587 0.2191 -0.1295 0.4833
VW50 60 0.2000 0.1903 1.0580 -0.2835 1.4881 0.0018 2.5089 0.0001 0.0282 -0.0357 0.5000
0050 60 0.1999 0.1964 1.0302 -0.2931 1.4874 0.0022 1.8869 NA NA NA NA
portfolio_returns <- pr_all %>% select(portfolio, hold_ym, ret)
cat("portfolio_returns rows:", nrow(portfolio_returns), "(expected 360) | holdings rows:", nrow(holdings), "(expected 1,200)\n")
## portfolio_returns rows: 360 (expected 360) | holdings rows: 1200 (expected 1,200)
growth <- portfolio_returns %>% arrange(portfolio, hold_ym) %>% group_by(portfolio) %>%
  mutate(value = 100 * cumprod(1 + ret)) %>% ungroup()
start <- tibble(portfolio = levels(pr_all$portfolio), hold_ym = as.Date("2020-12-01"), value = 100)
growth <- bind_rows(start %>% mutate(portfolio = factor(portfolio, levels = levels(pr_all$portfolio))), growth)

p_growth <- ggplot(growth, aes(hold_ym, value, colour = portfolio)) +
  geom_line(linewidth = 0.9) +
  labs(title = "Growth of NT$100 (December 2020 = 100)", x = NULL, y = "NT$", colour = NULL) +
  theme_minimal()
p_growth

ggsave("output/growth_chart.png", p_growth, width = 9, height = 5, dpi = 150)

saveRDS(holdings, "output/holdings.rds"); saveRDS(portfolio_returns, "output/portfolio_returns.rds")
saveRDS(performance, "output/performance.rds")
write_csv(holdings, "output/holdings.csv"); write_csv(portfolio_returns, "output/portfolio_returns.csv")
write_csv(performance, "output/performance.csv")

C6. Discussion

Risk-adjusted performance. The portfolio with the highest FF3 alpha is exp_EW, with a monthly alpha of -0.25% and a t-statistic of -0.35. 0 of the four portfolios have an alpha t-statistic above 1.96. So none of them beats 0050 after adjusting for the three factors with statistical confidence, even if some have a higher raw return. The raw return alone is not enough, because a portfolio can earn more simply by taking more market risk.

Equal versus value weights. The largest single weight in the value-weighted portfolios is on average 0.38 (alpha rule) and 0.31 (expected-return rule). Value weights are therefore concentrated in one or two giants, while equal weights give each stock 10%, so the two schemes have different volatility and different exposure to the largest firms and to small names.

Alpha rule versus expected-return rule. On average the two top-10 lists have only 3.4 stocks in common. Alpha is the part of a stock’s average return not explained by the factors, whereas exp_ret is only the part explained by the loadings and the factor averages, with alpha left out. The first picks stocks that did unusually well in the past window, the second picks stocks with high loadings on factors that did well.

Limitations. (1) The 0050 proxy and the benchmark are not exact: the top 50 by market cap is not the true index holdings, and weights and review dates differ. (2) Alpha, loadings and factor averages are estimated with 36 observations, so the signals are noisy and the ranks change a lot. (3) There are no trading costs, taxes or liquidity limits, although the turnover is high. (4) The sample has only 60 holding months in one market regime, so a difference of a few percent per year is not statistically reliable.

## [1] "R version 4.6.1 (2026-06-24 ucrt)"