Hi, STATA people,
I have 12000 obs. I want to randomly assign fake treatment within each year with stipulated treatment and run the regression. I want to repeat this procedure 100 times. This is what my code is. I am unable to store the beta and standard values in the matrix format.
Also after
STATA is issuing
Any help is appreciated. Struggling for a long time
I have 12000 obs. I want to randomly assign fake treatment within each year with stipulated treatment and run the regression. I want to repeat this procedure 100 times. This is what my code is. I am unable to store the beta and standard values in the matrix format.
Also after
Code:
matrix p = J(100,`l',.)
invalid syntax
r(198);
r(198);
Any help is appreciated. Struggling for a long time
Code:
set more off, permanently set matsize 8000 set seed 8600 unab y : wheat lentils rice local l : word count `y' matrix p = J(100,`l',.) matrix colnames p =`y' matrix b= J(100,`l',.) matrix s= J(100,`l',.) matrix colnames b =b `y' matrix colnames s=se `y' forvalues i = 1/100 { generate random=uniform() gen byte treat= . sort year random by year: replace treat= (_n <=28) if (year == 1991) //1991 28 by year: replace treat= (_n <=18) if (year == 1992) //1992 18 by year: replace treat= (_n <=19) if (year == 1993) //1993 19 by year: replace treat= (_n <=53) if (year == 1994) //1994 53 by year: replace treat= (_n <=53) if (year == 1995) //1995 53 by year: replace treat= (_n <=68) if (year == 1996) //1996 68 by year: replace treat= (_n <=58) if (year == 1997) //1997 58 by year: replace treat= (_n <=26) if (year == 1998) //1998 26 by year: replace treat= (_n <=19) if (year == 1999) //1999 19 by year: replace treat= (_n <=19) if (year == 2000) //2000 19 by year: replace treat= (_n <=19) if (year == 2001) //2001 19 by year: replace treat= (_n <=19) if (year == 2002) //2002 19 by year: replace treat= (_n <=19) if (year == 2003) //2003 19 by year: replace treat= (_n <=19) if (year == 2004) //2004 19 by year: replace treat= (_n <=19) if (year == 2005) //2005 19 by year: replace treat= (_n <=19) if (year == 2006) //2006 19 by year: replace treat= (_n <=38) if (year == 2007) //2007 38 by year: replace treat= (_n <=19) if (year == 2008) //2008 19 by year: replace treat= (_n <=19) if (year == 2009) //2009 19 by year: replace treat= (_n <=19) if (year == 2010) //2010 19 by year: replace treat= (_n <=19) if (year == 2011) //2011 19 by year: replace treat= (_n <=19) if (year == 2012) //2012 19 by year: replace treat= (_n <=19) if (year == 2013) //2013 19 by year: replace treat= (_n <=29) if (year == 2014) //2014 29 by year: replace treat= (_n <=29) if (year == 2015) //2015 29 by year: replace treat= (_n <=40) if (year == 2016) //2016 40 foreach x of local i{ local j = 1 foreach var of local y{ quietly reg `var' treat i.country_id i.year i.country_id#c.line_time_trend [aw=ypop], cluster( country_id) matrix b[`i',`j++']= get(_b) matrix s[`i',`j++']=get(_se) matrix p[`i ',`j++'] = 2*ttail(e(df_r), abs(_b[treat]/_se[treat])) } drop random drop treat // local ++i } // convert to dataset // clear svmat p, names(col) svmat b', names(matnames) svmat s, names(matnames)
Comment