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
Create a scatter plot with quartiles (visualisation)Hi folks. I hope this isn't a silly question, but still learning how to work with Stata. I am tryin…
Using _n to create a sequence variable using "if"Hi I have a dataset consisting of dispensed medication items - there are multiple records for each …
margins with discrete variables: semi-elasticity vs. relative marginal differencesDear Forum, In the context of factor variables in a logit model (calculated using Stata 15.1), I'm …
linktest interpretationHi all, Could you please help in interpreting the below result of the link test (attached). Also, I…
Testing for outliers with multiple imputation in panel dataAs the title says, I have a outlier in my panel data (2 time periods) with MI. I was wondering what …
Subscribe to:
Post Comments (Atom)
0 Response to entropy and missing values
Post a Comment