DD 방법 실습 :: 마케팅 효과 분석하기 - mindscale
Skip to content

DD 방법 실습

dat = read.csv('ddmethod.csv', header = T)
head(dat)

minfo = aggregate(dat$sales, list(dat$year, dat$adORnot == 1), mean)
names(minfo) = c("YR","Treatment","Average_sales")
minfo$Treatment[1:6] = "Control Group"
minfo$Treatment[7:12] = "Treatment Group"

library(ggplot2)

qplot(YR, Average_sales, data=minfo, geom=c("point","line"), colour=Treatment,
      xlab="Year", ylab="Average sales")

## linear regression for DD model
result = lm(sales ~ post93 + adORnot + post93*adORnot, data = dat)
summary(result)