Last active
October 25, 2024 16:43
-
-
Save g-leech/224b0e81ad8c0f23ef5a337c35491693 to your computer and use it in GitHub Desktop.
now with endogeneity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(matlib) | |
gamma <- 2 | |
rho11 <- 1.15 | |
rho22 <- 0.05 | |
mu1 <- 0.3 | |
r <- 0.05 | |
delta <- 0.05 | |
x <- rnorm(1000000) | |
y <- rnorm(1000000) + 0.5*(mu1*(200/110000)/0.022)*x | |
mu2 <- 0.1 + 0.2*(mu1*(200/110000)/0.022) | |
rho21 <- sqrt(cov(x,y)) | |
rho12 <- rho21 | |
rho21 | |
rho11 * rho22 - rho21^2 | |
omega <- matrix(data = c(rho11, rho21, rho12, rho22), nrow = 2, ncol = 2) | |
nretn <- c(mu1 - r, mu2 -r) | |
as.numeric((delta/gamma) - (1-gamma)*((r/gamma) + ((nretn %*% inv(omega) %*% nretn)/(2*(gamma^2))))) #consumption | |
c((1/gamma) * inv(matrix(data = c(rho11, rho21, rho12, rho22), nrow = 2, ncol = 2)) %*% c(mu1 - r, mu2 -r), 1-sum((1/gamma) * inv(matrix(data = c(rho11, rho21, rho12, rho22), nrow = 2, ncol = 2)) %*% c(mu1 - r, mu2 -r))) #allocation, AI vs non-AI stock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment