How do I select the interaction coefficients to keep in Stata? - stata

Similar to the question posed here, but I think I am not employing it correctly.
I used help fvvarlist to guide me on interactions.
I am employing a triple interaction with 3 binary variables:
As a toy model, let us assume:
x = gender (1 = male, 0 = female)
y = health (1 = good, 0 = poor)
z = employment (1 = employed, 0 = not employed)
using the following regression:
reg x##y##z if state == "NY" & year >1985
I am interested in the results for 1.x#1.y#1.z, but this coefficient is omitted.
1.x#1.y#1.z omitted because of collinearity
Is there a way I can keep this interaction?

It would be best to verify that you actually have this combination in your data with egen, group.
You should also use i. prefixes to keep Stata from treating your variables as continuous, which has the added benefit of a more informative error message: interaction identifies no observations in the sample rather than a mysterious collinearity one.
Here is a reproducible example:
. sysuse auto, clear
(1978 automobile data)
. sum mpg weight
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
mpg | 74 21.2973 5.785503 12 41
weight | 74 3019.459 777.1936 1760 4840
. gen efficient = mpg > 21
. lab define efficient 0 "Inefficient" 1 "Efficient"
. lab val efficient efficient
. gen heavy = weight > 3e3
. lab define heavy 0 "Light" 1 "Heavy"
. lab val heavy heavy
. egen group = group(foreign efficient heavy), label(group)
. tab group, sort
group(foreign efficient |
heavy) | Freq. Percent Cum.
---------------------------+-----------------------------------
Domestic Inefficient Heavy | 34 45.95 45.95
Foreign Efficient Light | 15 20.27 66.22
Domestic Efficient Light | 13 17.57 83.78
Foreign Inefficient Light | 5 6.76 90.54
Domestic Efficient Heavy | 3 4.05 94.59
Domestic Inefficient Light | 2 2.70 97.30
Foreign Inefficient Heavy | 2 2.70 100.00
---------------------------+-----------------------------------
Total | 74 100.00
. reg price c.foreign##c.efficient##c.heavy, robust
note: c.foreign#c.efficient#c.heavy omitted because of collinearity.
Linear regression Number of obs = 74
F(6, 67) = 74.67
Prob > F = 0.0000
R-squared = 0.2830
Root MSE = 2606.9
-----------------------------------------------------------------------------------------------
| Robust
price | Coefficient std. err. t P>|t| [95% conf. interval]
------------------------------+----------------------------------------------------------------
foreign | 3007.6 960.0626 3.13 0.003 1091.307 4923.893
efficient | 513.2308 394.6504 1.30 0.198 -274.4948 1300.956
|
c.foreign#c.efficient | -1810.164 1071.875 -1.69 0.096 -3949.636 329.3076
|
heavy | 3283.176 696.5873 4.71 0.000 1892.782 4673.571
|
c.foreign#c.heavy | 2462.724 1196.996 2.06 0.044 73.50896 4851.938
|
c.efficient#c.heavy | -2783.741 744.4813 -3.74 0.000 -4269.732 -1297.75
|
c.foreign#c.efficient#c.heavy | 0 (omitted)
|
_cons | 3739 332.9212 11.23 0.000 3074.486 4403.514
-----------------------------------------------------------------------------------------------
. reg price i.foreign##i.efficient##i.heavy, robust
note: 1.foreign#1.efficient#1.heavy identifies no observations in the sample.
Linear regression Number of obs = 74
F(6, 67) = 74.67
Prob > F = 0.0000
R-squared = 0.2830
Root MSE = 2606.9
------------------------------------------------------------------------------------------
| Robust
price | Coefficient std. err. t P>|t| [95% conf. interval]
-------------------------+----------------------------------------------------------------
foreign |
Foreign | 3007.6 960.0626 3.13 0.003 1091.307 4923.893
|
efficient |
Efficient | 513.2308 394.6504 1.30 0.198 -274.4948 1300.956
|
foreign#efficient |
Foreign#Efficient | -1810.164 1071.875 -1.69 0.096 -3949.636 329.3076
|
heavy |
Heavy | 3283.176 696.5873 4.71 0.000 1892.782 4673.571
|
foreign#heavy |
Foreign#Heavy | 2462.724 1196.996 2.06 0.044 73.50896 4851.938
|
efficient#heavy |
Efficient#Heavy | -2783.741 744.4813 -3.74 0.000 -4269.732 -1297.75
|
foreign#efficient#heavy |
Foreign#Efficient#Heavy | 0 (empty)
|
_cons | 3739 332.9212 11.23 0.000 3074.486 4403.514
------------------------------------------------------------------------------------------
There are no foreign, efficient, and heavy cars in the data, and when you let Stata know that you have categorical variables on the RHS, you get an understandable error message about why the triple interaction is missing.

