Describing the problem - Linear Example

Let’s now subset the values that fit in same groups for \(X^1\) and \(X^2\).

same_group_df <- 
  data.frame(x1,x2,ex,yx,x1c,x2c) |>
  subset(x1c==x2c)

Now if we calculate the mean we have many missing values.

same_group_y_mean_matrix <-
  with(same_group_df,
       tapply(yx, list(x1c,x2c), mean)) |>
  round(digits = 2)

same_group_y_mean_matrix
##           (0,0.2] (0.2,0.4] (0.4,0.6] (0.6,0.8] (0.8,1]
## (0,0.2]      0.19        NA        NA        NA      NA
## (0.2,0.4]      NA      0.59        NA        NA      NA
## (0.4,0.6]      NA        NA      0.98        NA      NA
## (0.6,0.8]      NA        NA        NA       1.4      NA
## (0.8,1]        NA        NA        NA        NA    1.77