Hello,
I am very new to Stata, so please excuse my inexperience.
I am using a data set comprised by the variables future, enddate, date, price, tk, S1_1, S1_1_TK, SKX.
"Future" refers to the settlement period of the future, enddate specifies the date of settlement, date is connected to price and specifies the date in which the price can be observed, tk is a constant 100bp for transaction costs, S1_1 refers to the spread in effect at the specified date between the future and the previous future, S1_1_TK is the spread minus the transaction costs at the time of opening the position and SKX refers to the settlement price of the future.
Now I would like to generate a new variable "S1_1_TK2". S1_1_TK2 should be comprised of S1_1_TK and the transaction costs at the time of closing the position. Thus I need to refer to the settlement price of the prior period future.
In this case (and as you can see in the screenshot attached) I want to refer to SKX=6,98 when calculating the value of S1_1_TK2 for the Dec-12 future.
I tried:
gen S1_1_TK2 = S1_1_TK - SKX[_n-1] * tk
Obviously this does not work expect for the first Dec-12 future. For all the following Dec-12 future this command refers to the closing price of the Dec-12 future aswell.
So I would need to find an command which refers to the first observation of the variable SKX which differs from the current observation.
Thanks!
Array
Related Posts with Referring to previous observation that differs from current observation of same variable
Command for computing effect size for paired/dependent samples t-testHello, I am trying to run some code for computing as effect size for paired sample t tests. It will…
Replace missing values per householdDear All, I would like to replace missing values per household Each household should have a similar…
Y-Var shows trend - how to deal with it?Hello dear community, I use the following regression model of an article in JFE, this is the exact …
Xtile - method for choosing cutpointsI'm revising a paper for a peer-reviewed medical journal. Part of our analysis included creating "qu…
Compare sum of coefficients across different regression subsamplesDear Statalisters I have looked through previous posts on suest on tests related to two coefficients…
Subscribe to:
Post Comments (Atom)
0 Response to Referring to previous observation that differs from current observation of same variable
Post a Comment