# delimit ;
* Code and answers to A1 questions;
use "E:\Prova MQM\beer.dta",clear;
log using "E:\Prova MQM\answers_A1.log", replace;
* Exercise 1;
* Item 1: The price of glass recipients seems to be a good instrument for the
beer price. An adequate instrument should have two characteristics: (i) to
be correlated with the endogenous explanatory variable and (ii) be uncorrelated
with the error. On the one hand, since the glass recipient represents a production cost, it should be
correlated to the final price of the beer. On the other hand, consumer demand
should not determined by the price of glass recipient. So, our variable seems
to be a good candidate for instrumenting the beer price.;
* Item 2: Hausman test to assess the endogeneity of beer price.;
* First, we construct the variables in logs.;
generate lnconsumptionpc = ln(consumptionpc);
generate lnpbeer = ln(pbeer);
generate lnpub = ln(pub);
generate lnincome = ln(income);
generate lnpemb = ln(pemb);
* First stage: we regress variable lnpbeer on all exogenous variables including
the instrument lnpemb;
regress lnpbeer lnpub lnincome lnpemb dsummer, vce(robust);
predict e, resid;
* Second stage: we estimate the original regression including the residual of
the first stage regression as an additional variable;
regress lnconsumptionpc lnpbeer lnpub lnincome dsummer e, vce(robust);
* We observe that the coefficient associated to the residual is statistically
significant. So we have evidence beer price is endogenous and we should
estimate the demand equation by an instrumental variable regression (2SLS).
Doing a OLS regression would result in inconsistent and biased estimates.;
* Item 3: ;
ivregress 2sls lnconsumptionpc (lnpbeer=lnpemb) lnincome lnpub dsummer, vce(robust);
* A 1% increase in the beer price is associated to a 1.21% reduction in demand. Consumers are
quite sentitive to the price of beer. On the other hand, the income elasticity is not statistically significant,
which means that beer demand does not respond to income variations. The elasticity of demand with respect to
advertising is 0.10: a 1% increase in advertising expenditures is associated to a 0.10% decrease in
demand. Finally, the dummy variable for summer suggestions that during this period
beer consumption is 15% higher than the rest of the year.;
* Item 4: hypothesis test;
test lnpbeer = -0.8;
* Since we have a high p-value (0.34), we cannot reject the null hypothesis that
price-elasticity is equal to -0.8;
* Exercise 2;
use "E:\Prova MQM\ldcalls.dta", clear;
* Item 1: estimation of the lingering effects model and computation of the proportion of
cumulative impact of advertising after 3 periods with respect to total impact;
* First, we have to compute quantities;
generate q = rev/p;
tsset month;
arima q l.q pub, ma(1);
scalar cumulative3 = 1 - 1.*(_b[l.q]^3);
display cumulative3;
* The cumulative impact after 3 months is 49% of the total impact.;
* Item 2: time necessary to 70% of the cumulative impact to take place;
generate m2 = ln(1 - 0.70)/ln(_b[l.q]);
* The required time is 5.33 months.;
* Item 3: estimation of the brand loyalty model.;
prais q pub l.q;
* Since the lagged quantity is significant, we have evidence against the current
effects model. Moreover, the DW statistic of the original equation does not
provide evidence on serial correlation. So, the most recommended
model is the lingering effects model.;
log close ;