Portfolio Theory: Estimate Beta for All Companies Listed on Ho Chi Minh Stock Exchange (HOSE)

Introduction

Giá trị beta của một tài sản tài chính một thước đo quan trọng và làm nền tảng cho nhiều mô hình tài chính và định giá tài sản tài chính. Mô tả về beta bạn đọc có thể tham khảo lí thuyết về danh mục đầu tư hoặc CAPM Model.

Có nhiều cách tiếp cận cho việc ước lượng beta và với bối cảnh về thị trường tài chính Việt Nam chúng ta có thể sử dụng cách tiếp cận được đề xuất của Gujatati (2009) để ước lượng beta cho các công ti niêm yết trên sàn HOSE. Chi tiết hơn về cách tiếp cận này bạn đọc có thể tham khảo ở chương 6, trang 168, Table 6.1 của cuốn Basic Economtrics.

Our Challenges

Hiện có hơn 1600 công ti đang niêm yết ở sàn HOSE. Tuy nhiên để các ước lượng cho beta đáng tin cậy hơn chúng ta chỉ lấy ra những công ti nào mà có thời gian niêm yết đủ lâu. Cụ thể khoảng thời gian chúng ta lấy dữ liệu là từ 01/01/2017 đến 01/07/2019. Về chỉ số đại diện cho lợi tức thị trường chúng ta có thể chọn chỉ số VNINDEX trong cùng khoảng thời gian trên.

Do vậy thách thức đầu tiên của chúng ta là phải trước hết lấy được dữ liệu giao dịch cho các công ti + chỉ số VNINDEX trong khoảng thời gian trên. Sau đó làm sạch dữ liệu và tính toán log return - là dữ liệu cần thiết sử dụng để ước lượng beta bằng hồi quy OLS như mô tả của Gujatati (2009).

Dưới đây là R codes lấy dữ liệu cho khoảng 500 công ti từ https://www.vndirect.com.vn:

#===============================================================
#    Function collect all transaction data with inputs are: 
#    (1) ticker selected, (2) start date, and end date. 
#===============================================================


get_transData_VND <- function(symbol, from_Date, end_Date) {
  
  #-------------------------------------------------------------------------
  #  Stage 1: Create HTML form, send request and collect transaction data
  #  and collects stock transactions for a specific page selected
  #-------------------------------------------------------------------------
  
  url <- "https://www.vndirect.com.vn/portal/thong-ke-thi-truong-chung-khoan/lich-su-gia.shtml"
  page_session <- html_session(url)               
  pgform <- html_form(page_session) %>% .[[1]]
  
  
  get_transaction_data <- function(page_index) {
    
    filled_form <- set_values(form = pgform, 
                              pagingInfo.indexPage = page_index, 
                              searchMarketStatisticsView.symbol = symbol, 
                              strFromDate = from_Date, 
                              strToDate = end_Date)
    
    
    submit_form(page_session, filled_form) %>% 
      read_html() -> page_content
    
    page_content %>% 
      html_nodes(".lichsugia div") %>%
      html_text() %>% 
      matrix(ncol = 10, byrow = TRUE) %>% 
      data.frame() %>% 
      slice(-1) %>% 
      select(-2) %>% 
      mutate(X1 = as.character(X1)) %>% 
      mutate(X1 = str_replace_all(X1, "[^0-9]", "")) %>% 
      mutate(X1 = ymd(X1)) %>% 
      mutate_if(is.factor, function(x) {as.character(x)}) %>% 
      mutate_if(is.character, function(x) {as.numeric(x)}) -> df_price
    
    names(df_price) <- c("date", "open", "high", "low", "close", 
                         "average", "adjusted", "volume", "reconcile_volume")
    
    return(df_price)
    
  }
  
  #------------------------------------------------------------------
  #  Stage 2: Extract the last page and return all transaction data
  #------------------------------------------------------------------
  
  
  filled_form_for_pages <- set_values(form = pgform, 
                                      searchMarketStatisticsView.symbol = symbol, 
                                      strFromDate = from_Date, 
                                      strToDate = end_Date)
  
  
  submit_form(page_session, filled_form_for_pages) %>% 
    read_html() -> page_content_pages
  
  
  page_content_pages %>% 
    html_nodes(".paging") %>% 
    html_text() %>%  
    str_extract("/[0-9]{1,100}") %>% 
    str_replace_all("[^0-9]", "") %>% 
    as.numeric() -> n_pages
  
  
  if (is.na(n_pages)) {
    final_df <- get_transaction_data(page_index = 1) %>% 
      mutate(symbol = str_to_upper(symbol)) %>% 
      select(symbol, everything())
  } else {
    
    lapply(1:n_pages, get_transaction_data) -> all_data_list
    
    final_df <- do.call("bind_rows", all_data_list) %>% 
      mutate(symbol = str_to_upper(symbol)) %>% 
      select(symbol, everything())
  }
  
  return(final_df)
  
}


