# delimit ;
* Code for estimating exercise 2: lingering effects model - estimation
and time aggregation bias issues.
Opening the database.;
use "C:\Users\AutoLogon\Desktop\palda.dta", clear;
* We create a .log file to register our results;
log using "C:\Users\AutoLogon\Desktop\exercise2.log", replace;
* First, we create the dummy variables;
generate dum1 = 0;
replace dum1=1 if year>=1908 & year <=1914;
generate dum2 = 0;
replace dum2=1 if year>=1915 & year <=1925;
generate dum3 = 0;
replace dum3=1 if year>=1926 & year <=1940;
* Now we can proceed with the estimation of the lingering effects model. But in order to use lagged values in the estimation model, we should inform Stata that our database have a time series structure;
tsset year ;
* We estimate the model first by ordinary least squares;
regress sales l.sales adver dum1 dum2 dum3;
* Time series operators in Stata:
Lag operators:
l.sales = sales(t-1)
l2.sales = sales(t-2)
ln.sales = sales(t-n)
Difference operators:
d.sales = sales(t)-sales(t-1)
d2.sales = sales(t) - sales(t-2), etc.;
* However, OLS fails to take into account the moving average structure of the lingering effects model. This means that we have serial correlation and our OLS coefficients are biased and inconsistent. We can circunvent this
problem by applying a arima estimator, which takes into account serial correlation;
arima sales l.sales adver dum1 dum2 dum3, ma(1);
* Interpretation of the coefficients:
Lagged sales determine current sales, since the lagged sales coefficient is statistically significant. In our case, we estimate a carry-over effect of 0.57: a $1,000 sales in previous period will result in a $570 sales in the current period (probably due to consumption habits). Dum1 is not significant. This means that there is no differences in
consumption patterns during 1909-1915 and the reference period 1941-1960. On the other hand, dum2 is positive and significant: between
1915-1925 consumption was $220 thousand higher than during the
reference period 1941-1960. Finally, the third dummy is negative: the consumption between 1926-1940 was $200 thousand lower than between 1941-1960.;
* Suppose we are interested to assess how long it takes to obtain 90% of the cumulative impact of our advertising expenditures on sales.;
scalar m = ln(1-0.9)/ln(_b[l.sales]);
display m;
* According to our result, it would take 4.2 years to have 90% of the
impact of our advertising expenditures on sales. This is clearly
unrealistic. Our model is plagued with the data aggregation bias.
First, letÂ´s check that the result is not related to our specific sample. If we re-estimate the regression for a subsample we get the same
overestimated number of periods. For example, considering the 1908-1920 or 1938-1960;
arima sales l.sales adver dum1 dum2 dum3 if tin(1908,1920) | tin(1938,1960), ma(1);
scalar m2 = ln(1-0.9)/ln(_b[l.sales]);
display m2;
* Despite the reduction in the time length to attain 90% of the cumulative impact, it is still unrealistic. The overestimation is not related to the specific sample we are using. Our database suffers from the time aggregation bias: the annual periodicity of the database is
inconsistent with the timing of the market purchase of this non-durable good (probably monthly or weekly);
* To verify that correcting the time inconsistency we get reasonable results, we do the exercise by using the corresponding monthly data.;
use "C:\Users\AutoLogon\Desktop\paldam.dta", clear;
* First we declare the variable mes as our time index;
tsset mes ;
* Construction the dummies;
generate mdum1= 0;
replace mdum1=1 if tin(1908m1,1914m12);
generate mdum2= 0;
replace mdum2=1 if tin(1915m1,1925m12);
generate mdum3= 0;
replace mdum3=1 if tin(1926m1,1940m12);
* Re-estimating the lingering effects model with monthly data and computing the number of periods necessary to attain 90% of the
cumulative impact of advertising on sales;
arima msales l.msales madv mdum1 mdum2 mdum3, ma(1);
scalar m3 = ln(1-0.9)/ln(_b[l.msales]);
display m3;
* We have now a more realistic estimate of the timing. It is reasonable that it takes 11 months to attain 90% of the impact on sales.;
log close ;