yield_data.csv "Index" "ZC025YR" "ZC050YR" "ZC075YR" "ZC100YR" "ZC125YR" "ZC150YR" "ZC175YR" "ZC200YR" "ZC225YR" "ZC250YR" "ZC275YR" "ZC300YR" "ZC325YR" "ZC350YR" "ZC375YR" "ZC400YR" "ZC425YR"...

1 answer below »
I will attach the data files needed after you evaluate


yield_data.csv "Index" "ZC025YR" "ZC050YR" "ZC075YR" "ZC100YR" "ZC125YR" "ZC150YR" "ZC175YR" "ZC200YR" "ZC225YR" "ZC250YR" "ZC275YR" "ZC300YR" "ZC325YR" "ZC350YR" "ZC375YR" "ZC400YR" "ZC425YR" "ZC450YR" "ZC475YR" "ZC500YR" "ZC525YR" "ZC550YR" "ZC575YR" "ZC600YR" "ZC625YR" "ZC650YR" "ZC675YR" "ZC700YR" "ZC725YR" "ZC750YR" "ZC775YR" "ZC800YR" "ZC825YR" "ZC850YR" "ZC875YR" "ZC900YR" "ZC925YR" "ZC950YR" "ZC975YR" "ZC1000YR" "ZC1025YR" "ZC1050YR" "ZC1075YR" "ZC1100YR" "ZC1125YR" "ZC1150YR" "ZC1175YR" "ZC1200YR" "ZC1225YR" "ZC1250YR" "ZC1275YR" "ZC1300YR" "ZC1325YR" "ZC1350YR" "ZC1375YR" "ZC1400YR" "ZC1425YR" "ZC1450YR" "ZC1475YR" "ZC1500YR" "ZC1525YR" "ZC1550YR" "ZC1575YR" "ZC1600YR" "ZC1625YR" "ZC1650YR" "ZC1675YR" "ZC1700YR" "ZC1725YR" "ZC1750YR" "ZC1775YR" "ZC1800YR" "ZC1825YR" "ZC1850YR" "ZC1875YR" "ZC1900YR" "ZC1925YR" "ZC1950YR" "ZC1975YR" "ZC2000YR" "ZC2025YR" "ZC2050YR" "ZC2075YR" "ZC2100YR" "ZC2125YR" "ZC2150YR" "ZC2175YR" "ZC2200YR" "ZC2225YR" "ZC2250YR" "ZC2275YR" "ZC2300YR" "ZC2325YR" "ZC2350YR" "ZC2375YR" "ZC2400YR" "ZC2425YR" "ZC2450YR" "ZC2475YR" "ZC2500YR" "ZC2525YR" "ZC2550YR" "ZC2575YR" "ZC2600YR" "ZC2625YR" "ZC2650YR" "ZC2675YR" "ZC2700YR" "ZC2725YR" "ZC2750YR" "ZC2775YR" "ZC2800YR" "ZC2825YR" "ZC2850YR" "ZC2875YR" "ZC2900YR" "ZC2925YR" "ZC2950YR" "ZC2975YR" "ZC3000YR" "2002-01-04" 0.019964852 0.019731308 0.020921567 0.023015448 0.025535785 0.02816865 0.030726748 0.03310981 0.035274357 0.037212194 0.038935568 0.040467175 0.041833635 0.043061432 0.044174574 0.04519343 0.046134354 0.047009801 0.047828741 0.048597209 0.049318921 0.049995856 0.050628807 0.051217848 0.051762721 0.052263148 0.052719063 0.053130768 0.053499039 0.053825169 0.054110979 0.054358786 0.054571351 0.054751806 0.054903575 0.055030284 0.055135673 0.055223514 0.055297526 0.055361312 0.055418292 0.055471657 0.055524329 0.055578929 0.05563776 0.055702794 0.055775671 0.055857701 0.055949874 0.056052875 0.056167097 0.056292667 0.056429462 0.056577137 0.056735145 0.056902762 0.057079111 0.05726318 0.057453853 0.05764992 0.057850105 0.058053082 0.058257489 0.05846195 0.058665086 0.058865529 0.059061938 0.059253005 0.059437471 0.059614133 0.059781852 0.059939561 0.060086271 0.06022108 0.060343172 0.060451823 0.060546407 0.060626394 0.06069135 0.060740943 0.060774937 0.060793191 0.06079566 0.06078239 0.060753512 0.060709244 0.060649879 0.060575786 0.0604874 0.060385219 0.060269795 0.060141729 0.060001668 0.059850291 0.059688309 0.059516458 0.059335487 0.059146162 0.058949251 0.058745526 0.058535753 0.05832069 0.058101084 0.057877663 0.057651139 0.0574222 0.05719151 0.056959706 0.056727398 0.056495165 0.056263557 0.056033092 0.055804257 0.055577508 0.055353269 0.055131933 0.054913862 0.05469939 0.054488819 0.054282425 "2002-01-11" 0.018970601 0.018167687 0.018324854 0.01964877 0.021664826 0.023991853 0.026382074 0.028690835 0.030844084 0.032813071 0.034596288 0.03620713 0.037665771 0.038994065 0.040212545 0.041338877 0.042387253 0.043368387 0.044289865 0.045156657 0.045971714 0.046736534 0.047451688 0.048117266 0.048733236 0.049299722 0.049817198 0.050286613 0.050709456 0.051087766 0.051424111 0.051721526 0.051983438 0.052213573 0.052415864 0.052594346 0.05275307 0.052896012 0.053027001 0.053149648 0.0532673 0.053382993 0.053499429 0.053618953 0.053743544 0.05387482 0.05401404 0.05416212 0.05431965 0.054486916 0.054663921 0.054850418 0.055045927 0.055249771 0.055461096 0.0556789 0.055902059 0.05612935 0.056359473 0.056591074 0.056822763 0.057053137 0.057280789 0.057504334 0.057722414 0.057933718 0.058136987 0.05833103 0.058514731 0.058687056 0.058847059 0.058993891 0.059126801 0.059245139 0.059348362 0.05943603 0.059507811 0.059563475 0.059602897 0.059626051 0.05963301 0.059623937 0.059599084 0.059558785 0.059503451 0.059433563 0.059349664 0.059252354 0.059142285 0.059020147 0.05888667 0.058742608 0.058588741 0.05842586 0.058254768 0.05807627 0.05789117 0.057700263 0.057504334 0.05730415 0.057100461 0.056893994 0.056685448 0.056475496 0.056264783 0.056053919 0.055843487 0.055634033 0.05542607 0.05522008 0.055016508 0.05481577 0.054618246 0.054424285 0.054234207 0.054048299 0.05386682 0.053690002 0.05351805 0.053351144 "2002-01-18" 0.020123181 0.019874017 0.020694907 0.022373132 0.024507788 0.026811718 0.029105403 0.031287283 0.033308023 0.03515143 0.036821036 0.038330972 0.039699965 0.040947566 0.042091936 0.043148706 0.044130544 0.04504718 0.045905691 0.046710927 0.047465988 0.048172696 0.048832023 0.049444468 0.050010359 0.050530094 0.051004315 0.051434025 0.051820651 0.052166069 0.052472591 0.052742928 0.052980135 0.053187535 0.053368645 0.053527095 0.053666553 0.053790645 0.053902891 0.054006648 0.05410506 0.054201017 0.054297125 0.054395688 0.054498695 0.054607812 0.054724388 0.054849459 0.054983765 0.055127759 0.055281631 0.055445327 0.05561857 0.055800881 0.055991606 0.056189934 0.056394923 0.056605519 0.056820575 0.057038876 0.05725915 0.057480093 0.057700378 0.057918675 0.058133663 0.058344042 0.058548546 0.058745953 0.058935095 0.059114865 0.059284227 0.05944222 0.059587966 0.059720674 0.059839641 0.059944261 0.060034022 0.060108506 0.060167394 0.060210465 0.060237589 0.06024873 0.060243945 0.060223372 0.060187235 0.060135835 0.060069545 0.059988805 0.059894116 0.059786033 0.059665163 0.059532152 0.059387684 0.05923247 0.059067248 0.058892772 0.058709805 0.058519121 0.058321492 0.058117685 0.057908462 0.057694571 0.057476742 0.05725569 0.057032105 0.056806654 0.056579976 0.056352684 0.05612536 0.055898557 0.055672796 0.055448566 0.055226328 0.055006506 0.054789499 0.054575671 0.054365359 0.054158867 0.053956476 0.053758436 "2002-01-25" 0.020382735 0.021211454 0.022648762 0.024678002 0.027010092 0.029425129 0.031783073 0.034004412 0.036051171 0.037912228 0.039592736 0.041106786 0.042472482 0.043708769 0.044833517 0.045862485 0.04680887 0.047683262 0.048493826 0.049246629 0.049946016 0.050595012 0.051195683 0.051749479 0.052257505 0.052720755 0.053140288 0.053517351 0.053853464 0.054150463 0.054410514 0.054636101 0.05482999 0.054995183 0.055134863 0.055252333 0.055350949 0.055434061 0.055504956 0.055566803 0.055622612 0.055675188 0.055727107 0.05578069 0.055837989 0.055900774 0.055970533 0.056048474 0.05613553 0.05623237 0.056339411 0.056456836 0.056584609 0.056722495 0.056870079 0.05702678 0.05719188 0.057364534 0.057543792 0.057728616 0.057917899 0.058110475 0.058305143 0.058500671 0.058695818 0.058889342 0.059080011 0.059266614 0.059447974 0.059622952 0.059790458 0.059949456 0.060098973 0.060238103 0.060366013 0.060481946 0.060585226 0.060675258 0.060751534 0.060813629 0.060861207 0.060894018 0.060911898 0.060914764 0.060902619 0.060875544 0.060833694 0.060777299 0.060706656 0.060622126 0.060524128 0.060413137 0.060289672 0.060154298 0.060007617 0.059850261 0.05968289 0.059506183 0.059320836 0.059127553 0.058927047 0.058720029 0.058507208 0.058289286 0.058066953 0.057840887 0.057611748 0.057380176 0.057146792 0.05691219 0.056676943 0.056441594 0.056206662 0.055972636 0.055739979 0.055509124 0.055280477 0.055054415 0.054831288 0.054611417 "2002-02-01" 0.02038237 0.021067079 0.022693406 0.024870066 0.02727339 0.029695197 0.032013819 0.034166464 0.036128505 0.037898796 0.03948956 0.040919589 0.042209833 0.043380675 0.044450391 0.045434416 0.046345146 0.047192078 0.047982141 0.048720129 0.049409158 0.050051113 0.050647049 0.051197545 0.051702984 0.05216379 0.052580585 0.052954311 0.053286299 0.053578293 0.053832452 0.054051319 0.054237772 0.054394965 0.054526261 0.054635151 0.054725192 0.054799928 0.054862832 0.054917244 0.054966325 0.055013015 0.05506 0.055109689 0.0551642 0.055225347 0.055294644 0.055373305 0.055462253 0.05556213 0.055673319 0.055795951 0.055929935 0.056074971 0.05623057 0.05639608 0.056570702 0.056753512 0.056943479 0.057139485 0.05734034 0.057544802 0.057751591 0.057959402 0.058166921 0.058372836 0.058575852 0.058774695 0.058968129 0.059154961 0.059334052 0.05950432 0.059664749 0.059814397 0.059952398 0.060077966 0.0601904 0.060289086 0.060373499 0.060443204 0.060497858 0.060537206 0.060561083 0.060569414 0.060562207 0.060539552 0.060501621 0.060448657 0.060380978 0.060298965 0.06020306 0.06009376 0.059971612 0.059837207 0.059691174 0.059534172 0.059366889 0.059190032 0.059004324 0.058810496 0.058609287 0.058401432 0.058187667 0.057968714 0.057745288 0.057518085 0.057287786 0.057055049 0.056820509 0.056584779 0.056348442 0.056112055 0.055876148 0.05564122 0.055407743 0.055176156 0.054946871 0.054720272 0.054496711 0.054276515 "2002-02-08" 0.020584144 0.021334894 0.022776148 0.024761026 0.027000312 0.029289374 0.031503346 0.033574779 0.035474319 0.03719643 0.038749397 0.040148583 0.04141203 0.042557755 0.043602199 0.044559483 0.045441175 0.046256387 0.047012058 0.047713326 0.048363924 0.048966562 0.049523271 0.050035693 0.050505313 0.050933639 0.051322327 0.051673257 0.051988579 0.052270717 0.052522348 0.052746372 0.052945859 0.05312399 0.053283998 0.053429108 0.053562477 0.053687146 0.053805986 0.053921666 0.054036621 0.054153026 0.054272782 0.054397508 0.054528539 0.054666925 0.054813444 0.05496861 0.055132688 0.055305712 0.055487502 0.055677685 0.055875715 0.05608089 0.056292379 0.056509234 0.056730417 0.056954812 0.057181245 0.057408501 0.057635339 0.057860507 0.058082755 0.058300846 0.058513572 0.058719759 0.058918279 0.05910806 0.059288091 0.059457429 0.059615208 0.059760638 0.059893014 0.060011719 0.06011622 0.060206081 0.06028095 0.060340571 0.060384775 0.060413482 0.060426699 0.060424514 0.060407098 0.060374693 0.060327616 0.060266248 0.060191032 0.060102465 0.060001094 0.059887512 0.059762346 0.059626258 0.059479934 0.059324081 0.059159423 0.058986689 0.058806617 0.058619943 0.058427396 0.058229701 0.058027568 0.05782169 0.057612745 0.057401387 0.057188249 0.056973937 0.056759031 0.056544084 0.05632962 0.056116133 0.055904088 0.055693922 0.05548604 0.055280818 0.055078606 0.054879723 0.054684461 0.054493086 0.054305838 0.054122934 "2002-02-15" 0.020690918 0.021455416 0.023097531 0.025242549 0.027578101 0.029906364 0.032114835 0.034148378 0.035988407 0.037638281 0.039113352 0.040434395 0.041623434 0.04270125 0.043686054 0.044592926 0.045433763 0.046217528 0.046950657 0.047637539 0.048281001 0.048882758 0.049443816 0.049964796 0.050446209 0.050888647 0.051292934 0.051660208 0.051991971 0.052290094 0.052556804 0.052794636 0.053006386 0.053195039 0.053363706 0.053515554 0.053653736 0.053781335 0.053901308 0.054016437 0.054129296 0.054242214 0.054357262 0.054476234 0.054600639 0.054731706 0.054870384 0.055017352 0.055173033 0.055337609 0.055511038 0.055693072 0.05588328 0.056081066 0.056285689 0.056496285 0.056711885 0.056931433 0.057153807 0.057377832 0.0576023 0.057825982 0.058047644 0.058266058 0.058480017 0.058688341 0.058889891 0.059083578 0.059268367 0.059443289 0.059607443 0.059760005 0.059900228 0.060027451 0.060141097 0.060240676 0.060325789 0.060396123 0.060451457 0.060491655 0.060516667 0.060526527 0.060521349 0.060501321 0.060466707 0.060417835 0.060355099 0.060278948 0.060189883 0.060088454 0.059975249 0.059850892 0.059716036 0.059571358 0.059417552 0.059255325 0.059085393 0.058908473 0.058725283 0.058536532 0.058342922 0.058145141 0.057943862 0.057739738 0.057533402 0.057325462 0.057116504 0.056907085 0.056697738 0.056488965 0.056281241 0.056075013 0.055870698 0.055668684 0.055469333 0.055272978 0.055079923 0.054890449 0.054704809 0.054523232 "2002-02-22" 0.020661498 0.021621495 0.023369238 0.025522236 0.027810168 0.030067347 0.032201321 0.034167939 0.035953522 0.037562523 0.039009192 0.040312098 0.041490672 0.042563156 0.043545522 0.044451037 0.04529024 0.046071168 0.046799717 0.04748005 0.048115017 0.048706537 0.049255935 0.049764225 0.050232335 0.050661269 0.051052227 0.051406681 0.051726401 0.052013468 0.052270248 0.052499357 0.052703608 0.052885959 0.053049448 0.053197132 0.053332033 0.053457082 0.053575075 0.05368863 0.053800157 0.053911832 0.054025581 0.054143069 0.054265693 0.054394587 0.054530622 0.05467442 0.054826366 0.054986618 0.055155129 0.055331663 0.055515813 0.05570702 0.055904591 0.056107721 0.056315507 0.056526966 0.056741056 0.056956685 0.057172731 0.057388054 0.057601506 0.057811949 0.058018262 0.058219351 0.058414157 0.058601669 0.058780925 0.058951025 0.059111129 0.059260469 0.059398348 0.059524146 0.059637321 0.059737411 0.059824037 0.059896898 0.059955776 0.060000533 0.06003111 0.060047522 0.060049858 0.060038279 0.06001301 0.059974339 0.059922613 0.059858232 0.059781644 0.059693339 0.059593849 0.059483736 0.059363592 0.05923403 0
Answered 2 days AfterJul 04, 2021

