Hello,
I am wondering if somebody can help me with my loop. I am trying to generate a list of incremental R2 for each variable in every year. I need it to examine the time trend in them. I built the following code but it doesn't work. First of all,I don't know why each variable has one incremental R2 for all years - which doesnt make sense. Secondly, I am not sure how I can generate the table including the values from generated 896 incremental R2 equations (56 years times 16 incremental R2 in every year) .
I use the following code and obtain following results. My desired outcome is a list incremental R2 for each variable for every year . From this form I could run the regression on time.
I would be very grateful if somebody could point out errors in my code and help me with generating the table.
Thanks in advance for your help.
Jakub
I am wondering if somebody can help me with my loop. I am trying to generate a list of incremental R2 for each variable in every year. I need it to examine the time trend in them. I built the following code but it doesn't work. First of all,I don't know why each variable has one incremental R2 for all years - which doesnt make sense. Secondly, I am not sure how I can generate the table including the values from generated 896 incremental R2 equations (56 years times 16 incremental R2 in every year) .
I use the following code and obtain following results. My desired outcome is a list incremental R2 for each variable for every year . From this form I could run the regression on time.
I would be very grateful if somebody could point out errors in my code and help me with generating the table.
Code:
gen incatpr =. gen incapxpr =. gen incceqpr =. gen inchcpr =. gen inccogspr =. gen incdvcpr =. gen incintanpr =. gen incibpr =. gen incoancfpr =. gen inrevtprpr =. gen incspipr =. gen incxadpr =. gen incxsgapr =. gen increvgrowpr =. gen inccocipr =. gen time = pyear-1961 local varlist16 "atpr capxpr ceqpr chpr cogspr dvcpr intanpr ibpr oancfpr revtpr spipr xadpr xrdpr xsgapr revgrowpr ocipr" reg prc atpr capxpr ceqpr chpr cogspr dvcpr intanpr ibpr oancfpr revtpr spipr xadpr xrdpr xsgapr revgrowpr ocipr if size == 0 & pyear >=1962 & pyear <=1971 local r2_16 = `e(r2)' foreach var of local varlist16 { local varlist15: list varlist16 - var forvalues i = 1962(1)2017 { display `i' qui reg prc `varlist15' if size == 0 & pyear >=1962 & pyear <=1971 local r2_`var' = `e(r2)' noi di "regression without `var' : r-squared is `r2_`var''" noi di "difference between full regression & regression without `var' is " `r2_16'-`r2_`var'' } }
HTML Code:
regression without revgrowpr : r-squared is .4880738219715385 difference between full regression & regression without revgrowpr is .02703107 2015 regression without revgrowpr : r-squared is .4880738219715385 difference between full regression & regression without revgrowpr is .02703107 2016 regression without revgrowpr : r-squared is .4880738219715385 difference between full regression & regression without revgrowpr is .02703107 2017 regression without revgrowpr : r-squared is .4880738219715385 difference between full regression & regression without revgrowpr is .02703107 1962 regression without ocipr : r-squared is .5150345109748508 difference between full regression & regression without ocipr is .00007038 1963 regression without ocipr : r-squared is .5150345109748508 difference between full regression & regression without ocipr is .00007038 1964 regression without ocipr : r-squared is .5150345109748508 difference between full regression & regression without ocipr is .00007038 1965 regression without ocipr : r-squared is .5150345109748508 difference between full regression & regression without ocipr is .00007038
Thanks in advance for your help.
Jakub
Comment