I have a panel data of participants with their blood sugar levels. I want to calculate probabilities for each of the following:
- controlled blood sugar, given the last measure of blood sugar was controlled
- uncontrolled blood sugar, given the last measure of blood sugar was controlled
- controlled blood sugar, given the last measure of blood sugar was uncontrolled
- uncontrolled blood sugar, given the last measure of blood sugar was uncontrolled
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str22 patientid float(mosfrombs cont_fbs) "10-986" 1 0 "10-986" 2 0 "10-986" 4 0 "10-986" 4 0 "10-986" 5 0 "11-1050" 11 1 "11-1050" 12 1 "2-128" 7 1 "2-128" 8 0 "2-128" 10 1 "2-128" 11 1 "2-128" 12 1 "2-128" 13 1 "2-128" 14 0 end
Below is the code I used to run monthly probability of having controlled blood sugar given (i) last blood sugar measure was controlled (ii) last measure was uncontrolled:
Code:
logistic cont_fbs mosfrombs if cont_fbs[_n-1]==1 margins, at(mosfrombs=(0(1)36))
Code:
logistic cont_fbs mosfrombs if cont_fbs[_n-1]==0 margins, at(mosfrombs=(0(1)36))
Thanks so much in advance!
0 Response to Conditional probability
Post a Comment