I am trying to generate a variable (CSSD) for dispersion which is equal to the sum of the squared deviations from the market of each of the following cryptocurrencies. However, not all of the currencies have data that goes back to the start of the period I am analysing. When there is missing values I want Stata to ignore that currency and calculate the statistic based on those with data. I am not sure if I have explained this very clearly but have tried my best. Does anyone have any ideas regarding a solution?
The code I am currently using:
gen SSD = 0
foreach var in Bitcoin Ethereum Cardano Binancecoin XRP Litecoin Chainlink Bitoincash Stellar Nem Dogecoin Theta Monero TRON EOS {
replace SSD = SSD + (`var'DayRtn - MarketDayRtn)^2
}
gen CSSD = 0
replace CSSD = sqrt((SSD/15-1))
Best,
Ted
Related Posts with How to generate a variable that uses other variables when I have missing values
DiD and MatchingHi, I came across two commands that are supposed to do similar jobs: -kmatch- and -diff- Both of th…
Simultaneous equation model with dynamic panelDear all: I am trying to estimate a four-equation simultaneous model, my dataset is a panel. Usuall…
meta regress - STATA16Dear all, I have a very general question about the meta regress command in Stata 16. I could not fin…
Setting Stubhello everyone, I hope you are all well. I have a variable that indicates the region of residence of…
Allocating cases to the class with the highest probabilty - Latent Class AnalysisHi Statalists, I am running a LCA with the gsem-command. My code is as follows: Code: gsem ( var…
Subscribe to:
Post Comments (Atom)
0 Response to How to generate a variable that uses other variables when I have missing values
Post a Comment