# STATA Help

<br /> STATA Documentation<br />

## STATA DOCUMENTATION ECONOMICS 2016

To look stuff up, just press Ctrl + F and type what you’re looking for

or just import the data by using File > Import

Details of our data

sum dataset

Generating a variable

gen x = 0

Deleting variables

drop x

Overwriting values

replace x = z

Generating a sequence

egen x = seq(), f(1) t(61) b(1)

Linear Regression

reg y x1 x2

Interaction Effects (Regression)

reg pizza income age c.income#c.age – [inserts only the interaction term]

reg pizza income age c.income##c.age – [inserts the interaction term and all individual terms]

Scatterplot

scatter x y

Lines

line x y, legend(size(small))

Scatterplot with Regression Line

graph twoway (lfit x y) (scatter x y)

graph twoway (lfitci x y) (scatter x y)

Two-Sided F-Test

test x2 = 1

Change text strings to numeric

gen x_n = real(x)

Predict residuals

predict res, residuals

Male dummy

sum res if male == 1

sum res if male == 2

Overwrite a variable

replace x = y

Something we did

regr wage exper male school [aweight = std^(-2)]

Variance weighted least squares

vwls wage exper male school, sd(std)

One-sided test

Just divide test x == 0 by 2, you dummy.

Installing a package

ssc install outreg2

Create a nice table into your working directory

outreg2 using regtable, excel

Generate a variable out of the coefficients

gen betax1 = _b[x]

Create constraint

constraint 1 x1 + x2 == 2

Constrained regression (constraint)

cnsreg y x1 x2 x3, constraints(1)

Plot residuals against fitted values

rvfplot

Covariance matrix of the coefficients of the regression model

estat vce

Testing two coefficients

test (exper=0) (school=0)

QNORM quantile shit

qnorm res