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
Growth mixture modelling for longitudinal register data with varying measurement pointsHi Statalisters, I wanted to ask regarding growth mixture modelling for register data (PS I am not s…
Stored results for standard errorsHi, I am using probit regression and margins command thereafter. I am inquiring if the standard err…
Count number of time where at least x number of consecutive rows have the same valueHello, I have a large dataset which displays a status per time point. I want to count the number of…
How can I use control variables(dummy) in probit?Hello, I am working on my thesis and was my professor explained that for my dataset a probit analys…
Creating a new observation with specific "missing" valueGreetings! I have seen similar questions posted, but not close enough to what I need to figure out a…
Subscribe to:
Post Comments (Atom)
0 Response to Referring to previous observation that differs from current observation of same variable
Post a Comment