12 Lecture 5: The Simple Regression Model II
Slides
- 5 The Simple Regression Model (link)
12.1 Introduction
We continue studying the simple regression model.
Figure 12.1: Slides for 4 The Simple Regression Model II.
12.2 Vignette 5.1
Let’s create some data:
## This is my population regression:
df <- tibble(x=rnorm(1000000)) %>%
mutate(y = 1 + 2*x + rnorm(1000000))
df %>%
ggplot(aes(x=x,y=y)) +
geom_point(color="royalblue3",alpha = .05) +
theme_minimal() 
##
## Call:
## lm(formula = y ~ x, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.6014 -0.6730 0.0006 0.6733 5.0313
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.9980409 0.0009995 998.5
## x 2.0003711 0.0009996 2001.1
## Pr(>|t|)
## (Intercept) <2e-16 ***
## x <2e-16 ***
## ---
## Signif. codes:
## 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9995 on 999998 degrees of freedom
## Multiple R-squared: 0.8002, Adjusted R-squared: 0.8002
## F-statistic: 4.004e+06 on 1 and 999998 DF, p-value: < 2.2e-16
12.2.1 Theorem SLR.1: Unbiasedness of OLS:
Let’s say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 1000
beta_coefs <- NULL
for(i in 1:n_samples){
df_sample <- df %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs <- cbind(beta_coefs,coef(model_sam)[2])
}## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
## slice_sample: removed 999,000 rows (>99%), 1,000 rows remaining
Let’s see the mean of these betas:
mean(beta_coefs)## [1] 2.00359
hist(beta_coefs)
12.3 Vignette 5.2
12.3.1 a. Increased variation in \(\mu\)
## This is my population regression a:
df_a <- tibble(x=rnorm(100000)) %>%
mutate(y = 1 + 2*x + rnorm(100000,sd=1))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 1000
beta_coefs_a <- NULL
for(i in 1:n_samples){
df_sample <- df_a %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_a <- rbind.data.frame(beta_coefs_a,coef(model_sam)[2])
}## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
colnames(beta_coefs_a) <- "betas"
beta_coefs_a$model <- "df_a"
## This is my population regression b:
df_b <- tibble(x=rnorm(100000)) %>%
mutate(y = 1 + 2*x + rnorm(100000,sd=5))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 1000
beta_coefs_b <- NULL
for(i in 1:n_samples){
df_sample <- df_b %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_b <- rbind.data.frame(beta_coefs_b,coef(model_sam)[2])
}## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
colnames(beta_coefs_b) <- "betas"
beta_coefs_b$model <- "df_b"
## Now we compare:
beta_coefs_comp <- rbind.data.frame(beta_coefs_a,beta_coefs_b)
beta_coefs_comp %>%
group_by(model) %>%
mutate(mean_beta=mean(betas)) %>%
ungroup() %>%
ggplot(aes(x=betas,fill=model,color=model)) +
geom_density(alpha=0.5) +
geom_vline(aes(xintercept=mean_beta,color=model),linetype="dashed") +
theme_minimal() ## ungroup: no grouping variables remain

12.3.2 b. Increased variation in x is good:
## This is my population regression a:
df_a <- tibble(x=rnorm(100000,sd=1)) %>%
mutate(y = 1 + 2*x + rnorm(100000))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 1000
beta_coefs_a <- NULL
for(i in 1:n_samples){
df_sample <- df_a %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_a <- rbind.data.frame(beta_coefs_a,coef(model_sam)[2])
}## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
colnames(beta_coefs_a) <- "betas"
beta_coefs_a$model <- "df_a"
## This is my population regression b:
df_b <- tibble(x=rnorm(100000,sd=5)) %>%
mutate(y = 1 + 2*x + rnorm(100000))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 1000
beta_coefs_b <- NULL
for(i in 1:n_samples){
df_sample <- df_b %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_b <- rbind.data.frame(beta_coefs_b,coef(model_sam)[2])
}## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
## slice_sample: removed 99,000 rows (99%), 1,000 rows remaining
colnames(beta_coefs_b) <- "betas"
beta_coefs_b$model <- "df_b"
## Now we compare:
beta_coefs_comp <- rbind.data.frame(beta_coefs_a,beta_coefs_b)
beta_coefs_comp %>%
group_by(model) %>%
mutate(mean_beta=mean(betas)) %>%
ungroup() %>%
ggplot(aes(x=betas,fill=model,color=model)) +
geom_density(alpha=0.5) +
geom_vline(aes(xintercept=mean_beta,color=model),linetype="dashed") +
theme_minimal() ## ungroup: no grouping variables remain

12.3.3 c. Increased sample size is good:
## This is my population regression a:
df_a <- tibble(x=rnorm(100000)) %>%
mutate(y = 1 + 2*x + rnorm(100000))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 20
beta_coefs_a <- NULL
for(i in 1:n_samples){
df_sample <- df_a %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_a <- rbind.data.frame(beta_coefs_a,coef(model_sam)[2])
}## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
## slice_sample: removed 99,980 rows (>99%), 20 rows remaining
colnames(beta_coefs_a) <- "betas"
beta_coefs_a$model <- "df_a"
## This is my population regression b:
df_b <- tibble(x=rnorm(100000)) %>%
mutate(y = 1 + 2*x + rnorm(100000))
### Let's say that I take n RANDOM samples of size N from the population:
n_samples <- 200
N_size <- 2000
beta_coefs_b <- NULL
for(i in 1:n_samples){
df_sample <- df_b %>%
slice_sample(n=N_size)
model_sam <- lm(y~x,data = df_sample)
beta_coefs_b <- rbind.data.frame(beta_coefs_b,coef(model_sam)[2])
}## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
## slice_sample: removed 98,000 rows (98%), 2,000 rows remaining
colnames(beta_coefs_b) <- "betas"
beta_coefs_b$model <- "df_b"
## Now we compare:
beta_coefs_comp <- rbind.data.frame(beta_coefs_a,beta_coefs_b)
beta_coefs_comp %>%
group_by(model) %>%
mutate(mean_beta=mean(betas)) %>%
ungroup() %>%
ggplot(aes(x=betas,fill=model,color=model)) +
geom_density(alpha=0.5) +
geom_vline(aes(xintercept=mean_beta,color=model),linetype="dashed") +
theme_minimal() ## ungroup: no grouping variables remain

### NOTE: beta is unbiased!!