Hi – I am struggling to understand how the i. and o. operators work I created a small example below. The first 3 examples of -regress- make sense to me, but not the last two. Why is region==2 being omitted in those cases? Code and log below. -- Paul
------------------------------------------------------------------------------------------
name: <unnamed>
log: /Users/paulrathouz/Desktop/StataTest/indicatorTest.log
log type: text
opened on: 20 May 2025, 14:20:13
. // Test the i. and o. operators
. // Time-stamp: <2025-05-20 14:19:29 paulrathouz>
.
. sysuse census
(1980 Census data by state)
. des
Contains data from /Applications/Stata/ado/base/c/census.dta
Observations: 50 1980 Census data by state
Variables: 13 6 Apr 2022 15:43
------------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
------------------------------------------------------------------------------------------
state str14 %-14s State
state2 str2 %-2s Two-letter state abbreviation
region int %-8.0g cenreg Census region
pop long %12.0gc Population
poplt5 long %12.0gc Pop, < 5 year
pop5_17 long %12.0gc Pop, 5 to 17 years
pop18p long %12.0gc Pop, 18 and older
pop65p long %12.0gc Pop, 65 and older
popurban long %12.0gc Urban population
medage float %9.2f Median age
death long %12.0gc Number of deaths
marriage long %12.0gc Number of marriages
divorce long %12.0gc Number of divorces
------------------------------------------------------------------------------------------
Sorted by:
. codebook region
------------------------------------------------------------------------------------------
region Census region
------------------------------------------------------------------------------------------
Type: Numeric (int)
Label: cenreg
Range: [1,4] Units: 1
Unique values: 4 Missing .: 0/50
Tabulation: Freq. Numeric Label
9 1 NE
12 2 N Cntrl
16 3 South
13 4 West
. regress medage i.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(3, 46) = 7.56
Model | 46.3961903 3 15.4653968 Prob > F = 0.0003
Residual | 94.1237947 46 2.04616945 R-squared = 0.3302
-------------+---------------------------------- Adj R-squared = 0.2865
Total | 140.519985 49 2.8677548 Root MSE = 1.4304
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | -1.708333 .6307664 -2.71 0.009 -2.978 -.4386663
South | -1.614583 .5960182 -2.71 0.009 -2.814306 -.4148606
West | -2.948718 .620282 -4.75 0.000 -4.197281 -1.700155
|
_cons | 31.23333 .4768146 65.50 0.000 30.27356 32.19311
------------------------------------------------------------------------------
. regress medage i1.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(1, 48) = 13.85
Model | 31.4712118 1 31.4712118 Prob > F = 0.0005
Residual | 109.048773 48 2.27184944 R-squared = 0.2240
-------------+---------------------------------- Adj R-squared = 0.2078
Total | 140.519985 49 2.8677548 Root MSE = 1.5073
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
NE | 2.06504 .5548321 3.72 0.001 .9494757 3.180605
_cons | 29.16829 .2353953 123.91 0.000 28.695 29.64159
------------------------------------------------------------------------------
. regress medage o1.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(3, 46) = 7.56
Model | 46.3961903 3 15.4653968 Prob > F = 0.0003
Residual | 94.1237947 46 2.04616945 R-squared = 0.3302
-------------+---------------------------------- Adj R-squared = 0.2865
Total | 140.519985 49 2.8677548 Root MSE = 1.4304
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | -1.708333 .6307664 -2.71 0.009 -2.978 -.4386663
South | -1.614583 .5960182 -2.71 0.009 -2.814306 -.4148606
West | -2.948718 .620282 -4.75 0.000 -4.197281 -1.700155
|
_cons | 31.23333 .4768146 65.50 0.000 30.27356 32.19311
------------------------------------------------------------------------------
. regress medage o2.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(2, 47) = 6.76
Model | 31.3872636 2 15.6936318 Prob > F = 0.0026
Residual | 109.132721 47 2.3219728 R-squared = 0.2234
-------------+---------------------------------- Adj R-squared = 0.1903
Total | 140.519985 49 2.8677548 Root MSE = 1.5238
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | 0 (omitted)
South | -.6383927 .5056614 -1.26 0.213 -1.655652 .3788668
West | -1.972527 .5377578 -3.67 0.001 -3.054356 -.8906981
|
_cons | 30.25714 .3325209 90.99 0.000 29.5882 30.92609
------------------------------------------------------------------------------
.
. regress medage i(2 3 4).region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(2, 47) = 6.76
Model | 31.3872636 2 15.6936318 Prob > F = 0.0026
Residual | 109.132721 47 2.3219728 R-squared = 0.2234
-------------+---------------------------------- Adj R-squared = 0.1903
Total | 140.519985 49 2.8677548 Root MSE = 1.5238
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
South | -.6383927 .5056614 -1.26 0.213 -1.655652 .3788668
West | -1.972527 .5377578 -3.67 0.001 -3.054356 -.8906981
|
_cons | 30.25714 .3325209 90.99 0.000 29.5882 30.92609
------------------------------------------------------------------------------
.
. log close
name: <unnamed>
log: /Users/paulrathouz/Desktop/StataTest/indicatorTest.log
log type: text
closed on: 20 May 2025, 14:20:13
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
name: <unnamed>
log: /Users/paulrathouz/Desktop/StataTest/indicatorTest.log
log type: text
opened on: 20 May 2025, 14:20:13
. // Test the i. and o. operators
. // Time-stamp: <2025-05-20 14:19:29 paulrathouz>
.
. sysuse census
(1980 Census data by state)
. des
Contains data from /Applications/Stata/ado/base/c/census.dta
Observations: 50 1980 Census data by state
Variables: 13 6 Apr 2022 15:43
------------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
------------------------------------------------------------------------------------------
state str14 %-14s State
state2 str2 %-2s Two-letter state abbreviation
region int %-8.0g cenreg Census region
pop long %12.0gc Population
poplt5 long %12.0gc Pop, < 5 year
pop5_17 long %12.0gc Pop, 5 to 17 years
pop18p long %12.0gc Pop, 18 and older
pop65p long %12.0gc Pop, 65 and older
popurban long %12.0gc Urban population
medage float %9.2f Median age
death long %12.0gc Number of deaths
marriage long %12.0gc Number of marriages
divorce long %12.0gc Number of divorces
------------------------------------------------------------------------------------------
Sorted by:
. codebook region
------------------------------------------------------------------------------------------
region Census region
------------------------------------------------------------------------------------------
Type: Numeric (int)
Label: cenreg
Range: [1,4] Units: 1
Unique values: 4 Missing .: 0/50
Tabulation: Freq. Numeric Label
9 1 NE
12 2 N Cntrl
16 3 South
13 4 West
. regress medage i.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(3, 46) = 7.56
Model | 46.3961903 3 15.4653968 Prob > F = 0.0003
Residual | 94.1237947 46 2.04616945 R-squared = 0.3302
-------------+---------------------------------- Adj R-squared = 0.2865
Total | 140.519985 49 2.8677548 Root MSE = 1.4304
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | -1.708333 .6307664 -2.71 0.009 -2.978 -.4386663
South | -1.614583 .5960182 -2.71 0.009 -2.814306 -.4148606
West | -2.948718 .620282 -4.75 0.000 -4.197281 -1.700155
|
_cons | 31.23333 .4768146 65.50 0.000 30.27356 32.19311
------------------------------------------------------------------------------
. regress medage i1.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(1, 48) = 13.85
Model | 31.4712118 1 31.4712118 Prob > F = 0.0005
Residual | 109.048773 48 2.27184944 R-squared = 0.2240
-------------+---------------------------------- Adj R-squared = 0.2078
Total | 140.519985 49 2.8677548 Root MSE = 1.5073
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
NE | 2.06504 .5548321 3.72 0.001 .9494757 3.180605
_cons | 29.16829 .2353953 123.91 0.000 28.695 29.64159
------------------------------------------------------------------------------
. regress medage o1.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(3, 46) = 7.56
Model | 46.3961903 3 15.4653968 Prob > F = 0.0003
Residual | 94.1237947 46 2.04616945 R-squared = 0.3302
-------------+---------------------------------- Adj R-squared = 0.2865
Total | 140.519985 49 2.8677548 Root MSE = 1.4304
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | -1.708333 .6307664 -2.71 0.009 -2.978 -.4386663
South | -1.614583 .5960182 -2.71 0.009 -2.814306 -.4148606
West | -2.948718 .620282 -4.75 0.000 -4.197281 -1.700155
|
_cons | 31.23333 .4768146 65.50 0.000 30.27356 32.19311
------------------------------------------------------------------------------
. regress medage o2.region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(2, 47) = 6.76
Model | 31.3872636 2 15.6936318 Prob > F = 0.0026
Residual | 109.132721 47 2.3219728 R-squared = 0.2234
-------------+---------------------------------- Adj R-squared = 0.1903
Total | 140.519985 49 2.8677548 Root MSE = 1.5238
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
N Cntrl | 0 (omitted)
South | -.6383927 .5056614 -1.26 0.213 -1.655652 .3788668
West | -1.972527 .5377578 -3.67 0.001 -3.054356 -.8906981
|
_cons | 30.25714 .3325209 90.99 0.000 29.5882 30.92609
------------------------------------------------------------------------------
.
. regress medage i(2 3 4).region
Source | SS df MS Number of obs = 50
-------------+---------------------------------- F(2, 47) = 6.76
Model | 31.3872636 2 15.6936318 Prob > F = 0.0026
Residual | 109.132721 47 2.3219728 R-squared = 0.2234
-------------+---------------------------------- Adj R-squared = 0.1903
Total | 140.519985 49 2.8677548 Root MSE = 1.5238
------------------------------------------------------------------------------
medage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
region |
South | -.6383927 .5056614 -1.26 0.213 -1.655652 .3788668
West | -1.972527 .5377578 -3.67 0.001 -3.054356 -.8906981
|
_cons | 30.25714 .3325209 90.99 0.000 29.5882 30.92609
------------------------------------------------------------------------------
.
. log close
name: <unnamed>
log: /Users/paulrathouz/Desktop/StataTest/indicatorTest.log
log type: text
closed on: 20 May 2025, 14:20:13
------------------------------------------------------------------------------------------
Comment