Answer To: yield_data.csv "Index" "ZC025YR" "ZC050YR" "ZC075YR" "ZC100YR" "ZC125YR" "ZC150YR" "ZC175YR"...

Neha answered on Jul 06 2021
150 Votes
Question 1
A) Yield Curve
library(cashflow)
library(holdings)
library(yield_data)
library(MSCI World Index Total Return CAD)
yield_curve <- list("DTB3", "DGS2", "DGS5", "DGS10", "DGS30") %>%
map(
~getSymbols(.x, auto.assign=FALSE, src="True")
) %>%
do.call(merge,.)
yield_curve["1980::"] %>%
data.matrix() %>%
t() %>%
plot_ly(
x=as.Date(index(yield_curve["1980::"])),
y=c(0.25,2,5,10,30),
z=.,
type="surface"
) %>%

plotly::layout(
scene=list(
xaxis=list(title="date"),
yaxis=list(title="term"),
zaxis=list(title="yield")
)
)
yield_curve_tidy <- yield_curve %>%
data.frame() %>%
add_rownames(var="date") %>%
gather(symbol,yield,-date) %>%
mutate(term=c(0.25,2,5,10,30)[match(symbol,colnames(yield_curve))])
yield_curve_tidy[which(!is.na(yield_curve_tidy$yield)),] %>%
group_by(symbol) %>%
plot_ly(
x = ~date, y = ~term, z = ~yield,
type="scatter3d",
mode="markers",
size=3,
color=~yield
)
Standard Deviation
const standardDeviation = values => {
const avg = arr => arr.reduce((acc, cur) => (acc + cur)) / arr.length

const mean = avg(values)
const squareDiffs = values.map(val => {
const diff = val - mean
const sqrDiff = diff * diff
return sqrDiff
})
const avgSquareDiff = avg(squareDiffs)
const stdDev = Math.sqrt(avgSquareDiff)
return stdDev
}
Variance Covariance
covariance = function(x, y)
mean(x*y) - mean(x) * mean(y)

