Dear all,
Does anyone know how to crop (or not show in some way) the highest part of the yaxis in a sts graph? Let me explain my data and problem:
I am using sts graph, hazard to estimate risk of a type of cancer (cancer==1) in participants who are exposed (exposed==1) or unexposed (exposed==0) to a certain risk factor. I have a large dataset with about 3,330,000 participants, and I since the exposure is time-dependent, I have split the file (using stsplit), so there are 6,622,000 observations in the dataset.
As the data is sensitive, I have to use Stata on a secure server where I cannot copy anything or use the internet, so I am unfortunately not able to use dataex. In addition, I wanted to attach the graphs I have made, but I am not allowed to export graphic files (only pdfs) and when I took a picture of the graph with my phone, saved it as a .png-file and tried to upload it, I got ; "Error uploading image"). I hope someone is still able to help me.
I want to compare two graphs, one using stset with birthyear as origin, and one using study entry as origin.
stset date_eof_cancer, failure(cancer==1) entry(study_entry) origin(birth_year) sc(365.25) id(id)
and
stset date_eof_cancer, failure(cancer==1) entry(study_entry) origin(study_entry) sc(365.25) id(id)
My code for the graph is:
sts graph, by(exposed) hazard ci ///
ylabel(0 "0" 0.0001 "10" 0.0002 "20" 0.0003 "30" 0.0004 "40" 0.0005 "50") /// //and in addition 0.001 "100" 0.0015 "150" for the one with birth_year as origin
xlabel(0(5)35) // and some other options for esthetics which I suppose is not relevant to the question
The problem is that when I use the birth_year as origin, the confidence interval in the start of the curve for the exposed group is very high (150 cases per 100 000 person-years) as compared to the rest of the two graphs, where the maximum values at the yaxis is about 50 cases per 100 000 person-years.
As I would like to compare the two graphs and use them in a publication, I would prefer if I could have the same scale and labels on the yaxis. The relevant information would still be included in the graphs, and I would write a foot-note to the table describing the maximum value of the confidence interval (unless there is a way to show it in the graph without showing the whole curve of the confidence interval). As you probably know, it does not help to change the ylabel.
I have searched the Statlist forum and other websites, but not found the right way to do this. Is it even possible?
In one previous post from the Statalist (https://www.stata.com/statalist/arch.../msg00224.html), David Harrison writes "If you want to restrict the range so that some of the curve is not visible, you will need to use -sts gen- to generate the full curve and then plot only the bit you want using a standard twoway graph." Maybe that is what I need to do? However, I have not managed to make the graph this way (I can give more information about how I have tried doing this, if this is the best way to solve my problem).
I am thankful for any help,
Best regards,
Marie S. Sandvei
Resident physician and researcher
Does anyone know how to crop (or not show in some way) the highest part of the yaxis in a sts graph? Let me explain my data and problem:
I am using sts graph, hazard to estimate risk of a type of cancer (cancer==1) in participants who are exposed (exposed==1) or unexposed (exposed==0) to a certain risk factor. I have a large dataset with about 3,330,000 participants, and I since the exposure is time-dependent, I have split the file (using stsplit), so there are 6,622,000 observations in the dataset.
As the data is sensitive, I have to use Stata on a secure server where I cannot copy anything or use the internet, so I am unfortunately not able to use dataex. In addition, I wanted to attach the graphs I have made, but I am not allowed to export graphic files (only pdfs) and when I took a picture of the graph with my phone, saved it as a .png-file and tried to upload it, I got ; "Error uploading image"). I hope someone is still able to help me.
I want to compare two graphs, one using stset with birthyear as origin, and one using study entry as origin.
stset date_eof_cancer, failure(cancer==1) entry(study_entry) origin(birth_year) sc(365.25) id(id)
and
stset date_eof_cancer, failure(cancer==1) entry(study_entry) origin(study_entry) sc(365.25) id(id)
My code for the graph is:
sts graph, by(exposed) hazard ci ///
ylabel(0 "0" 0.0001 "10" 0.0002 "20" 0.0003 "30" 0.0004 "40" 0.0005 "50") /// //and in addition 0.001 "100" 0.0015 "150" for the one with birth_year as origin
xlabel(0(5)35) // and some other options for esthetics which I suppose is not relevant to the question
The problem is that when I use the birth_year as origin, the confidence interval in the start of the curve for the exposed group is very high (150 cases per 100 000 person-years) as compared to the rest of the two graphs, where the maximum values at the yaxis is about 50 cases per 100 000 person-years.
As I would like to compare the two graphs and use them in a publication, I would prefer if I could have the same scale and labels on the yaxis. The relevant information would still be included in the graphs, and I would write a foot-note to the table describing the maximum value of the confidence interval (unless there is a way to show it in the graph without showing the whole curve of the confidence interval). As you probably know, it does not help to change the ylabel.
I have searched the Statlist forum and other websites, but not found the right way to do this. Is it even possible?
In one previous post from the Statalist (https://www.stata.com/statalist/arch.../msg00224.html), David Harrison writes "If you want to restrict the range so that some of the curve is not visible, you will need to use -sts gen- to generate the full curve and then plot only the bit you want using a standard twoway graph." Maybe that is what I need to do? However, I have not managed to make the graph this way (I can give more information about how I have tried doing this, if this is the best way to solve my problem).
I am thankful for any help,
Best regards,
Marie S. Sandvei
Resident physician and researcher
Comment