*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\Aula04.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 MÚLTIPLA: RENDA = ESCOLARIDADE + IDPIA ************************************ reg renpri anest idpia [aweight=v4729] ************************************ *REGRESSÃO MÚLTIPLA: LOG DA RENDA = ESCOLARIDADE + IDPIA ************************************ reg lnrenpri anest idpia [aweight=v4729] *Visualizar o exponencial do coeficiente reg lnrenpri anest idpia [aweight=v4729], eform(Exp. Coef.) ************************************ *REGRESSÃO MÚLTIPLA: RENDA = IDPIA + IDQUAD ************************************ reg renpri idpia idquad [aweight=v4729] predict renpre2 predict renres2, res *Predito line renpre2 idpia, sort twoway (scatter renpri idpia) (line renpre2 idpia, sort) *Resíduo scatter renres2 renpre2, yline(0) ************************************ *REGRESSÃO MÚLTIPLA: LOG DA RENDA = IDPIA + IDQUAD ************************************ reg lnrenpri idpia idquad [aweight=v4729] predict lnrenpre2 predict lnrenres2, res *Predito line lnrenpre2 idpia, sort twoway (scatter lnrenpri idpia) (line lnrenpre2 idpia, sort) *Resíduo scatter lnrenres2 lnrenpre2, yline(0) *Exponencial gen explnrenpre2=exp(lnrenpre2) gen explnrenres2=exp(lnrenres2) *Predito line explnrenpre2 idpia, sort twoway (scatter renpri idpia) (line explnrenpre2 idpia, sort) *Resíduo scatter lnrenres2 explnrenpre2, yline(0) log close *browse anest renpri lnrenpri *browse anest renpri renpre renres lnrenpri lnrenpre lnrenres explnrenpre explnrenres log close