I'm trying to run a loop to generate the normal returns for my event study, however I run into the following error: no observations r(2000);
A sample of the data that I'm using:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(firmid date) int eventtime double(return marketreturn) 10104 20150928 -171 -.027066 -.025666 10104 20150929 -170 -.000902 .001233 10104 20150930 -169 .019445 .019076 10104 20151001 -168 .001948 .001974 10104 20151002 -167 .015204 .014315 10104 20151005 -166 .018788 .01829 10104 20151006 -165 -.003079 -.003588 10104 20151007 -164 .009817 .008036 10104 20151008 -163 .008534 .008818 10104 20151009 -162 .001437 .000725 10104 20151012 -161 -.000226 .001276 10104 20151013 -160 -.007799 -.006825 10104 20151014 -159 -.004298 -.004716 10104 20151015 -158 .014726 .014853 10104 20151016 -157 .003398 .00457 10104 20151019 -156 -.000676 .000271 10104 20151020 -155 -.001174 -.001421 10104 20151021 -154 -.00803 -.005825 10104 20151022 -153 .013958 .016628 10104 20151023 -152 .009512 .01103 10104 20151026 -151 -.002833 -.001913 10104 20151027 -150 -.004484 -.002554 10104 20151028 -149 .013662 .01184 10104 20151029 -148 -.00221 -.00045 10104 20151030 -147 -.004013 -.00481 10104 20151102 -146 .012462 .011874 10104 20151103 -145 .003109 .002728 10104 20151104 -144 -.003391 -.003545 10104 20151105 -143 -.001398 -.001132 10104 20151106 -142 -.000379 -.000348 10104 20151109 -141 -.009617 -.009823 10104 20151110 -140 .00129 .001511 10104 20151111 -139 -.004136 -.003228 10104 20151112 -138 -.014517 -.01399 10104 20151113 -137 -.009785 -.011207 10104 20151116 -136 .013755 .014903 10104 20151117 -135 -.001368 -.001339 10104 20151118 -134 .015289 .016162 10104 20151119 -133 -.000995 -.001123 10104 20151120 -132 .003012 .00381 10104 20151123 -131 -.000676 -.001235 10104 20151124 -130 .002372 .001222 10104 20151125 -129 .001165 -.000129 10104 20151127 -128 .00078 .000594 10104 20151130 -127 -.003856 -.004641 10104 20151201 -126 .009524 .010681 10104 20151202 -125 -.010729 -.010996 10104 20151203 -124 -.01433 -.014374 10104 20151204 -123 .016455 .020526 10104 20151207 -122 -.009795 -.00699 10104 20151208 -121 -.006114 -.00649 10104 20151209 -120 -.0066 -.007739 10104 20151210 -119 .00205 .002251 10104 20151211 -118 -.019851 -.019423 10104 20151214 -117 .001597 .004756 10104 20151215 -116 .011313 .010619 10104 20151216 -115 .014906 .014515 10104 20151217 -114 -.014615 -.015041 10104 20151218 -113 -.015068 -.017797 10104 20151221 -112 .007152 .007778 10104 20151222 -111 .008839 .008817 10104 20151223 -110 .013685 .012418 10104 20151224 -109 -.000831 -.001599 10104 20151228 -108 -.003328 -.002179 10104 20151229 -107 .010021 .01063 10104 20151230 -106 -.007376 -.007217 10104 20151231 -105 -.008202 -.009412 10104 20160104 -104 -.0149 -.015304 10104 20160105 -103 .001397 .002012 10104 20160106 -102 -.013822 -.013115 10104 20160107 -101 -.02396 -.0237 10104 20160108 -100 -.010925 -.010838 10104 20160111 -99 -.001716 .000853 10104 20160112 -98 .006078 .007803 10104 20160113 -97 -.025859 -.024965 10104 20160114 -96 .015461 .016696 10104 20160115 -95 -.021697 -.021599 10104 20160119 -94 -.002418 .000532 10104 20160120 -93 -.010609 -.011694 10104 20160121 -92 .005685 .005195 10104 20160122 -91 .022497 .020284 10104 20160125 -90 -.016696 -.015638 10104 20160126 -89 .015938 .014144 10104 20160127 -88 -.010554 -.010863 10104 20160128 -87 .00508 .005529 10104 20160129 -86 .024569 .02476 10104 20160201 -85 -.000359 -.000443 10104 20160202 -84 -.020012 -.018743 10104 20160203 -83 .005759 .004992 10104 20160204 -82 .003651 .001527 10104 20160205 -81 -.019618 -.018481 10104 20160208 -80 -.016957 -.014154 10104 20160209 -79 -.003064 -.000664 10104 20160210 -78 .000261 -.000189 10104 20160211 -77 -.011979 -.012301 10104 20160212 -76 .020146 .019518 10104 20160216 -75 .017685 .016517 10104 20160217 -74 .018118 .01648 10104 20160218 -73 -.004207 -.004666 10104 20160219 -72 -.000227 -.000026 end
My current code is looking as follows:
Code:
su firmid local N `r(max)' //Generate normal returns variable gen NR_MMM =. //Creating a loop to generate normal returns forvalues i = 1/`N'{ display `i'/`N' ** Market Model method (MMM) quietly reg return marketreturn if (firmid==`i' & eventtime<=-1) quietly predict r if firmid==`i' quietly replace NR_MMM = r if firmid==`i' quietly drop r } gen AR_MMM = return - NR_MMM
0 Response to no observations error event study
Post a Comment