我已经将线性回归模型拟合到Stata中的某些数据,现在我想针对变量id
生成Residual Autocorrelation Plot。
下面您可以找到从回归生成的变量:
clear
input id response pred_response stud_res
101 72 57.55613 1.512287
102 61 51.24638 1.010817
103 49 56.94838 -0.8237054
104 48 43.1188 0.5078933
105 51 60.35182 -0.9997848
106 49 43.1188 0.6123365
107 50 43.60501 0.6678697
108 58 67.50063 -1.00277
109 50 45.17883 0.5053187
110 51 45.66593 0.5525671
111 59 62.28483 -0.3425483
112 65 52.94175 1.259024
113 57 59.49549 -0.2584414
114 53 59.00929 -0.6238151
115 74 68.10928 0.6212816
116 50 54.2797 -0.4418168
117 84 68.35238 1.671826
118 46 50.27308 -0.4435438
119 52 48.0915 0.4033695
120 64 58.04234 0.6188389
121 59 45.17972 1.444254
122 55 54.51646 0.0500989
124 46 44.33432 0.1745929
125 52 51.48948 0.0526441
126 63 64.71586 -0.1833892
127 52 51.00238 0.1038181
128 42 43.84811 -0.1929091
129 57 63.62279 -0.6922547
130 23 42.75415 -2.098808
131 65 58.88685 0.6355278
132 38 48.45526 -1.100601
133 59 54.77137 0.4510341
134 26 43.72021 -1.880954
135 53 60.46791 -0.7770496
136 50 40.68689 0.9796554
137 56 51.9748 0.4227943
138 49 65.43971 -1.751305
139 76 68.83858 0.7565064
140 68 66.53456 0.1536334
141 60 49.66532 1.077015
142 46 43.72021 0.2374953
143 57 59.85926 -0.2981544
144 45 48.45615 -0.3568231
145 46 45.42282 0.0596576
146 64 67.13597 -0.3291895
147 40 41.9024 -0.1997022
148 62 64.7104 -0.283202
149 13 45.78748 -3.629334
150 79 63.25813 1.66337
151 61 59.86015 0.1180355
152 46 42.02484 0.4124526
153 50 45.66593 0.4487194
154 48 51.61103 -0.3727813
155 65 59.37306 0.5858857
156 62 69.08168 -0.748562
157 56 54.5228 0.1524598
158 54 52.09724 0.196739
159 72 60.46156 1.209799
160 57 60.83167 -0.4032753
161 50 41.6593 0.8780965
162 65 55.97507 0.9392686
163 56 66.28511 -1.086957
201 54 49.5392 0.4779044
202 57 50.02451 0.7322617
203 48 49.18 -0.1222386
204 41 41.66019 -0.0684602
205 34 38.38376 -0.4576099
206 54 54.511 -0.0545433
207 38 40.68777 -0.2798446
208 49 41.77539 0.7603746
209 58 54.63255 0.3589811
210 14 47.24063 -3.676064
211 40 39.47226 0.0554914
212 13 39.71537 -2.931103
213 51 45.17426 0.611295
214 44 54.39491 -1.084383
216 42 48.08604 -0.6381954
217 55 46.38978 0.8958285
301 62 63.86043 -0.1954589
302 37 43.23401 -0.6509517
303 46 44.57196 0.147607
304 59 59.8538 -0.0890346
305 35 41.66019 -0.6924483
306 70 66.77221 0.3416052
307 56 58.15843 -0.2244185
308 45 46.99207 -0.2117317
309 50 47.47739 0.2635025
310 52 46.87598 0.5302449
311 52 59.84834 -0.8546749
312 83 49.78776 3.674294
313 57 54.03025 0.3084902
314 38 44.57196 -0.680949
315 40 48.81446 -0.9177504
410 48 39.59927 0.8789283
415 50 40.92999 0.9539063
605 42 36.31649 0.6024827
end
当我生成此图时,垂直轴的默认范围设置为包含估计的自相关值。但是,我想将此轴范围扩展到所有允许的相关值上(即从负一到正一)。不幸的是,当我这样做时,轴标签不会调整到新的范围,并且标签会被挤压。
下面是我的代码和输出:
* Generate the residual autocorrelation plot
* (taken with respect to id variable)
tsset id
ac stud_res, lags(12) yscale(r(-1,1)) ///
title("Residual Autocorrelation Plot") ///
ytitle("Estimated Autocorrelation") ///
如何获得在垂直轴上具有所需扩展长度的图,而又不将标签仅挤压到图值的范围内?