Issue
My dataframe is below
patid age gender tg0 tg1 tg2 tg3 tg4 wgt0 wgt1 wgt2 wgt3 wgt4
0 1 45 Male 180 148 106 113 100 198 196 193 188 192
1 2 56 Male 139 94 119 75 92 237 233 232 228 225
2 3 50 Male 152 185 86 149 118 233 231 229 228 226
3 4 46 Female 112 145 136 149 82 179 181 177 174 172
4 5 64 Male 156 104 157 79 97 219 217 215 213 214
Is it the right way If I do the average of tg0 tg1 tg2 tg3 tg4
and wgt0 wgt1 wgt2 wgt3 wgt4
so that i will get 2 columns a and b and do the ttest
Copying the case study also
A physician is evaluating a new diet for her patients with a family history of heart disease. To test the effectiveness of this diet, 16 patients are placed on the diet for 6 months. Their weights and triglyceride levels are measured before and after the study, and the physician wants to know if either set of measurements has changed
Null hypothesis: There is no difference in the levels of Triglycerides and weight of individual after using new diet for 6 months.
Alt hypothesis: There is has been a significant difference in the levels of Triglycerides and weight of individual after using new diet for 6 months.
For 2 variable we can do like below code
from scipy import stats
#Data of group 1
a = np.array([42.1, 80.0, 30.0, 45.8, 57.7, 80.0, 82.4, 66.2, 66.9, 79.0])
#Data of group 2
b = np.array([80.7, 85.1, 88.6, 81.7, 69.8, 79.5, 107.2, 69.3, 80.9, 63.0])
t2, p2 = stats.ttest_ind(a,b)
Solution
It looks like you want to find the difference before and after the 6 month period for each measurement type. Based on this, it seems that you would want to do two separate tests:
- Whether the final triglyceride measurement value significantly differs from the initial triglyceride measurement.
- Whether the final weight measurement value significantly differs from the initial weight measurement.
Note: I'm assuming that each column represents a measurement over time, starting with 0 and ending with 4. This would mean that tg0
and wgt0
are the initial triglyceride and weight measurements respectively, and that tg4
and wgt4
are the final measurements
For each test, you are comparing the final measurement with the initial measurement, so you would want to structure the tests like this:
t_tg, p_tg = stats.ttest_ind(tg4,tg0)
t_wgt, p_wgt = stats.ttest_ind(wgt4,wgt0)
Then use p_tg
and p_wgt
to make a unique determination for the triglycerides and the weight.
Answered By - Rylan Polster Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.