Related

How can I adjust a coefplot for the constant value of categorical variable estimation?

I have a dataset in Stata that looks something like this
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
dv2 | 1,904 .5395645 .427109 -1.034977 1.071396
xvar | 1,904 3.074055 1.387308 1 5
with xvar being a categorical independent variable and dv2 a dependent variable of interest.
I am estimating a simple model with the categorical variable as a dummy:
reg dv2 ib4.xvar
eststo myest
Source | SS df MS Number of obs = 1,904
-------------+---------------------------------- F(4, 1899) = 13.51
Model | 9.60846364 4 2.40211591 Prob > F = 0.0000
Residual | 337.540713 1,899 .177746558 R-squared = 0.0277
-------------+---------------------------------- Adj R-squared = 0.0256
Total | 347.149177 1,903 .182422058 Root MSE = .4216
------------------------------------------------------------------------------
dv2 | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
xvar |
A | .015635 .0307356 0.51 0.611 -.044644 .075914
B | .1435987 .029325 4.90 0.000 .0860861 .2011113
C | .1711176 .0299331 5.72 0.000 .1124124 .2298228
E | .1337754 .0295877 4.52 0.000 .0757477 .1918032
|
_cons | .447794 .020191 22.18 0.000 .4081952 .4873928
------------------------------------------------------------------------------
These are the results. As you can see B, C and E have larger effect than D which is the excluded category.
However, coefplot does not account for the in categorical variable the coefficient is composite true_A=D+A.
coefplot myest, scheme(s1color) vert
As you can see the plot shows the constant to be the largest coefficient, while the other to be smaller.
Is there a systematic way I can adjust for this problem and plot the true coefficients and SEs of each category?
Thanks a lot for your help
In response to your second comment, here is an example of how you can use marginsplot to plot estimated effects from a linear regression.
sysuse auto, clear
replace price = price/100
reg price i.rep78, cformat(%9.2f)
------------------------------------------------------------------------------
price | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
rep78 |
2 | 14.03 23.56 0.60 0.554 -33.04 61.10
3 | 18.65 21.76 0.86 0.395 -24.83 62.13
4 | 15.07 22.21 0.68 0.500 -29.31 59.45
5 | 13.48 22.91 0.59 0.558 -32.28 59.25
|
_cons | 45.65 21.07 2.17 0.034 3.55 87.74
------------------------------------------------------------------------------
margins i.rep78, cformat(%9.2f)
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
rep78 |
1 | 45.65 21.07 2.17 0.034 3.55 87.74
2 | 59.68 10.54 5.66 0.000 38.63 80.73
3 | 64.29 5.44 11.82 0.000 53.42 75.16
4 | 60.72 7.02 8.64 0.000 46.68 74.75
5 | 59.13 8.99 6.58 0.000 41.18 77.08
------------------------------------------------------------------------------
marginsplot
Note that these values are the constant plus the appropriate coefficient.
And then using the marginsplot command we can produce the following plot, which includes the marginal estimates and confidence intervals:

Show categorical variables in reverse order in regression results

I am running a regression on categorical variables in Stata:
regress y i.age i.birth
Part of the regression results output is below:
coef
age
28 .1
29 -.2
birth
1958 .2
1959 .5
I want the above results to be shown in the reverse order, so that I can export them to Excel using the putexcel command:
coef
age
29 -.2
28 .1
birth
1959 .5
1958 .2
I tried sorting the birth and age variables before regression, but this does not work.
Can someone help?
You cannot directly reverse the factor levels of a variable in the regression output.
However, if your end goal is to create a table in Microsoft Excel one way to do this is the following:
sysuse auto.dta, clear
estimates clear
keep if !missing(rep78)
tabulate rep78, generate(rep)
regress price mpg weight rep2-rep5
estimates store r1
regress price mpg weight rep5 rep4 rep3 rep2
estimates store r2
Normal results:
esttab r1 using results.csv, label refcat(rep2 "Repair record", nolabel)
------------------------------------
(1)
Price
------------------------------------
Mileage (mpg) -63.10
(-0.72)
Weight (lbs.) 2.093**
(3.29)
Repair record
rep78== 2.0000 753.7
(0.39)
rep78== 3.0000 1349.4
(0.76)
rep78== 4.0000 2030.5
(1.12)
rep78== 5.0000 3376.9
(1.78)
Constant -599.0
(-0.15)
------------------------------------
Observations 69
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Reversed results:
esttab r2 using results.csv, label refcat(rep5 "Repair record", nolabel)
------------------------------------
(1)
Price
------------------------------------
Mileage (mpg) -63.10
(-0.72)
Weight (lbs.) 2.093**
(3.29)
Repair record
rep78== 5.0000 3376.9
(1.78)
rep78== 4.0000 2030.5
(1.12)
rep78== 3.0000 1349.4
(0.76)
rep78== 2.0000 753.7
(0.39)
Constant -599.0
(-0.15)
------------------------------------
Observations 69
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Note that here I am using the commmunity-contributed command esttab to export the results.
You can make further tweaks if you fiddle with its options.
EDIT:
This solution manually creates dummies for esttab but instead you can also create a new variable with the reverse coding and use the opposite base level as #NickCox demonstrates in his solution.
You can reverse the coding and apply value labels to insist on what you will see:
sysuse auto, clear
generate rep78_2 = 6 - rep78
label define new 1 "5" 2 "4" 3 "3" 4 "2" 5 "1"
label values rep78_2 new
regress mpg i.rep78_2
Source | SS df MS Number of obs = 69
-------------+---------------------------------- F(4, 64) = 4.91
Model | 549.415777 4 137.353944 Prob > F = 0.0016
Residual | 1790.78712 64 27.9810488 R-squared = 0.2348
-------------+---------------------------------- Adj R-squared = 0.1869
Total | 2340.2029 68 34.4147485 Root MSE = 5.2897
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rep78_2 |
4 | -5.69697 2.02441 -2.81 0.006 -9.741193 -1.652747
3 | -7.930303 1.86452 -4.25 0.000 -11.65511 -4.205497
2 | -8.238636 2.457918 -3.35 0.001 -13.14889 -3.32838
1 | -6.363636 4.066234 -1.56 0.123 -14.48687 1.759599
|
_cons | 27.36364 1.594908 17.16 0.000 24.17744 30.54983
------------------------------------------------------------------------------
regress mpg ib5.rep78_2
Source | SS df MS Number of obs = 69
-------------+---------------------------------- F(4, 64) = 4.91
Model | 549.415777 4 137.353944 Prob > F = 0.0016
Residual | 1790.78712 64 27.9810488 R-squared = 0.2348
-------------+---------------------------------- Adj R-squared = 0.1869
Total | 2340.2029 68 34.4147485 Root MSE = 5.2897
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rep78_2 |
5 | 6.363636 4.066234 1.56 0.123 -1.759599 14.48687
4 | .6666667 3.942718 0.17 0.866 -7.209818 8.543152
3 | -1.566667 3.863059 -0.41 0.686 -9.284014 6.150681
2 | -1.875 4.181884 -0.45 0.655 -10.22927 6.479274
|
_cons | 21 3.740391 5.61 0.000 13.52771 28.47229
------------------------------------------------------------------------------
If you wanted to see the same variable name as before, you could also do the following:
drop rep78
rename rep78_2

