4
I made graph 1 below in R, from the code:
library(truncreg)
set.seed(1)
x <- sort(rnorm(50)+3)
y <- 3 + 1*x + rnorm(50,0,0.3)
compl <- data.frame(x,y)
y[y>6.5] <- 6.5
sample <- data.frame(x,y)
pred.OLS <- predict( lm(y~x, data=sample) )
pred.trunc <- predict( truncreg(y~x, data=compl,point = 12.04,direction = "right"))
plot( compl$x, compl$y, pch= 1,xlab="x",ylab="y",ylim=NULL,xlim=NULL)
points(sample$x,sample$y, pch=16)
lines( sample$x,pred.OLS, lty=2,lwd=2)
lines( compl$x,pred.trunc,lty=1,lwd=2)
abline(h=6.5,lty=3) # horizontal line at 0
abline(v=3.5,lty=3)
However, my wish is to make this chart:
Does anyone know how I can proceed? I have not found how to remove the numerical values from the axes nor how to add the intercepts $k$ e $x_{0}.$
If you have suggestions on how to do with ggplot, I am even more grateful!