Publications by Rui Fan
Lab 3: Statistics
In this lab exercise, you will learn: How to select a subset of data subset How to compute confidence intervals using R qnorm, qt, qf t.test How to conduct a statistical test using R pnorm, pt, pf t.test The data set used for this exercise is CPS96_15 from E3.1 of Stock and Watson (2020, e4). This data contains 13,201 observations on full-ti...
5681 sym R (4624 sym/64 pcs)
Lab 2: Probabilities (homework solutions)
Suppose you collect data from a sample of \(n\) people. You use random sampling, so your data are independent and identically distributed (i.i.d.). You collect data on one variable, \(y\), so \(y_i\) is the value of \(y\) for person \(i\) in your sample, and \(\bar{y}\) is the sample mean. The true mean of \(y\) in the population is \(\mu_y\) and t...
7876 sym 4 img
Lab 2: Probabilities (exercise_with_solutions)
Objective Explore the properties of the sample average using a simulated dataset from a non-normal distribution. Instructions Generate a simulated dataset: Generate a simulated dataset with 100 observations from a non-normal distribution (e.g., use the rgamma or rpois function). set.seed(123) simulated_data <- rgamma(100, shape = 2, rate = 1) C...
1404 sym 1 img
Lab 2: Probabilities (exercise)
Objective Explore the properties of the sample average using a simulated dataset from a non-normal distribution. Instructions Generate a simulated dataset with 100 observations from a non-normal distribution (e.g., use the rgamma or rpois function). set.seed(123) n <- 100 simulated_data <- rgamma(n, shape = 2, rate = 1) Calculate the sample ave...
770 sym
Publish Document
In this lab exercise, you will learn how to: Clear all objects from the workspace: rm(list=ls()) Generate random variables from different distributions. Use the set.seed() function to ensure all results are reproducible. Normal distribution: rnorm Student t distribution: rt Uniform distribution: runif Obtain summary statistics: summary(). Plot ...
7453 sym R (5767 sym/41 pcs) 6 img
Lab 1: A Brief Introduction to R
0. Useful online resources for beginners How to Install R and RStudio R for Data Science Data Analysis and Visualization in R for Ecologists The Undergraduate Guide to R An Introduction to R 1. What is R? What is RStudio? The term “R” is used to refer to both the programming language and the software that interprets the scripts written using ...
12114 sym R (6280 sym/62 pcs) 3 img
Lab_Ch2_sol
Suppose you collect data from a sample of \(n\) people. You use random sampling, so your data are independent and identically distributed (i.i.d.). You collect data on one variable, \(y\), so \(y_i\) is the value of \(y\) for person \(i\) in your sample, and \(\bar{y}\) is the sample mean. The true mean of \(y\) in the population is \(\mu_y\) and...
7878 sym 4 img
Data Analytics_HW1
Q1. [Meyer, Viscusi, and Durbin (1995) (hereafter, MVD) - Effect of Worker Compensation Laws on Weeks out of Work] In this question, we will review the difference-in-differences (hereafter, DID) method, which is a useful method for evaluating the impact of a certain event or policy. The data used in DID does not have to be a panel data. In this e...
18118 sym R (16539 sym/36 pcs) 6 tbl
Econometrics Lab: Chapter 11
In this lab exercise, you will use command glm to run regressions for the probit model and the logit model. Linear Probability Model model <- y~x # regression model fit.lpm <- lm(model, data) # OLS regression coeftest(fit.lpm, vcov=vcovHC, type="HC1") #use heteroskedasticity robust SE Probit Model model <- y~x # regress...
7047 sym R (16232 sym/58 pcs)
Econometrics Lab: Chapter 10
In this lab exercise, you will use command plm from R package plm for panel data analysis. Individual fixed effects only model <- y~x # regression model fit <- plm(model, data, index, effect="individual", model="within") # fixed effects regression coeftest(fit, vcovHC(fit, cluster="group", type="HC0")) # results with clustered standa...
8852 sym R (12064 sym/57 pcs) 2 img