true_variance = function(x)
covariance(x, x)
bootstrap = function(x, s=sample_size, it=iteration)
matrix(sample(x, s*it, replace=T), nrow=s, ncol=it)
confidence = .05
q = c(1 - confidence/2, confidence/2)
sample_size = 100
iteration = 1E3
x = rnorm(sample_size)
monte_carlo = matrix(rnorm(sample_size*iteration), nrow=sample_size, ncol=iteration)

plot(1:iteration, cumsum(variance(monte_carlo) - 1) / 1:iteration, type='l')
lines(1:iteration, cumsum(variance(bootstrap(x)) - true_variance(x)) / 1:iteration, type='l', col='green')
abline(h=-1/sample_size, col='red')
sample_size = 1E3
iteration = 1E3
x = rnorm(sample_size, mean=5, sd= sqrt(2))
bootstraped_mean = mean(x)
bootstraped_var = true_variance(x)
estimated_variance = function(matrix)
apply(matrix, 2, true_variance)

estimated_mean = function(matrix)
apply(matrix, 2, mean)
bx = bootstrap(x)

IC1 = bootstraped_mean + qt(q, df=sample_size -1) * sqrt(bootstraped_var/sample_size)
IC2 = bootstraped_mean + qnorm(q) * sqrt(bootstraped_var/sample_size)
IC3 = bootstraped_mean - quantile(estimated_mean(bx) - bootstraped_mean, probs=q)
IC4 = bootstraped_var - quantile(estimated_variance(bx) - bootstraped_var, probs=q)
sample_size = 30
iteration = 1E3
sigma_2 = .5
alpha = 2
beta = 1
deg_of_free = 5
x = seq(0, 10, length=sample_size)
e = rt(sample_size, df=deg_of_free) * sqrt(sigma_2 * (deg_of_free - 2) / deg_of_free)
y = alpha + beta * x + e
mx = mean(x)
my = mean(y)
Sxx = true_variance(x)
Syy = true_variance(y)
Sxy = covariance(x, y)
beta_hat = Sxy/Sxx
alpha_hat = my - beta_hat * mx
be = bootstrap(y - alpha_hat - beta_hat * x)
by = alpha_hat + beta_hat * x + be
#plot(x, alpha_hat + beta_hat * x + e)
#abline(alpha_hat, beta_hat)
#abline(alpha, beta, col='red')
estimated_covariance = estimated_mean(by * x) - estimated_mean(by) * mx
beta_star = estimated_covariance / Sxx
alpha_star = estimated_mean(by) - beta_star * mx
ICb = beta_hat - quantile(beta_star - beta_hat , probs=q)
ICa = alpha_hat - quantile(alpha_star - alpha_hat, probs=q)
R = y - alpha_hat - beta_hat * x
T = sqrt((sample_size - 2) * Sxx) * (beta_hat - 1) / sqrt(sum( R ^ 2 ))
R_star = bootstrap(R)
T_star = sqrt((sample_size - 2) * Sxx) * (beta_star - 1) / sqrt(sum( R_star ^ 2 ))
B) Eigen Value
The result of first data matrix is equivalent to the eigenvalue matrix. The importance is used to arrange the vectors. Those vectors which are arranged to be the important ones are then further observed.
After the most important vectors are found, the economic states of the vector can be found after getting the data point of the curves we can find out the real economic status of the vectors.
.
The high value and low level value are corresponding.
There can be seen steepness in the yield curve.
C) The principal components contribute to a major section towards risk. The percent is between >=65%.
D) Since, hedging always helps in contributing to mitigate risk till a certain level. The simple duration immunization constraint has been a help.
Question 2
A) Conditional VAR...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here