Hi everyone,
I am analysing a data with the aim to generate mean cost for two treatment arms A and B. I have 2 variables: type (Before or After) and age. Treatment A has 104 patients and B has 116 patients.
To do this, I used the following command:
bysort treatment: glm totalcost i.type i.age
This gave me exactly what I was looking for i.e. effect of type and age on total cost according to treatment A and treatment B.
To get the mean cost, I used the margins command.
margins type
This gave me the following table:
Predictive margins
Model VCE: OIM
Expression: Predicted mean total, predict () Number of obs = 116
I noticed that 'margins type' gave me the mean costs for both the types but only for treatment B, as shown by the number of observations.
So, I was wondering if you can help me figure out the reason behind this and how to obtain a similar table for treatment A?
I am analysing a data with the aim to generate mean cost for two treatment arms A and B. I have 2 variables: type (Before or After) and age. Treatment A has 104 patients and B has 116 patients.
To do this, I used the following command:
bysort treatment: glm totalcost i.type i.age
This gave me exactly what I was looking for i.e. effect of type and age on total cost according to treatment A and treatment B.
To get the mean cost, I used the margins command.
margins type
This gave me the following table:
Predictive margins
Model VCE: OIM
Expression: Predicted mean total, predict () Number of obs = 116
Type | Margin | SE | z | P|z| | [95% Conf. Interval] | |
Before | 41758.05 | 5360.599 | 7.79 | 0.000 | 31251.47 | 52264.63 |
After | 64857.69 | 7530.048 | 8.61 | 0.000 | 50099.06 | 79616.31 |
So, I was wondering if you can help me figure out the reason behind this and how to obtain a similar table for treatment A?
Comment