Skip to content

Instantly share code, notes, and snippets.

@paulgp
Created February 8, 2019 01:34
Show Gist options
  • Save paulgp/86f67b10ed0e1e2063735999cfcef060 to your computer and use it in GitHub Desktop.
Save paulgp/86f67b10ed0e1e2063735999cfcef060 to your computer and use it in GitHub Desktop.
n <- 100
m <- 1000
coef <- rep(0,m)
coef2 <- rep(0,m)
beta <- 0
for (j in seq(1,m) ){
x <- rnorm(n, 0, 1)
y <- rnorm(n, x* beta, 1)
fit <- lm(y ~ x)
coef[j] <- fit$coefficients[1]
fit <- lm(sort(y) ~ sort(x))
coef2[j] <- fit$coefficients[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment