การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R
Ross Bennett
Instructor
Solver หลายตัวไม่ได้ออกแบบมาเฉพาะสำหรับการปรับพอร์ตโฟลิโอ
ต้องเข้าใจความสามารถและข้อจำกัดของ solver เพื่อเลือกให้เหมาะกับปัญหา หรือกำหนดปัญหาให้สอดคล้องกับ solver
การเปลี่ยน solver ทำได้ยาก
Closed-Form solver (เช่น quadratic programming)
Global solver (เช่น differential evolution optimization)
$$\omega_{i} >= 0$$
$$\sum_{i=1}^{n} \omega_i = 1$$
ใช้แพ็กเกจ quadprog ใน R เพื่อแก้ปัญหา quadratic utility optimization
solve.QP() แก้ปัญหา quadratic programming ในรูปแบบ:
$$min(-d^Tb+\frac{1}{2}b^TDb)$$
$$A^Tb>=b_0$$
library(quadprog)
data(edhec)
dat <- edhec[,1:4]
# Create the constraint matrix
Amat <- cbind(1, diag(ncol(dat)), -diag(ncol(dat)))
# Create the constraint vector
bvec <- c(1, rep(0, ncol(dat)), -rep(1, ncol(dat)))
# Create the objective matrix
Dmat <- 10 * cov(dat)
# Create the objective vector
dvec <- colMeans(dat)
# Specify number of equality constraints
meq <- 1
# Solve the optimization problem
opt <- solve.QP(Dmat, dvec, Amat, bvec, meq)
การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R