Hi,

I have a dataset like this. Each patient has multiple admissions and cost corresponding to that admission in a particular year, and either falls in sample a or sample b. the variable ' months' gives the number of months that the patient is alive in that year. So, I calculate the average monthly cost as total cost/total months. So, for sample a, the average cost is 200/6 and for sample b, the average cost is 210/14. How do I apply t-test to check if these two means are statistically different?
PT_ID Cost subsample months
1 20 a 4
1 30 a 4
1 40 a 4
2 10 b 6
2 20 b 6
2 30 b 6
3 50 a 2
3 60 a 2
4 70 b 8
4 80 b 8
Thanks a lot!

Regards,
Ishwarya