xtreg omitting year dummy variables when using i.year

I have a panel dataset with the following years:
tab year
year | Freq. Percent Cum.
------------+-----------------------------------
2000 | 31 12.55 12.55
2001 | 31 12.55 25.10
2002 | 30 12.15 37.25
2003 | 31 12.55 49.80
2004 | 31 12.55 62.35
2005 | 31 12.55 74.90
2006 | 31 12.55 87.45
2007 | 31 12.55 100.00
------------+-----------------------------------
Total | 247 100.00
When I do xtreg dv iv i.year, I see that year 2000 is not included, as well as 2007:
xtreg local_gr rtxdum i.year
note: 2007.year omitted because of collinearity
Random-effects GLS regression Number of obs = 247
Group variable: province_n~e Number of groups = 31
R-sq: Obs per group:
within = 0.6194 min = 7
between = 0.0016 avg = 8.0
overall = 0.2356 max = 8
Wald chi2(7) = 341.51
corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000
------------------------------------------------------------------------------
local_gr | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rtxdum | -753799.7 291543.7 -2.59 0.010 -1325215 -182384.5
|
year |
2001 | 388246 291543.7 1.33 0.183 -183169.2 959661.2
2002 | 745406.4 294294.5 2.53 0.011 168599.8 1322213
2003 | 1175610 291543.7 4.03 0.000 604194.4 1747025
2004 | 1773982 291543.7 6.08 0.000 1202567 2345397
2005 | 2600005 291543.7 8.92 0.000 2028589 3171420
2006 | 4425318 291543.7 15.18 0.000 3853903 4996734
2007 | 0 (omitted)
|
_cons | 1564670 447832.4 3.49 0.000 686934.1 2442405
-------------+----------------------------------------------------------------
sigma_u | 2217878.8
sigma_e | 1150064.9
rho | .78809251 (fraction of variance due to u_i)
------------------------------------------------------------------------------
The message says 2007 was omitted due to collinearity, but I don't understand why year 2000 would not show up in the results?
Because it is the base level. You can see it by using the allbaselevels option:
webuse nlswork, clear
xtset idcode
xtreg ln_w grade tenure i.race not_smsa south, allbaselevels
Random-effects GLS regression Number of obs = 28,091
Group variable: idcode Number of groups = 4,697
R-sq: Obs per group:
within = 0.1005 min = 1
between = 0.4498 avg = 6.0
overall = 0.3305 max = 15
Wald chi2(6) = 6509.50
corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000
------------------------------------------------------------------------------
ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
grade | .07605 .0018128 41.95 0.000 .0724969 .0796031
tenure | .0361319 .0006298 57.37 0.000 .0348975 .0373663
|
race |
white | 0 (base)
black | -.0530121 .0102916 -5.15 0.000 -.0731832 -.0328409
other | .0762678 .0415911 1.83 0.067 -.0052492 .1577849
|
not_smsa | -.1289554 .0074296 -17.36 0.000 -.1435172 -.1143936
south | -.0786512 .0075533 -10.41 0.000 -.0934555 -.063847
_cons | .6759773 .0244723 27.62 0.000 .6280125 .7239421
-------------+----------------------------------------------------------------
sigma_u | .26440074
sigma_e | .30295598
rho | .43235646 (fraction of variance due to u_i)
------------------------------------------------------------------------------

Stata Not Dropping Variables (in regression) due to Multicollinearity and I think it should

