*Limpando a memória clear *Indicando tamanho da memória set mem 100m *Não interromper tabelas longas set more off *Colocar vírgulas e pontos no padrão brasileiro set dp comma *Abrindo o arquivo de log log using "C:\curso\progs\Aula02.log", replace text ************************************ *PNAD 2007 - MINAS GERAIS ************************************ use "C:\curso\dados\pes2007MG.dta", clear ************************************ *RENDIMENTO ************************************ *Rendimento mensal em dinheiro que recebia normalmente, *no mês de referência, *no trabalho principal da semana de referência sum v9532, detail *OLHAR DICIONÁRIO DE DADOS!!! *Recodificando rendimento gen renpri=. replace renpri=v9532 if v9532!=999999999999 sum renpri, d hist renpri *Criando logaritmo de rendimento gen lnrenpri=ln(renpri) hist lnrenpri ************************************ *IDADE DO MORADOR ************************************ sum v8005, d *OLHAR DICIONÁRIO DE DADOS!!! *Recodificando idade do morador gen idpia=. replace idpia=v8005 if v8005>=15 & v8005<=64 sum idpia, d gen idquad = idpia ^ 2 ************************************ *ANOS DE ESTUDO ************************************ sum v4803, d *OLHAR DICIONÁRIO DE DADOS!!! *Recodificando anos de estudo gen anest=. replace anest=v4803-1 if v4803!=17 tab v4803 anest, missing ************************************ *RAÇA NEGRA ************************************ gen negra=. replace negra=0 if v0404==2 replace negra=1 if v0404==4 | v0404==8 ************************************ *SEXO FEMININO ************************************ gen mulher=. replace mulher=0 if v0302==2 replace mulher=1 if v0302==4 ************************************ *REGIÃO DE RESIDÊNCIA ************************************ gen regiao=. replace regiao=1 if uf>=11 & uf<=17 replace regiao=2 if uf>=21 & uf<=29 replace regiao=3 if uf>=31 & uf<=35 replace regiao=4 if uf>=41 & uf<=43 replace regiao=5 if uf>=50 & uf<=53 gen no=0 replace no=1 if regiao==1 gen ne=0 replace ne=1 if regiao==2 gen se=0 replace se=1 if regiao==3 gen su=0 replace su=1 if regiao==4 gen co=0 replace co=1 if regiao==5 ************************************ *LIMPANDO O BANCO ************************************ keep if renpri!=. & lnrenpri!=. & idpia!=. & anest!=. & negra!=. & mulher!=. & regiao!=. ************************************ *EXEMPLOS DOS SLIDES ************************************ ************************************ *REGRESSÃO SIMPLES: RENDA = ESCOLARIDADE ************************************ reg renpri anest [aweight=v4729] predict renpre predict renres, res label variable renpre "" *Predito line renpre anest, sort twoway (scatter renpri anest) (line renpre anest, sort) *Resíduo scatter renres renpre, yline(0) ************************************ *REGRESSÃO SIMPLES: LOG DA RENDA = ESCOLARIDADE ************************************ reg lnrenpri anest [aweight=v4729] predict lnrenpre predict lnrenres, res label variable lnrenpre "" *Visualizar o exponencial do coeficiente reg lnrenpri anest [aweight=v4729], eform(Exp. Coef.) *Predito line lnrenpre anest, sort twoway (scatter lnrenpri anest) (line lnrenpre anest, sort) *Resíduo scatter lnrenres lnrenpre, yline(0) *Exponencial gen explnrenpre=exp(lnrenpre) gen explnrenres=exp(lnrenres) *Predito line explnrenpre anest, sort twoway (scatter renpri anest) (line explnrenpre anest, sort) *Resíduo scatter lnrenres explnrenpre, yline(0) log close