I recently used R for a moderately complicated scraping task, and found that using tools and techniques from the tidyverse made for a very pleasant web scraping experience, especially for retrieving nested data. In particular, the nest/unnest functions in the tidyr package make it easy to implement breadth-first scrapers in R by nesting the results from each level and then expanding to a tabular structure. This approach has the advantage of making it easy to follow the program logic, and it also makes it very easy to store retrieved values in a convenient format.
A simulation for OLS model In an observational study, we need to assume we have the functional form to get causal effect estimated correctly, in addtion to the assumption of treatment being exogenous.
library(MASS) library(ggplot2) library(dplyr) library(tmle) library(glmnet) set.seed(366) nobs <- 2000 xw <- .8 xz <- .5 zw <- .6 nrow <- 3 ncol <- 3 covarMat = matrix( c(1^2, xz^2, xw^2, xz^2, 1^2, zw^2, xw^2, zw^2, 1^2 ) , nrow=ncol , ncol=ncol ) mu <- rep(0,3) rawvars <- mvrnorm(n=nobs, mu=mu, Sigma=covarMat) df <- tbl_df(rawvars) names(df) <- c('x','z','w') df <- df %>% mutate(log.