Created
January 6, 2021 17:20
-
-
Save lschwetlick/562366af0197205894beb80961b1dd94 to your computer and use it in GitHub Desktop.
How to generate a reciprobit plot (used in LATER models) in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We want to generate a reciprobit plot like it is used in the context of LATER models. | |
# Here, we generate normally distributed data. In the reciprobit plot that should appear linear | |
rm(list=ls()) | |
library(ggplot2) | |
N = 1000 | |
f = rnorm(N,mean=300,sd=50) | |
x = sort(1/f,decreasing=T) | |
y = (1:N)/N | |
d = data.frame(x=x,y=y) | |
l = seq(from=1,to=0.00,by=-0.001) | |
s = round(1/l) | |
p = ggplot(d,aes(x=x,y=y)) + | |
geom_point() + | |
geom_line() + | |
scale_x_continuous(trans="reciprocal",breaks=l,labels=s) + | |
scale_y_continuous(trans="probit") | |
print(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment