# Different price elasticity results

According to this article, calculating elasticity of demand for different models is: I generate data for 5% reduction in prices with a corresponding 10% increasing in sales: price elasticity = (+10%/-5%)=-2 and get different result coefficient from linear model.

price <- double(length = 10L)
price <- 200
for(i in 2:10)price[i] <- price[i-1]*.95 # price sequence with step =  -5% of last value
sales <- numeric(10)
sales <- 1000
for(i in 2:10)sales[i] <- sales[i-1]*1.1 # sales sequence with step =  +10% of last value
plot(price,sales,type="b")
+.1/-.05 #price elastic = -2
m <- lm(log(sales)~log(price))
coef(m) #price elastic = -1.858141 it's not equal -2


Then I take the same dependency of sales on price plus trend and monthly seasonality and again I get another coefficient!

# generate monthly  time series (length=48 month) with trend, monthly seasons and price correlations (from above)
smpl <- sample(x = 1:10,size = 48,replace = T) # create random index for get price-sales dependies
mnth.sez <- runif(n = 12,min = .8,max = 1.2) #create multiplication seasonality
mnth.sez[c(1,12)] <- c(0.5,1.9) # manual adjust for january and december
mnth.sez

(mnth.ts <- rep(x = 1:12,length.out=length(smpl))) # create monthly sequence
sez.ts <- mnth.sez[mnth.ts] # create seasonality sequence
trend.ts <- seq(from=10000,by=100,length.out = length(smpl)) # create linear trend
ts.num <- seq(length(trend.ts)) # create trend predictor for lm model
sales.ts <- trend.ts*sez.ts+sales[smpl] # create sales with trend, seasonality and price-sales dependies
price.ts <- price[smpl] # create price predictor for lm model
plot(x=ts.num,y=sales.ts,col="black",type = "b")
text(x=ts.num,y=sales.ts,labels = mnth.ts,pos=2,col="blue")
text(x=ts.num,y=sales.ts,labels = round(price.ts),pos=4,col="red")
# View(data.frame(mnth.ts,sez.ts,trend.ts,sales.ts,sale.price=sales[smpl]))
d <- data.frame(sales.ts,ts.num,price.ts,mnth.ts=as.factor(mnth.ts))
d.mat <- as.data.frame(model.matrix(~.,d)[,-1])
m2 <- lm(log(sales.ts)~log(price.ts)+ts.num+mnth.ts2+mnth.ts3+mnth.ts4+mnth.ts5+mnth.ts6+mnth.ts7+mnth.ts8+mnth.ts9+mnth.ts10+mnth.ts11+mnth.ts12,data = d.mat)
summary(m2)
coefficients(m2) # -0.23 it's not equal  -2 and -1.858141!!!
lines(x = ts.num,y=exp(fitted(m2)),col="green")


Why is it incorrect, and what is the true strategy for price elasticity extraction in trend-seasonality problems?

If $$P2=P1*0.95$$ then $$P3=P2*0.95=P1*(0.95)^2$$. So if $$P1=100$$ then $$P2=95$$ and $$P3=90.25$$ which isn't a 5% price step. I think your data generating process is incorrect which leads to a price elasticity from the model that doesn't match what you think it ought to be ($$\frac{0.1}{-0.05}=-2$$). As for the latter question, I do not have an answer for the price elasticity extraction in trend-seasonality problem.