Hi everyone,
I am having issues graphing a regression discontinuity in Stata.
My dataset is the following:
HiscamP year treated |
|---------------------------|
1. | 42.84128 1862 0 |
2. | 43.88376 1862 0 |
3. | 43.422 1863 0 |
4. | 44.46448 1863 0 |
5. | 44.15967 1864 0 |
|---------------------------|
6. | 45.20215 1864 0 |
7. | 43.7359 1865 0 |
8. | 44.77838 1865 0 |
9. | 42.87267 1866 0 |
10. | 43.91515 1866 0 |
|---------------------------|
11. | 42.82558 1867 0 |
12. | 43.86806 1867 0 |
13. | 43.0924 1868 0 |
14. | 44.13488 1868 0 |
15. | 44.23815 1869 0 |
|---------------------------|
16. | 45.28062 1869 0 |
17. | 44.3794 1870 0 |
18. | 45.42188 1870 0 |
19. | 44.12828 1871 0 |
20. | 45.17076 1871 0 |
|---------------------------|
21. | 48.19841 1872 1 |
22. | 49.07626 1872 1 |
23. | 47.75099 1873 1 |
24. | 48.62885 1873 1 |
25. | 47.60185 1874 1 |
|---------------------------|
26. | 48.47971 1874 1 |
27. | 47.64446 1875 1 |
28. | 48.52232 1875 1 |
29. | 47.74034 1876 1 |
30. | 48.61819 1876 1 |
|---------------------------|
31. | 47.86817 1877 1 |
32. | 48.74603 1877 1 |
33. | 48.12384 1878 1 |
34. | 49.00169 1878 1 |
35. | 48.33689 1879 1 |
|---------------------------|
36. | 49.21475 1879 1 |
37. | 48.73105 1880 1 |
38. | 49.60891 1880 1 |
39. | 49.67915 1881 1 |
40. | 50.55701 1881 1 |
|---------------------------|
41. | 48.51799 1882 1 |
42. | 49.39585 1882 1 |
+---------------------------+
.
Essentially, I am trying to produce a scatter graph for the dataset above that includes two lines of best fit, one for the years that experienced the treatment and one for the years that did not receive the treatment.
I have tried the following lines of code but they return "error 198 invalid syntax":
Attempted lines
graph twoway (lfit HiscamP year if treated=1) (scatter HiscamP year if treated=1
> )
twoway (lfit HiscamP year if treated=1)
In essence, I am trying to add two lines of best fit to the graph below. One for the years up to and including 1871 and one for the following years

Thank you in advance!
I am having issues graphing a regression discontinuity in Stata.
My dataset is the following:
HiscamP year treated |
|---------------------------|
1. | 42.84128 1862 0 |
2. | 43.88376 1862 0 |
3. | 43.422 1863 0 |
4. | 44.46448 1863 0 |
5. | 44.15967 1864 0 |
|---------------------------|
6. | 45.20215 1864 0 |
7. | 43.7359 1865 0 |
8. | 44.77838 1865 0 |
9. | 42.87267 1866 0 |
10. | 43.91515 1866 0 |
|---------------------------|
11. | 42.82558 1867 0 |
12. | 43.86806 1867 0 |
13. | 43.0924 1868 0 |
14. | 44.13488 1868 0 |
15. | 44.23815 1869 0 |
|---------------------------|
16. | 45.28062 1869 0 |
17. | 44.3794 1870 0 |
18. | 45.42188 1870 0 |
19. | 44.12828 1871 0 |
20. | 45.17076 1871 0 |
|---------------------------|
21. | 48.19841 1872 1 |
22. | 49.07626 1872 1 |
23. | 47.75099 1873 1 |
24. | 48.62885 1873 1 |
25. | 47.60185 1874 1 |
|---------------------------|
26. | 48.47971 1874 1 |
27. | 47.64446 1875 1 |
28. | 48.52232 1875 1 |
29. | 47.74034 1876 1 |
30. | 48.61819 1876 1 |
|---------------------------|
31. | 47.86817 1877 1 |
32. | 48.74603 1877 1 |
33. | 48.12384 1878 1 |
34. | 49.00169 1878 1 |
35. | 48.33689 1879 1 |
|---------------------------|
36. | 49.21475 1879 1 |
37. | 48.73105 1880 1 |
38. | 49.60891 1880 1 |
39. | 49.67915 1881 1 |
40. | 50.55701 1881 1 |
|---------------------------|
41. | 48.51799 1882 1 |
42. | 49.39585 1882 1 |
+---------------------------+
.
Essentially, I am trying to produce a scatter graph for the dataset above that includes two lines of best fit, one for the years that experienced the treatment and one for the years that did not receive the treatment.
I have tried the following lines of code but they return "error 198 invalid syntax":
Attempted lines
graph twoway (lfit HiscamP year if treated=1) (scatter HiscamP year if treated=1
> )
twoway (lfit HiscamP year if treated=1)
In essence, I am trying to add two lines of best fit to the graph below. One for the years up to and including 1871 and one for the following years
Thank you in advance!
Comment