For the bar chart of heart attack variable - I'm not clear on why the wording of the assignment asks us to make bar plots of the means of flag variables heart attack and diabetes? Shouldn't we plot the count?
Hello Julia,
You are right that it would make more sense to make the count since we want to know either, how many patients had hearth atk or what percentage had the event. However, if you use the 'count' command STATA will return the raw number of ONLY the people who had hearth atk making difficult the visualization of the meaning of the event in your overall population.
If you use 'mean' it will return the proportion of people with heart atk. I think that this is a more meaningful way to display the data.
It is a little bit confusing because in this particular case the graph is not really displaying the actual mean of hearth attack but rather the proportion of people who presented heart attack
To understand better your graph you can use the 'tab' command: tab heartatk sex, col
I hope this helps, let me know if you have any questions.
Yes, I used the tab function to take a look and also found the same problem with using 'count.' I wanted to double check to ensure we weren't supposed to create a new variable or something for this question.
Okay, here's another question about the same assignment: I am trying to troubleshoot my syntax for editing the legend in the command line and it keeps going wrong, so I thought I'd try to edit in the graph editor and see what the command line syntax looks like after I manipulate the graph in the graph editor - but when I use the graph editor Stata isn't reporting out the command line syntax for the manipulation.
That is correct. The graph editor will not return command lines because is not producing a new graph.
An extra help that you might explore is below your error message there is a line stating 'r(103)' if you click on it it will give you more information on what the error might be.
Note that the number in parenthesis might be different for you.
"help legend" is also useful. Feel free to send me your code if you are still having an issue.
For dichotomous variables where 1 = yes and 0 = no , the mean will give you the proportion of observations with 1 (yes). This is useful if we want to know the proportion of study participants with heart attack or with diabetes, for example.
Note that if you variable was coded 1 = No and 2 = Yes, then taking the mean would not give you an interpretable number.