Question: You can generate data from a bivariate normal distrubution using the MASS package using the following code: Sigma % set Names(c( x , y ))

You can generate data from a bivariate normal distrubution using the MASS package using the following code:

Sigma <- 9*matrix(c(1,0.5,0.5,1), 2, 2) dat <- MASS::mvrnorm(n = 10000, c(69, 69), Sigma) %>% data.frame() %>% setNames(c("x", "y")) 

And you can make a quick plot using plot(dat).

Using an approach similar to that used in the previous exercise, let's estimate the conditional expectations and make a plot. Part of the code has again been provided for you:

ps <- seq(0, 1, 0.1) dat %>% # MISSING CODE qplot(x, y, data =.) 

Which of the following blocks of code can be used to replace # MISSING CODE to make the correct plot?

mutate(g = cut(x, quantile(x, ps), include.lowest = TRUE)) %>% group_by(g) %>% summarize(y = mean(y), x = mean(x)) %>% mutate(g = cut(x, quantile(x, ps))) %>% group_by(g) %>% summarize(y = mean(y), x = mean(x)) %>% mutate(g = cut(x, quantile(x, ps), include.lowest = TRUE)) %>% summarize(y = mean(y), x = mean(x)) %>% mutate(g = cut(x, quantile(x, ps), include.lowest = TRUE)) %>% group_by(g) %>% summarize(y =(y), x =(x)) %>% 

What is the answer please and why!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!