The number of non-missing values varies with cases. For example, as shown in the below table, a has two values and d has full five values. I want to know how this (m in the below entropy formula) can be integrated into Stata.
Array
x y z w v
a 2 3 . . .
b 4 5 6 . .
c 2 . . . .
d 4 5 6 7 2
[QUOTE]
gen entropy = 0
foreach v in a b c d e {
replace entropy = entropy + cond(`v' == 0, 0, `v' * ln(1/`v'))
}
sum entropy[
/QUOTE]
Related Posts with entropy and missing values
How to change a numeric variable to string variable? Tostring and decode code don't work.Dear all, I am trying to dealing with the following problem: There is a numeric variable in my datas…
Difference-in-difference analysisHello, I'm doing a difference-in-difference analysis to show the impact of removing financial incent…
converting Risk ratio from quantiles to tertilesWe summarize the associations corresponding to the top versus bottom third of the baseline FGF-23 co…
converting Risk ratio from quantiles to tertilesI am Hatem Ali We summarize the associations corresponding to the top versus bottom third of the bas…
Histogram, wrong y-axisHi guys, I created a histogram, but the y-axis is wrong. I need the assets on the x-axis and the nu…
Subscribe to:
Post Comments (Atom)
0 Response to entropy and missing values
Post a Comment