# Chapter 4 Dissertation: Difference-In-Difference Regression

My issue is solved *** Ty for the assistance.
My chapter 4 is private and has been approved by my SME, but my chair has yet to approve it. All of the linear and multiple regressions are completed, except the diff-in-diff regression. I can share more information privately as needed but here is the general overview: I am looking at COVID and how it has affected the federal funds rate and stock indices. I am not using a canonical form of DID, but rather a DID comparing dummy variable 0 no COVID present and 1 COVID present. I suppose to actually take my differences between treated and control I can compare two different states or countries, but my chair has been vague up until now. I can send or Attach excel spreadsheets; I tried R code from various diff-in-diff in R tutorials and manuals but have been unable to make it work for my purposes; I can make it work for the demos and tutorials but not my dataset.

I realize this is vague and I am not trying to be difficult, but if an experienced diff-in-diff regression practitiner can contact me, I would appreciate it. Paid tutoring sites were not helpful; I am close to completign my dissertation.

Here is some code I tried wit error messages:
model_simple <- lm(DJ Change ~ Dff, + after_12/1/2019 +
Error: unexpected symbol in "model_simple <- lm(DJ Change"

model_simple <- lm(DJ_Change ~ Dff, + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data = UNRATE)

data = model_simple
data = UNRATE.csv)
Error: unexpected ')' in "data = UNRATE.csv)"
data = "UNRATE.csv")
Error: unexpected ')' in "data = "UNRATE.csv")"
model_simple <- lm(DJ Change ~ Dff, + after_12/1/2019 +
Error: unexpected symbol in "model_simple <- lm(DJ Change"
model_simple <- lm(DJ_Change ~ Dff, + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data = mydata)

model_simple <- lm(DJ_Change ~ Dff, + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data = model_simple)

data = df
df
function (x, df1, df2, ncp, log = FALSE)
{
if (missing(ncp))
.Call(C_df, x, df1, df2, log)
else .Call(C_dnf, x, df1, df2, ncp, log)
}
<bytecode: 0x000001f5bba66f48>
<environment: namespace:stats>

Here are two links I am working from:

1 Like

thanks for offering to help me.

1 Like

You have a comma after dif where it doesn’t belong and the after variable isn’t a legal R variable name.

1 Like

Startz, ty for point that out now I have this:
model_simple <- lm(DJ_Change ~ Dff + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data = UNRATE)
Error in terms.formula(formula, data = data) :
invalid model formula in ExtractVars

I don’t think you can have slashes in a variable name.

Here are other attempts I made:

Model1 <-lm(DJ_Change ~ Dff + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data=MODEL1)

UNRATE <-lm(DJ_Change ~ Dff + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data=UNRATE)

MODEL1 <- lm(DJ_Change ~ Dff + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data=MODEL1)

didreg = lm(DJ.Change ~ DFF + after_12/1/2019 +

• (DFF * after_12/1/2019),
• data=didreg)

I tried adapting this as well:

Check whether in the notes the variable name is in quotes.

2 Likes