The simulation study approximates the covariance very well, with the simulated and analytic covariances lying within approximately 0.1 (depending on the simulation) of each other.
(ggplot(data = simstudy) +geom_point(aes(x = x, y = y), alpha =0.5, size =0.5)+geom_point(aes(x =5, y=5), col ='red')+facet_grid(rho~sigx+sigy, labeller = label_both)+theme_bw())
Warning in geom_point(aes(x = 5, y = 5), col = "red"): All aesthetics have length 1, but the data has 200000 rows.
ℹ Please consider using `annotate()` or provide this layer with data containing
a single row.
Question 7
N <-10000(simstudy_1 <-data.frame(x =rexp(N,1))%>%mutate(y = x +rexp(N,1))) %>% head
x y
1 0.1488812 0.3580922
2 0.8677757 1.1195775
3 0.2762563 1.9954143
4 0.8810833 2.2242157
5 0.5809241 1.2253704
6 0.1663885 1.8102942