When you want to execute a difference-in-differences (DID) analysis with cluster-robust standard errors, you can install packages like estimatr and write R scripts within your note.
Select “Manage R Packages” from the project menu.
In the Manage R Packages dialog, enter “estimatr” in the package installation field and click install.
Next, click the plus button in the report and select “Create Note”.
Select “R Script” from the created note.
Copy and paste the following into the R script:
model <- estimatr::lm_robust(salary ~ job_level * total_working_years,
data = Employee,
clusters = job_role,
se_type = "CR2")
summary(model)
In the data parameter, specify the data frame name, and in the clusters parameter, specify the cluster variable.
The salary part is the dependent variable, while job_level and total_working_years are the explanatory variables.
By previewing, you can execute the difference-in-differences analysis with robust standard errors.