Publications by Arvind Sharma

R Markdown Basics

10.07.2023

Can replace ‘html_document’ with ‘pdf_document’ in the .Rmd (Rmarkdown) file above manually to generate the output in your preferred format. However, I would strongly suggest using HTML format initially as the setup is likely to reduce math symbol issues if you do not have Latex installed locally. Also, make sure to change the settings of t...

3032 sym 1 img

OLS: From Scratch using Matrix Algebra in R

10.07.2023

1 Introduction One of the very first learning algorithms that you’ll encounter when studying data science and machine learning is least squares linear regression. Linear regression is one of the easiest learning algorithms to understand; it’s suitable for a wide array of problems, and is already implemented in many programming languages. Most u...

5225 sym R (15261 sym/30 pcs) 3 img

Preview: Running a regression and residual analysis in R

05.07.2023

1 Setting Up Working directory, clearing all data and memory # Clear the workspace rm(list = ls()) # Clear environment gc() # Clear unused memory ## used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) ## Ncells 526249 28.2 1168927 62.5 NA 669282 35.8 ## Vcells 967551 7.4 8388608 64.0 32768 1840394 14.1 cat(...

757 sym R (5859 sym/39 pcs) 6 img

Bankruptcy_Paper_Miniator_CrossCheck

01.07.2023

Correlation Function # Clear the environment by removing all objects from memory remove(list = ls()) # Define a function for computing correlations and creating a correlation plot corfunction <- function(d) { # Compute the correlation matrix mycorr <- cor(d[, 1:ncol(d)]) # Compute the p-values for correlations p.mat <- ggcorrplot::cor_pma...

11676 sym R (46161 sym/107 pcs) 5 img

WLS

01.05.2023

1 INTRO Weighted least squares (WLS) is a method of fitting a linear regression model where the errors are not homoscedastic (i.e., they have unequal variances). In WLS, the model is fitted by minimizing the weighted sum of squared residuals, where each residual is multiplied by a weight that is proportional to the inverse of the variance of the co...

3575 sym R (6170 sym/38 pcs) 4 img

HW2_solution

27.04.2023

1 Setup 1.1 Empty variables and functions in the environment tab/window First, empty the environment so that we can uplaod the clean data. # Clear the workspace rm(list = ls()) # Clear environment-remove all files from your workspace gc() # Clear unused memory ## used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) ## Ncells ...

14471 sym R (65124 sym/72 pcs) 18 img

IV_JEC_example

27.04.2023

1 Import Data Raw Data from https://github.com/R-Avalos/JEC remove(list=ls()) library(readxl) ?read_excel JEC_data <- read_excel("~/Library/CloudStorage/Dropbox/WCAS/Econometrics/share/shared/W6/JEC_data.xlsx") library("psych") describe(JEC_data) ## vars n mean sd median trimmed mad min max ## week* 1 32...

6039 sym R (22663 sym/42 pcs) 4 img 1 tbl

Count_Regressions_Implementation

24.04.2023

1 Data We use the data set "warpbreaks". This data set gives the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn. remove(list=ls()) ?warpbreaks df <- warpbreaks print(head(df)) ## breaks wool tension ## 1 26 A L ## 2 30 A L ## 3 54 A L ## 4 25 A L ## 5 70 ...

3307 sym R (5115 sym/21 pcs) 3 img

QTM

23.04.2023

1 Quantity Theory Equation We want to test whether quantity theory of money holds or not. M * V = P * T where M is money supply: https://fred.stlouisfed.org/series/WM2NS V is velocity of money: https://fred.stlouisfed.org/series/M2V P is price level: https://fred.stlouisfed.org/series/CPIAUCSL#0 T is transactions: https://fred.stlouisfed.org/serie...

4844 sym R (6088 sym/28 pcs) 6 img

Lasso_Ridge

20.04.2023

1 SetUp # Clear the workspace rm(list = ls()) # Clear environment - remove all files from your workspace gc() # Clear unused memory ## used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) ## Ncells 524036 28.0 1162601 62.1 NA 669288 35.8 ## Vcells 964993 7.4 8388608 64.0 32768 1840228 14.1 cat("\f") ...

67 sym R (7566 sym/30 pcs) 1 img