Hello everyone,
I have 20 items ranging and a price as my dependent variable. With independent variable and lagged variables in the regression model. And I do have some interaction variables too in the regression, I want to replicate the attached graph for my analysis in Stata.
I have tried the following code.
xtset panelid date
reghdfe price var L1.var L2.var L3.var if item_new==1, absorb(district month year) vce(cluster district)
matrix b = e(b)
matrix V = e(V)
local lags var L1.var L2.var L3.var
*dataset
clear
set obs 12
gen lag = 1 + _n - 1
gen beta = .
gen lb = .
gen ub = .
local i = 1
foreach var of local lags {
scalar bval = b[1, "`var'"]
scalar se = sqrt(V[`i', `i'])
replace beta = bval in `i'
replace lb = bval - 1.96*se in `i'
replace ub = bval + 1.96*se in `i'
local ++i
}
twoway ///
(rarea ub lb lag, color(maroon%20))
(line beta lag, lcolor(maroon) lwidth(medium)), ///
xtitle("Lag (months)") ytitle("β (ln price)") ///
yline(0, lpattern(solid) lcolor(black) lwidth(medium)) ///
title("temperature effects on price: Item 1")"
However, this is for one item only, I want to have the similar graphs for all the items from 1 to 20, can someone please let me know how to do it? It would be of great help. I have taken help of AI but unable to do it.

Thanks.
I have 20 items ranging and a price as my dependent variable. With independent variable and lagged variables in the regression model. And I do have some interaction variables too in the regression, I want to replicate the attached graph for my analysis in Stata.
I have tried the following code.
xtset panelid date
reghdfe price var L1.var L2.var L3.var if item_new==1, absorb(district month year) vce(cluster district)
matrix b = e(b)
matrix V = e(V)
local lags var L1.var L2.var L3.var
*dataset
clear
set obs 12
gen lag = 1 + _n - 1
gen beta = .
gen lb = .
gen ub = .
local i = 1
foreach var of local lags {
scalar bval = b[1, "`var'"]
scalar se = sqrt(V[`i', `i'])
replace beta = bval in `i'
replace lb = bval - 1.96*se in `i'
replace ub = bval + 1.96*se in `i'
local ++i
}
twoway ///
(rarea ub lb lag, color(maroon%20))
(line beta lag, lcolor(maroon) lwidth(medium)), ///
xtitle("Lag (months)") ytitle("β (ln price)") ///
yline(0, lpattern(solid) lcolor(black) lwidth(medium)) ///
title("temperature effects on price: Item 1")"
However, this is for one item only, I want to have the similar graphs for all the items from 1 to 20, can someone please let me know how to do it? It would be of great help. I have taken help of AI but unable to do it.
Thanks.

Comment