Dear all
I am trying to calculate the average bond maturity over the preceding three months as an instrumental variable in my analysis. it is worth noting that my data is unbalanced and one firm_id can have multiple observations within one year. Therefore, declaring the data as a panel using firm_id would not work. Therefore,
My command is :
xtset observations_num Year
gen matruity_moveavrg=(F1.maturity+maturity+L1.maturit y)/3
the generated new variable is missing and the code is incorrect.
any help is highly appreciated in proving the correct code.
Related Posts with how to calculate the moving average for a variable
filling blank spaces for data in long formatMy data are repeated measures in long format as shown below. Since this is the same participant, How…
Getting the value of kernel density function estimate at specific coordinateDear all, I estimate the kernel density of variable var1 and at the mean of var1 I would like to dr…
Graph parallel trend for DID with multiple periods and csdidHi everyone, I am trying to do DID with multiple periods. My dataset is a panel data (from 1960 to…
Extract year from DateHallo, I have have a little problem and would be thankful if anyone could help me. My dataset conta…
convert a matrix to a column vector, and then output it to Excel fileHello, I need your help on matrix and Excel in Stata. I have a matrix m and would like to stack its …
Subscribe to:
Post Comments (Atom)
0 Response to how to calculate the moving average for a variable
Post a Comment