I am running a simple regression of race times against temperature just to develop some basic intuition. My data-set is very large and each observation is the race completion time of a unit in a given race, in a given year.
For starters I am running a very simple regression of race time on temperature bins.
Summary of temp variable:
|
Variable | Obs Mean Std. Dev Min Max
------------+--------------------------------------------
avg_temp_scc| 8309434 54.3 9.4 0 89
Summary of time variable:
Variable | Obs Mean Std. Dev Min Max
------------+--------------------------------------------
chiptime | 8309434 267.5 59.6 122 1262
I decided to make 10 degree bins for temperature and regress time against those.
The code is:
egen temp_trial = cut(avg_temp_scc), at(0,10,20,30,40,50,60,70,80,90)
reg chiptime i.temp_trial
The output is
Source | SS df MS Number of obs = 8309434
---------+------------------------------ F( 8,8309425) =69509.83
Model | 1.8525e+09 8 231557659 Prob > F = 0.0000
Residual | 2.7681e+108309425 3331.29368 R-squared = 0.0627
-----+-------------------------------- Adj R-squared = 0.0627
Total | 2.9534e+108309433 3554.22521 Root MSE = 57.717
chiptime | Coef. Std. Err. t P>|t| [95% Conf. Interval]
----------+----------------------------------------------------------------
temp_trial |
10 | -26.63549 2.673903 -9.96 0.000 -31.87625 -21.39474
20 | 10.23883 1.796236 5.70 0.000 6.71827 13.75939
30 | -16.1049 1.678432 -9.60 0.000 -19.39457 -12.81523
40 | -13.97918 1.675669 -8.34 0.000 -17.26343 -10.69493
50 | -10.18371 1.675546 -6.08 0.000 -13.46772 -6.899695
60 | -.6865365 1.675901 -0.41 0.682 -3.971243 2.59817
70 | 44.42869 1.676883 26.49 0.000 41.14206 47.71532
80 | 23.63064 1.766566 13.38 0.000 20.16824 27.09305
_cons | 273.1366 1.675256 163.04 0.000 269.8531 276.42
So stata correctly drops the one of the bins (in this case 0-10) of temperature.
Now I manually created the bins and ran the regression again:
gen temp0 = 1 if temp_trial==0
replace temp0 = 0 if temp_trial!=0
gen temp1 = 1 if temp_trial == 10
replace temp1 = 0 if temp_trial != 10
gen temp2 = 1 if temp_trial==20
replace temp2 = 0 if temp_trial!=20
gen temp3 = 1 if temp_trial==30
replace temp3 = 0 if temp_trial!=30
gen temp4=1 if temp_trial==40
replace temp4=0 if temp_trial!=40
gen temp5=1 if temp_trial==50
replace temp5=0 if temp_trial!=50
gen temp6=1 if temp_trial==60
replace temp6=0 if temp_trial!=60
gen temp7=1 if temp_trial==70
replace temp7=0 if temp_trial!=70
gen temp8=1 if temp_trial==80
replace temp8=0 if temp_trial!=80
reg chiptime temp0 temp1 temp2 temp3 temp4 temp5 temp6 temp7 temp8
The output is:
Source | SS df MS Number of obs = 8309434
---------+------------------------------ F( 9,8309424) =61786.51
Model | 1.8525e+09 9 205829030 Prob > F = 0.0000
Residual | 2.7681e+108309424 3331.29408 R-squared = 0.0627
--------+------------------------------ Adj R-squared = 0.0627
Total | 2.9534e+108309433 3554.22521 Root MSE = 57.717
--------------------------------------------------------------------------
chiptime | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---------+----------------------------------------------------------------
temp0 | -54.13245 6050.204 -0.01 0.993 -11912.32 11804.05
temp1 | -80.76794 6050.204 -0.01 0.989 -11938.95 11777.42
temp2 | -43.89362 6050.203 -0.01 0.994 -11902.08 11814.29
temp3 | -70.23735 6050.203 -0.01 0.991 -11928.42 11787.94
temp4 | -68.11162 6050.203 -0.01 0.991 -11926.29 11790.07
temp5 | -64.31615 6050.203 -0.01 0.992 -11922.5 11793.87
temp6 | -54.81898 6050.203 -0.01 0.993 -11913 11803.36
temp7 | -9.703755 6050.203 -0.00 0.999 -11867.89 11848.48
temp8 | -30.5018 6050.203 -0.01 0.996 -11888.68 11827.68
_cons | 327.269 6050.203 0.05 0.957 -11530.91 12185.45
Note the bins are exhaustive of the entire data set and stata is including a constant in the regression and none of the bins are getting dropped. Is this not incorrect? Given that the constant is being included in the regression, shouldn't one of the bins get dropped to make it the "base case"? I feel as though I am missing something obvious here.
Edit:
Here is a dropbox link for the data and do file:
It contains only the two variables under consideration. The file is 129 mb. I also have a picture of my output at the link.
This too is not an answer, but an extended comment, since I'm tired of fighting with the 600-character limit and the freeze on editing after 5 minutes.
In the comment thread on the original post, #user52932 wrote
Thank you for verifying this. Can you elaborate on what exactly this
precision issue is? Does this only cause problems in this
multicollinearity issue? Could it be that when I am using factor
variables this precision issue may cause my estimates to be wrong?
I want to be unambiguous that the results from the regression using factor variables are as correct as those of any well-specified regression can be.
In the regression using dummy variables, the model was misspecified to include a set of multicollinear variables. Stata is then faulted for failing to detect the multicollinearity.
But there's no magic test for multicollinearity. It's inferred from characteristics of the cross-products matrix. In this case the cross-products matrix represents 8.3 million observations, and despite Stata's use of double-precision throughout, the calculated matrix passed Stata's test and was not detected as containing a multicollinear set of variables. This is the locus of the precision problem to which I referred. Note that by reordering the observations, the accumulated cross-products matrix differed enough so that it now failed Stata's test, and the misspecification was detected.
Now look at the results in the original post obtained from this misspecified regression. Note that if you add 54.13245 to the coefficients on each of the dummy variables and subtract the same amount from the constant, the resulting coefficients and constant are identical to those in the regression using factor variables. This is the textbook definition of the problem with multicollinearity - not that the coefficient estimates are wrong, but that the coefficient estimates are not uniquely defined.
In a comment above, #user52932 wrote
I am unsure what Stata is using as the base case in my data.
The answer is that Stata used no base case; the results are what are to be expected when a set of multicollinear variables is included among the independent variables.
So this question is a reminder to us that statistical packages like Stata cannot infallibly detect multicollinearity. As it turns out, that's part of the genius of factor variable notation, I realize now. With factor variable notation, you tell Stata to create a set of dummy variables that by definition will be multicollinear, and since it understands that relationship between the dummy variables, it can eliminate the multicollinearity ex ante, before constructing the cross-products matrix, rather than attempt to infer the problem ex post, using the cross-products matrix's characteristics.
We should not be surprised that Stata occasionally fails to detect multicollinearity, but rather gratified that it does as well as it does at doing so. After all, the second model is indeed a misspecification, which constitutes an unambiguous violation of the assumptions of OLS regression on the user's part.
This may not be an "answer" but it's too long for a comment, so I write it here.
My results are different. At the final regression, one variable is dropped:
. clear all
. set obs 8309434
number of observations (_N) was 0, now 8,309,434
. set seed 1
. gen avg_temp_scc = floor(90*uniform())
. egen temp_trial = cut(avg_temp_scc), at(0,10,20,30,40,50,60,70,80,90)
. gen chiptime = rnormal()
. reg chiptime i.temp_trial
Source | SS df MS Number of obs = 8,309,434
-------------+---------------------------------- F(8, 8309425) = 0.88
Model | 7.07729775 8 .884662219 Prob > F = 0.5282
Residual | 8308356.5 8,309,425 .999871411 R-squared = 0.0000
-------------+---------------------------------- Adj R-squared = -0.0000
Total | 8308363.58 8,309,433 .9998713 Root MSE = .99994
------------------------------------------------------------------------------
chiptime | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
temp_trial |
10 | .0010732 .0014715 0.73 0.466 -.0018109 .0039573
20 | .0003255 .0014713 0.22 0.825 -.0025581 .0032092
30 | .0017061 .0014713 1.16 0.246 -.0011776 .0045897
40 | .0003128 .0014717 0.21 0.832 -.0025718 .0031973
50 | .0007142 .0014715 0.49 0.627 -.0021699 .0035983
60 | .0021693 .0014716 1.47 0.140 -.0007149 .0050535
70 | -.0008265 .0014715 -0.56 0.574 -.0037107 .0020577
80 | -.0005001 .0014714 -0.34 0.734 -.0033839 .0023837
|
_cons | -.0006364 .0010403 -0.61 0.541 -.0026753 .0014025
------------------------------------------------------------------------------
. * "qui tab temp_trial, gen(temp)" is more convenient than "forv ..."
. forv k = 0/8 {
2. gen temp`k' = temp_trial==`k'0
3. }
. reg chiptime temp0-temp8
note: temp6 omitted because of collinearity
Source | SS df MS Number of obs = 8,309,434
-------------+---------------------------------- F(8, 8309425) = 0.88
Model | 7.07729775 8 .884662219 Prob > F = 0.5282
Residual | 8308356.5 8,309,425 .999871411 R-squared = 0.0000
-------------+---------------------------------- Adj R-squared = -0.0000
Total | 8308363.58 8,309,433 .9998713 Root MSE = .99994
------------------------------------------------------------------------------
chiptime | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
temp0 | -.0021693 .0014716 -1.47 0.140 -.0050535 .0007149
temp1 | -.0010961 .0014719 -0.74 0.456 -.003981 .0017888
temp2 | -.0018438 .0014717 -1.25 0.210 -.0047282 .0010407
temp3 | -.0004633 .0014717 -0.31 0.753 -.0033477 .0024211
temp4 | -.0018566 .0014721 -1.26 0.207 -.0047419 .0010287
temp5 | -.0014551 .0014719 -0.99 0.323 -.00434 .0014298
temp6 | 0 (omitted)
temp7 | -.0029958 .0014719 -2.04 0.042 -.0058808 -.0001108
temp8 | -.0026694 .0014718 -1.81 0.070 -.005554 .0002152
_cons | .0015329 .0010408 1.47 0.141 -.0005071 .0035729
------------------------------------------------------------------------------
The difference with yours is: (i) different data (I generated random numbers), (ii) I used a forvalue loop instead of manual variable creation. Yet, I see no errors in your codes.

