library(tidyverse)
Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
── Attaching packages ─────────────────────────────────────────────── tidyverse 1.3.2 ──✔ ggplot2 3.4.0 ✔ purrr 1.0.0
✔ tibble 3.1.8 ✔ dplyr 1.0.10
✔ tidyr 1.2.1 ✔ stringr 1.5.0
✔ readr 2.1.3 ✔ forcats 0.5.2 ── Conflicts ────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
sim <- function(i){
x <- rnorm(250, 3, 1)
#hist(x)
y <- 3*x +20 + rnorm(250, sd = sqrt(2))
#plot(x,y)
res <- lm(y~x) %>% summary
return(res$coefficients[,1])
}
#sim(2)
result <- sapply(1:1000, sim)
rowMeans(result)
(Intercept) x
19.996917 3.001502
LS0tCnRpdGxlOiAiQ2xhc3MgMTEiCmF1dGhvcjogIklzYWFjIFF1aW50YW5pbGxhIFNhbGluYXMiCmRhdGU6ICJgciBmb3JtYXQoU3lzLnRpbWUoKSwnJW0tJWQtJVknKWAiCm91dHB1dDogCiAgaHRtbF9ub3RlYm9vazoKICAgIHRvYzogdHJ1ZQogICAgdG9jX2Zsb2F0OiB0cnVlCiAgICBjb2RlX2ZvbGRpbmc6IGhpZGUKLS0tCgpgYGB7cn0KbGlicmFyeSh0aWR5dmVyc2UpCnNpbSA8LSBmdW5jdGlvbihpKXsKeCA8LSBybm9ybSgyNTAsIDMsIDEpCiNoaXN0KHgpCnkgPC0gMyp4ICsyMCArIHJub3JtKDI1MCwgc2QgPSBzcXJ0KDIpKQojcGxvdCh4LHkpCiByZXMgPC0gbG0oeX54KSAlPiUgc3VtbWFyeQpyZXR1cm4ocmVzJGNvZWZmaWNpZW50c1ssMV0pCn0KI3NpbSgyKQpyZXN1bHQgPC0gc2FwcGx5KDE6MTAwMCwgc2ltKQpyb3dNZWFucyhyZXN1bHQpCmBgYAo=