#====================================
#  Function gets all tickers listed
#====================================

get_ticker_listed <- function(link) {
  
  link %>% 
    read_html() %>% 
    html_table(fill = TRUE) %>% 
    .[[2]] %>% 
    slice(4:28) %>% 
    select(2:10) %>% 
    mutate_all(function(x) {stri_trans_general(x, "Latin-ASCII")}) -> my_df
  
  names(my_df) <- c("ticker", "firm_name", "fist_date_listed", "firs_volume", "price_listed", 
                    "current_volume", "treasure_volume", "listed_volume", "state_own")
  
  return(my_df)
  
  
}


# Get all tickers listed on HOSE: 

all_links <- paste0("https://www.cophieu68.vn/companylist.php?currentPage=", 1:65, "&o=s&ud=a")
lapply(all_links, get_ticker_listed) -> tickers_list
df_tickers <- do.call("bind_rows", tickers_list)


df_tickers %>% 
  mutate(fist_date_listed = dmy(fist_date_listed)) %>% 
  filter(fist_date_listed >= ymd("2017-01-01")) %>% 
  filter(str_count(ticker) == 3) %>% 
  pull(ticker) %>% 
  as.character() -> all_my_tickers


#================================
#  A function for getting data
#================================

get_transaction_data <- function(ticker_selected) {
  from_Date <- "01/01/2017"
  end_Date <- "01/07/2019"
  get_transData_VND(symbol = ticker_selected, from_Date = from_Date, end_Date = end_Date) -> df_final
  return(df_final)
  
}


# Collect data for tickers selected: 

lapply(all_my_tickers, get_transaction_data) -> transactions_data_list
df_transactions_data <- do.call("bind_rows", transactions_data_list)

# Collect VNINDEX indicator: 

df_vnindex <- get_transaction_data(ticker_selected = "VNINDEX") 

# Save our data for using later: 

# save.image(file = "my_work_space.RData")
save(df_transactions_data, file = "df_transactions_data.RData")
save(df_vnindex, file = "df_vnindex_2017_2019.RData")

Results

R Codes cho ước lượng beta:

Beta của các công ti niêm yết theo chiều giảm dần:

ticker beta std.error statistic p.value N
VPB 1.530 0.097 15.780 0.000 463
PLX 1.474 0.067 22.104 0.000 545
VRE 1.277 0.082 15.534 0.000 407
VCI 1.163 0.096 12.058 0.000 492
HVN 1.126 0.103 10.982 0.000 610
HDB 1.070 0.072 14.967 0.000 364
BSR 1.013 0.096 10.586 0.000 332
VGI 1.009 0.285 3.544 0.000 188
VTK 1.007 0.784 1.284 0.201 128
OIL 0.942 0.101 9.321 0.000 328
VHM 0.934 0.116 8.048 0.000 280
VGT 0.926 0.103 8.979 0.000 617
PLP 0.921 0.125 7.369 0.000 461
TCB 0.918 0.345 2.662 0.008 268
MSH 0.909 0.262 3.475 0.001 142
DVN 0.902 0.116 7.762 0.000 527
C4G 0.901 0.390 2.308 0.023 134
VJC 0.879 0.084 10.509 0.000 582
LPB 0.844 0.077 10.918 0.000 429
POW 0.803 0.091 8.831 0.000 320
HII 0.778 0.112 6.953 0.000 503
ATB 0.759 0.284 2.669 0.008 457
DPG 0.753 0.192 3.925 0.000 606
DSP 0.748 0.436 1.715 0.088 172
TPB 0.700 0.084 8.296 0.000 297
TGG 0.670 0.290 2.314 0.021 274
ART 0.638 0.234 2.732 0.007 470
YBM 0.638 0.275 2.324 0.021 212
VEA 0.628 0.169 3.719 0.000 248
FTS 0.622 0.078 7.998 0.000 609
SJF 0.621 0.135 4.603 0.000 494
EIN 0.602 0.227 2.651 0.008 570
VIB 0.593 0.099 6.006 0.000 613
NRC 0.590 0.136 4.334 0.000 307
DRI 0.582 0.161 3.608 0.000 525
DTG 0.549 0.192 2.860 0.004 582
TDG 0.524 0.153 3.435 0.001 508
SBH 0.507 0.353 1.437 0.152 265
TDT 0.505 0.127 3.973 0.000 236
BWE 0.499 0.090 5.530 0.000 483
VTP 0.495 0.375 1.318 0.190 145
VGR 0.492 0.175 2.807 0.005 302
TVH 0.490 0.992 0.493 0.623 108
CIA 0.481 0.130 3.700 0.000 390
M10 0.474 0.204 2.328 0.020 361
TNS 0.471 0.208 2.261 0.024 614
CRC 0.469 0.213 2.199 0.029 213
SCS 0.462 0.090 5.112 0.000 483
BMG 0.447 0.657 0.681 0.497 123
DSC 0.439 0.289 1.518 0.130 364
HTK 0.435 0.326 1.334 0.184 197
GVR 0.429 0.166 2.582 0.010 318
NQN 0.422 0.589 0.717 0.474 259
TA6 0.420 0.185 2.267 0.024 391
PMG 0.412 0.071 5.812 0.000 352
BCM 0.406 0.190 2.135 0.033 338
TLP 0.402 0.202 1.990 0.047 383
AMS 0.398 0.171 2.331 0.020 598
BDC 0.392 0.537 0.731 0.466 196
VET 0.379 0.245 1.549 0.122 380
TQN 0.373 0.134 2.781 0.006 596
VHD 0.368 0.227 1.621 0.106 503
VVN 0.363 0.234 1.549 0.122 421
HTM 0.361 0.177 2.045 0.042 289
NSS 0.361 0.371 0.972 0.332 163
BTD 0.354 0.184 1.926 0.055 580
NHT 0.342 0.212 1.609 0.108 388
HTN 0.338 0.233 1.449 0.150 154
HBW 0.335 0.279 1.200 0.231 236
HEJ 0.335 0.177 1.890 0.059 487
VEC 0.330 0.224 1.471 0.142 487
HWS 0.327 0.352 0.930 0.354 229
HTG 0.326 0.119 2.738 0.006 509
CET 0.324 0.205 1.579 0.115 477
AST 0.323 0.086 3.741 0.000 365
KDF 0.323 0.155 2.080 0.038 434
NAS 0.322 0.165 1.945 0.052 601
EVF 0.321 0.278 1.153 0.250 222
TVP 0.315 0.289 1.091 0.276 463
HTT 0.313 0.164 1.908 0.057 494
IDC 0.312 0.154 2.023 0.044 393
MIG 0.308 0.118 2.614 0.009 537
VPI 0.301 0.053 5.643 0.000 384
BHA 0.298 0.220 1.357 0.175 474
FRT 0.295 0.197 1.502 0.134 293
VAV 0.292 0.260 1.124 0.261 479
HNI 0.289 0.180 1.607 0.109 381
GKM 0.282 0.075 3.744 0.000 486
LMH 0.282 0.249 1.131 0.260 175
LTG 0.281 0.087 3.208 0.001 481
HVH 0.277 0.268 1.034 0.303 140
MQN 0.275 0.327 0.843 0.400 254
NSH 0.271 0.174 1.560 0.119 476
VIF 0.267 0.197 1.360 0.174 610
SNZ 0.266 0.188 1.412 0.159 397
MRF 0.262 0.198 1.328 0.185 381
C69 0.261 0.168 1.554 0.121 545
THI 0.260 0.127 2.042 0.042 508
PME 0.259 0.081 3.206 0.001 405
CEE 0.258 0.113 2.286 0.023 531
SKH 0.251 0.096 2.605 0.010 415
VDP 0.245 0.112 2.189 0.029 465
VHE 0.244 0.425 0.575 0.567 111
EVG 0.241 0.112 2.154 0.032 513
LMC 0.241 0.180 1.341 0.181 439
BSH 0.237 0.343 0.693 0.489 246
SID 0.237 0.180 1.319 0.188 613
TOT 0.236 0.274 0.860 0.390 486
CTR 0.233 0.133 1.752 0.081 411
YTC 0.233 0.216 1.078 0.282 473
AFC 0.230 0.127 1.809 0.071 511
CC4 0.225 0.233 0.965 0.335 477
DP1 0.218 0.281 0.776 0.438 262
BAL 0.216 0.206 1.051 0.294 359
HKT 0.215 0.198 1.091 0.276 610
FRM 0.213 0.169 1.257 0.209 393
DHN 0.211 0.214 0.983 0.326 297
GEG 0.207 0.093 2.232 0.026 567
HAV 0.206 0.223 0.926 0.355 389
CHS 0.204 0.244 0.835 0.404 610
TCW 0.202 0.154 1.310 0.191 501
TCI 0.201 0.454 0.443 0.658 202
KGU 0.200 0.284 0.703 0.482 501
PBT 0.199 0.891 0.223 0.824 107
TCK 0.197 0.123 1.600 0.110 413
PPH 0.196 0.161 1.221 0.223 459
X20 0.196 0.162 1.213 0.226 345
TNW 0.194 0.165 1.174 0.241 522
VPG 0.193 0.113 1.709 0.088 355
VDB 0.188 0.189 0.995 0.321 146
QTP 0.185 0.164 1.125 0.261 570
TTT 0.185 0.112 1.650 0.099 517
LLM 0.183 0.251 0.730 0.466 464
PVH 0.181 0.211 0.856 0.392 527
ABR 0.179 0.398 0.449 0.654 262
BSA 0.176 0.209 0.842 0.401 213
DNH 0.176 0.154 1.147 0.252 506
SBV 0.174 0.113 1.541 0.124 530
APF 0.166 0.124 1.345 0.179 513
DBD 0.166 0.078 2.115 0.035 603
FRC 0.165 0.259 0.639 0.524 230
TOW 0.165 0.155 1.066 0.289 102
VDM 0.165 0.147 1.122 0.263 293
CMN 0.163 0.207 0.788 0.431 491
QNU 0.159 0.068 2.327 0.020 582
MDN 0.158 0.068 2.330 0.021 150
PWS 0.157 0.131 1.196 0.232 497
TNI 0.156 0.108 1.442 0.150 521
TTN 0.155 0.209 0.741 0.459 547
DHD 0.153 0.278 0.553 0.580 537
PCM 0.152 0.146 1.040 0.299 468
X18 0.149 0.177 0.845 0.399 605
MH3 0.147 0.182 0.808 0.420 578
TVW 0.147 0.136 1.077 0.282 382
KOS 0.146 0.126 1.157 0.248 383
SBM 0.144 0.127 1.136 0.257 439
HHR 0.142 0.077 1.845 0.066 589
HPX 0.142 0.138 1.025 0.306 232
PSN 0.141 0.145 0.971 0.332 498
VSM 0.141 0.204 0.692 0.490 486
TVA 0.138 0.162 0.849 0.396 553
HNA 0.136 0.161 0.844 0.399 429
BWS 0.133 0.201 0.659 0.510 391
NHH 0.133 0.243 0.548 0.584 448
DS3 0.132 0.154 0.857 0.392 461
NUE 0.132 0.191 0.689 0.491 588
BAB 0.131 0.059 2.240 0.026 369
GLC 0.129 0.276 0.466 0.642 114
HIZ 0.128 0.360 0.355 0.723 229
TLI 0.123 0.676 0.183 0.855 102
NED 0.122 0.139 0.879 0.380 462
PNT 0.122 0.192 0.632 0.528 610
XLV 0.119 0.059 2.009 0.046 277
IKH 0.116 0.108 1.077 0.282 363
MCH 0.115 0.098 1.181 0.238 615
FHN 0.114 0.095 1.198 0.232 368
IDN 0.114 0.093 1.219 0.224 359
VGV 0.114 0.220 0.521 0.603 486
ACS 0.110 0.140 0.789 0.431 488
MKP 0.104 0.179 0.583 0.560 350
HNR 0.102 0.227 0.451 0.652 264
NAW 0.102 0.237 0.433 0.666 472
CCP 0.100 0.203 0.493 0.623 570
HC3 0.098 0.170 0.575 0.565 490
HSA 0.093 0.152 0.614 0.539 603
UPC 0.091 0.238 0.382 0.703 545
HFT 0.090 0.173 0.522 0.602 355
CBI 0.088 0.124 0.707 0.480 434
CCV 0.088 0.100 0.875 0.382 613
S72 0.086 0.098 0.876 0.382 277
DM7 0.083 0.063 1.318 0.189 174
TSG 0.083 0.074 1.130 0.259 548
ILS 0.082 0.286 0.287 0.774 320
BCB 0.080 0.147 0.544 0.587 164
PIA 0.076 0.185 0.411 0.681 586
MVC 0.075 0.145 0.519 0.604 566
LEC 0.074 0.121 0.615 0.539 509
TRT 0.073 0.104 0.705 0.481 570
PGV 0.072 0.203 0.355 0.723 318
EMS 0.071 0.204 0.348 0.728 364
HTR 0.070 0.043 1.617 0.107 586
PVY 0.070 0.165 0.424 0.672 368
SKV 0.070 0.171 0.407 0.684 408
BMD 0.069 0.119 0.576 0.565 509
DSS 0.069 0.081 0.852 0.395 544
DSG 0.068 0.059 1.152 0.250 467
FOX 0.068 0.119 0.573 0.567 609
KTU 0.067 0.059 1.134 0.257 338
PRT 0.064 0.232 0.276 0.783 288
THN 0.064 0.086 0.742 0.459 429
HFB 0.063 0.176 0.358 0.720 560
HGW 0.063 0.098 0.646 0.518 611
TEL 0.063 0.228 0.277 0.782 436
MTV 0.061 0.230 0.263 0.793 464
KHS 0.059 0.126 0.472 0.637 371
X26 0.059 0.581 0.101 0.920 243
TCJ 0.058 0.060 0.977 0.329 393
TCD 0.057 0.127 0.447 0.655 522
YEG 0.056 0.262 0.215 0.830 252
SUM 0.055 0.101 0.542 0.588 364
BRS 0.054 0.081 0.671 0.503 602
CDG 0.051 0.093 0.553 0.580 583
WTN 0.050 0.108 0.468 0.640 399
AMP 0.046 0.159 0.288 0.774 610
DCF 0.046 0.184 0.252 0.801 610
GLW 0.045 0.096 0.475 0.635 363
CPH 0.041 0.054 0.761 0.447 596
CPI 0.041 0.116 0.355 0.722 477
DCG 0.039 0.114 0.343 0.732 130
MVN 0.039 0.104 0.370 0.712 179
CRE 0.038 0.238 0.161 0.872 202
XDH 0.038 0.407 0.093 0.926 169
TA3 0.037 0.035 1.055 0.292 364
BSQ 0.035 0.121 0.291 0.771 582
FIR 0.034 0.179 0.190 0.849 171
KTC 0.032 0.153 0.209 0.835 254
BRR 0.029 0.188 0.153 0.879 507
HPI 0.029 0.265 0.111 0.912 429
BSD 0.028 0.032 0.884 0.377 540
BDT 0.027 0.140 0.192 0.848 450
TTS 0.027 0.064 0.426 0.670 529
BBM 0.025 0.124 0.200 0.842 364
ONW 0.025 0.068 0.362 0.718 589
PND 0.023 0.120 0.194 0.846 588
DTD 0.022 0.144 0.150 0.881 399
HDW 0.022 0.126 0.178 0.859 408
VNY 0.022 0.347 0.062 0.950 224
HAM 0.021 0.078 0.276 0.783 461
DNE 0.019 0.110 0.176 0.860 556
EMG 0.018 0.062 0.289 0.773 590
TBN 0.018 0.012 1.469 0.143 386
MEL 0.016 0.081 0.202 0.840 435
TLD 0.015 0.149 0.102 0.919 384
HBH 0.014 0.180 0.075 0.940 468
HHP 0.011 0.210 0.053 0.957 221
SEP 0.011 0.080 0.139 0.889 598
CHC 0.010 0.094 0.102 0.919 590
HDP 0.010 0.165 0.058 0.954 570
MCT 0.010 0.031 0.307 0.759 616
BGW 0.007 0.009 0.828 0.408 411
MDA 0.006 0.020 0.318 0.751 361
MLC 0.006 0.012 0.456 0.648 525
HEP 0.005 0.114 0.045 0.964 378
LWS 0.005 0.013 0.398 0.691 373
C36 0.004 0.011 0.376 0.707 519
L12 0.003 0.143 0.020 0.984 617
PCF 0.003 0.041 0.076 0.940 561
SVL 0.003 0.003 0.821 0.412 458
DX2 0.002 0.004 0.607 0.544 246
CDR 0.001 0.081 0.018 0.985 501
MC3 0.001 0.008 0.183 0.855 509
VSF 0.001 0.186 0.005 0.996 295
BAX 0.000 0.139 0.003 0.997 564
BNW 0.000 0.054 -0.003 0.998 120
EIC -0.001 0.129 -0.004 0.997 582
AVC -0.002 0.168 -0.014 0.989 363
BLW -0.002 0.005 -0.357 0.722 170
MND -0.002 0.015 -0.143 0.886 467
T12 -0.002 0.002 -1.242 0.215 407
DNN -0.003 0.100 -0.025 0.980 486
NAU -0.003 0.004 -0.753 0.452 249
PTX -0.003 0.274 -0.009 0.993 228
RHN -0.003 0.012 -0.226 0.821 570
MQB -0.004 0.004 -1.132 0.259 405
PAI -0.004 0.004 -0.905 0.366 603
PDV -0.006 0.204 -0.030 0.976 546
CCH -0.007 0.107 -0.069 0.945 454
MTS -0.007 0.010 -0.695 0.488 540
QLT -0.008 0.074 -0.107 0.915 558
RTH -0.009 0.044 -0.209 0.834 581
VBG -0.009 0.053 -0.162 0.871 564
HUG -0.010 0.212 -0.047 0.962 377
MVY -0.010 0.181 -0.058 0.954 601
AC4 -0.011 0.179 -0.062 0.950 596
LBC -0.011 0.073 -0.148 0.883 464
LG9 -0.011 0.117 -0.098 0.922 377
NTT -0.011 0.032 -0.358 0.721 370
TVT -0.011 0.110 -0.098 0.922 486
UMC -0.011 0.007 -1.522 0.129 456
CVH -0.014 0.012 -1.200 0.231 505
HAF -0.014 0.265 -0.052 0.959 481
LIC -0.016 0.160 -0.103 0.918 516
MPY -0.016 0.013 -1.250 0.212 531
FGL -0.017 0.048 -0.353 0.724 195
NAC -0.018 0.126 -0.142 0.887 567
VEE -0.018 0.046 -0.399 0.690 613
MGG -0.019 0.250 -0.075 0.940 407
SPV -0.020 0.151 -0.132 0.895 592
HTE -0.021 0.240 -0.090 0.929 481
HLE -0.023 0.102 -0.226 0.821 401
CAG -0.025 0.109 -0.230 0.818 387
FSO -0.026 0.046 -0.564 0.573 598
CE1 -0.029 0.073 -0.396 0.692 554
CLX -0.029 0.149 -0.193 0.847 581
DDG -0.030 0.244 -0.121 0.904 128
HLB -0.030 0.205 -0.145 0.884 596
TMB -0.031 0.105 -0.297 0.767 608
DTI -0.032 0.146 -0.218 0.828 364
NHV -0.032 0.054 -0.598 0.550 509
TTJ -0.032 0.200 -0.161 0.872 505
CEG -0.035 0.089 -0.398 0.691 529
ILA -0.035 0.253 -0.137 0.891 391
QLD -0.036 0.097 -0.375 0.708 364
DCH -0.039 0.137 -0.284 0.776 295
IST -0.041 0.144 -0.287 0.774 615
FTM -0.044 0.077 -0.567 0.571 598
GVT -0.044 0.132 -0.335 0.738 610
SVH -0.044 0.110 -0.403 0.687 369
KHW -0.046 0.080 -0.570 0.569 588
SAL -0.046 0.051 -0.893 0.372 418
IRC -0.047 0.055 -0.850 0.396 353
NBE -0.047 0.201 -0.233 0.816 461
HRB -0.049 0.168 -0.288 0.773 407
FT1 -0.050 0.138 -0.362 0.717 435
HFS -0.050 0.110 -0.451 0.652 358
PCC -0.053 0.160 -0.331 0.741 401
DHB -0.054 0.173 -0.312 0.755 479
AAV -0.055 0.254 -0.218 0.828 253
HAB -0.055 0.080 -0.683 0.495 364
CGV -0.056 0.224 -0.250 0.803 504
RGC -0.057 0.272 -0.209 0.834 506
MNB -0.058 0.170 -0.342 0.732 294
MSC -0.060 0.126 -0.477 0.633 596
CKH -0.061 0.111 -0.550 0.583 610
FCS -0.061 0.084 -0.725 0.469 579
BTB -0.062 0.166 -0.373 0.709 610
HEM -0.062 0.250 -0.250 0.803 617
CIP -0.065 0.127 -0.515 0.607 435
BQB -0.066 0.130 -0.510 0.610 362
DP2 -0.067 0.160 -0.416 0.678 527
SIV -0.067 0.208 -0.324 0.746 525
CAT -0.068 0.244 -0.278 0.781 316
SON -0.071 0.115 -0.612 0.541 364
NDT -0.074 0.449 -0.164 0.870 198
PKR -0.075 0.164 -0.458 0.647 614
CTF -0.079 0.146 -0.545 0.586 520
DVW -0.079 0.333 -0.236 0.813 266
TDB -0.080 0.094 -0.859 0.391 484
PLA -0.081 0.195 -0.414 0.679 397
KGM -0.082 0.125 -0.657 0.511 439
USC -0.082 0.103 -0.795 0.427 598
BUD -0.083 0.312 -0.266 0.791 253
HSM -0.083 0.244 -0.341 0.733 297
LMI -0.084 0.142 -0.592 0.554 483
BHK -0.087 0.096 -0.910 0.364 307
THR -0.089 0.094 -0.939 0.348 552
CC1 -0.091 0.173 -0.523 0.601 483
VIM -0.093 0.194 -0.482 0.630 602
HPH -0.098 0.158 -0.617 0.537 369
VWS -0.098 0.250 -0.392 0.695 614
HPU -0.099 0.123 -0.808 0.419 363
HCS -0.100 0.103 -0.977 0.329 545
AG1 -0.101 0.148 -0.681 0.496 361
BDF -0.105 0.087 -1.212 0.226 614
CH5 -0.109 0.152 -0.717 0.473 509
CKA -0.110 0.584 -0.189 0.851 172
KLB -0.111 0.138 -0.808 0.419 498
BSL -0.115 0.149 -0.775 0.439 507
SHE -0.118 0.415 -0.283 0.778 102
TTD -0.118 0.128 -0.925 0.355 598
JOS -0.120 0.106 -1.128 0.260 477
BLT -0.123 0.199 -0.619 0.536 491
SKN -0.125 0.490 -0.255 0.799 177
KSE -0.128 0.102 -1.253 0.211 467
HLS -0.133 0.126 -1.056 0.292 422
DAR -0.135 0.169 -0.798 0.425 533
VLP -0.135 0.121 -1.115 0.265 485
CBS -0.136 0.111 -1.218 0.224 505
VLW -0.136 0.156 -0.868 0.386 486
EPH -0.140 0.155 -0.902 0.368 374
C22 -0.142 0.115 -1.232 0.219 275
CDP -0.146 0.477 -0.306 0.760 239
NCP -0.147 0.132 -1.111 0.267 437
DPH -0.152 0.155 -0.981 0.327 604
A32 -0.168 0.254 -0.662 0.509 168
TTE -0.168 0.621 -0.271 0.787 134
PTO -0.169 0.173 -0.975 0.330 505
FBC -0.170 0.092 -1.842 0.066 418
HSL -0.171 0.181 -0.943 0.346 285
TDP -0.171 0.435 -0.392 0.696 154
TSJ -0.177 0.204 -0.868 0.386 475
FTI -0.185 0.161 -1.150 0.251 413
CMW -0.191 0.144 -1.324 0.186 554
HMS -0.199 0.188 -1.059 0.290 516
SBL -0.208 0.138 -1.504 0.133 603
POB -0.209 0.100 -2.102 0.036 433
VTE -0.210 0.309 -0.680 0.497 267
EVS -0.211 0.446 -0.473 0.636 218
SJG -0.211 0.236 -0.893 0.373 340
VIW -0.214 0.228 -0.936 0.350 364
TTL -0.215 0.150 -1.427 0.154 355
TMG -0.218 0.198 -1.098 0.273 597
BTV -0.219 0.199 -1.098 0.273 579
CEN -0.248 0.543 -0.456 0.649 259
DFC -0.255 0.172 -1.484 0.138 610
GND -0.259 0.238 -1.087 0.277 587
BTN -0.260 0.264 -0.985 0.325 364
DNA -0.276 0.272 -1.016 0.310 419
BMF -0.282 0.205 -1.377 0.170 300
FOC -0.316 0.635 -0.497 0.620 134
FIC -0.326 0.439 -0.743 0.459 225
VIH -0.353 0.240 -1.467 0.143 544
STW -0.364 0.238 -1.530 0.127 244
SBD -0.407 0.185 -2.208 0.028 590
TUG -0.416 0.215 -1.934 0.054 587
VSE -0.435 0.360 -1.207 0.229 177
EME -0.439 0.316 -1.389 0.166 456
DCI -0.460 0.274 -1.677 0.094 576
SZC -0.491 0.639 -0.768 0.444 110
BMS -0.661 0.497 -1.330 0.185 221
TID -1.307 0.676 -1.932 0.055 132
FHS -1.427 0.805 -1.772 0.078 161
PDT -1.436 0.642 -2.237 0.027 146

Thông thường căn cứ vào giá trị và cả dấu của beta chúng ta có thể xếp loại các công ti thành các nhóm:

type n
0 < Beta <= 1 263
Beta < 0 161
Beta > 1 9

Chẳng hạn kết quả trên chỉ ra rằng có 9 công ti có lợi tức biến động cùng chiều với lợi tức thị trường và mức độ nhạy cảm với các biến cố của thị trường là rất lớn. Danh sách các công ti này:

ticker beta std.error statistic p.value N
VPB 1.530 0.097 15.780 0.000 463
PLX 1.474 0.067 22.104 0.000 545
VRE 1.277 0.082 15.534 0.000 407
VCI 1.163 0.096 12.058 0.000 492
HVN 1.126 0.103 10.982 0.000 610
HDB 1.070 0.072 14.967 0.000 364
BSR 1.013 0.096 10.586 0.000 332
VGI 1.009 0.285 3.544 0.000 188
VTK 1.007 0.784 1.284 0.201 128

Author: Nguyen Chi Dung

LS0tDQp0aXRsZTogIlBvcnRmb2xpbyBUaGVvcnk6IEVzdGltYXRlIEJldGEgZm9yIEFsbCBDb21wYW5pZXMgTGlzdGVkIG9uIEhvIENoaSBNaW5oIFN0b2NrIEV4Y2hhbmdlIChIT1NFKSINCmF1dGhvcjogIkF1dGhvcjogTmd1eWVuIENoaSBEdW5nIg0Kc3VidGl0bGU6ICJSIGZvciBQbGVhc3VyZSINCg0Kb3V0cHV0Og0KICBybWRmb3JtYXRzOjpyZWFkdGhlZG93bjoNCiAgICBoaWdobGlnaHQ6IGthdGUNCiAgICBjb2RlX2ZvbGRpbmc6IGhpZGUNCiAgICBjb2RlX2Rvd25sb2FkOiB5ZXMNCi0tLQ0KDQoNCmBgYHtyIGtuaXRyX2luaXQsIGVjaG89R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