Stata Predict GARCH

I want to do something very easy, but it doesnt work!
I need to see the predictions (and errors) of a GARCH model. The Main Variable es "dowclose", and my idea is look if the GARCH model has a good fitting on this variable.
Im using this easy code, but the prediction are just 0's
webuse dow1.dta
arch dowclose, noconstant arch(1) garch(1)
predict dow_hat, y
ARCH Results:
ARCH family regression
Sample: 1 - 9341 Number of obs = 9341
Distribution: Gaussian Wald chi2(.) = .
Log likelihood = -76191.43 Prob > chi2 = .
------------------------------------------------------------------------------
| OPG
dowclose | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
arch |
L1. | 1.00144 6.418855 0.16 0.876 -11.57929 13.58217
|
garch |
L1. | -.001033 6.264372 -0.00 1.000 -12.27898 12.27691
|
_cons | 56.60589 620784.7 0.00 1.000 -1216659 1216772
------------------------------------------------------------------------------
This is to be expected: you have no covariates and no intercept, so there's nothing to predict.
Here's a simple OLS regression that makes the problem apparent:
. sysuse auto
(1978 Automobile Data)
. reg price, nocons
Source | SS df MS Number of obs = 74
-------------+------------------------------ F( 0, 74) = 0.00
Model | 0 0 . Prob > F = .
Residual | 3.4478e+09 74 46592355.7 R-squared = 0.0000
-------------+------------------------------ Adj R-squared = 0.0000
Total | 3.4478e+09 74 46592355.7 Root MSE = 6825.9
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
------------------------------------------------------------------------------
. predict phat
(option xb assumed; fitted values)
. sum phat
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
phat | 74 0 0 0 0