I recognize the title is probably a bit confusing so I am gonna try to illustrate what I want to do below:
Consider that I already have the variables "F", "t" and "Beta", and I want to create a new column called "weighted beta", "weighted beta2" and so on. I will write these new variables according to the formula I want to use below but note that I have not been able to generate them yet. The idea is that the t-1 part will generate 0 division, causing stata to fill the cells with zeros, which is what I want, and also it will give the proper weight to my betas. The problem is that I do not know how to fix a beta in the formula...
Code:
F t Beta weighted beta weighted beta2 weighted beta3 weighted beta4 1 1 0.7 =(1/t)*0.7 =(1/(t-1))*0.5=0 =(1/(t-2))*0.3=0 =(1/(t-3))*0.55=0 1 2 0.5 =(1/t)*0.7 =(1/(t-1))*0.5 =(1/(t-2))*0.3=0 =(1/(t-3))*0.55=0 1 3 0.3 =(1/t)*0.7 =(1/(t-1))*0.5 =(1/(t-2))*0.3 =(1/(t-3))*0.55=0 1 4 0.55 =(1/t)*0.7 =(1/(t-1))*0.5 =(1/(t-2))*0.3 =(1/(t-3))*0.55 2 1 0.3 =(1/t)*0.3 =(1/(t-1))*0.4=0 =(1/(t-2))*0.67=0 =(1/(t-3))*0.3=0 2 2 0.4 =(1/t)*0.3 =(1/(t-1))*0.4 =(1/(t-2))*0.67=0 =(1/(t-3))*0.3=0 2 3 0.67 =(1/t)*0.3 =(1/(t-1))*0.4 =(1/(t-2))*0.67 =(1/(t-3))*0.3=0 2 4 0.3 =(1/t)*0.3 =(1/(t-1))*0.4 =(1/(t-2))*0.67 =(1/(t-3))*0.3
Kind Regards,
Birger
0 Response to Fixing a specific value within a column based on another variable when generating a new variable through a formula.
Post a Comment