I am trying to produce a cluster outliers as in the figure below to investigate that situation in more depths.
I tried but with nothing, because the figure has one dependent and independent variable. I want the same situation but with more than one independent variables. So, it will be one dependent variable and a matrix of independent variables.
My attempt R-Code was as below
n=50
p=2
x <- matrix(rnorm(n*p),ncol = p)
y <- rnorm(n)
b=quantile(x,probs = 0.95)
id=which(x>b)
no=length(id)
x[id]=rnorm(no,5,0.5)
y[id]=rnorm(1)+10
UPDATE
I try the following code but still is not the same as shown in the figure
xa=rnorm(50)
xb=runif(50,min = 0,max=400)
x=rbind(xa,xb)
y=rnorm(100)
plot(x,y)
