Descarga la aplicación para disfrutar aún más
Vista previa del material en texto
Ejercicio Econometría 1. DESCRIPCIÓN BASE DE DATOS: Variables Profit Utilidad anual de la farmacia ubicada en la ciudad (en dólares) Birth Rate Número de nacimientos por cada 1.000 habitantes de la población Soc Security Número de habitantes con seguro social, por cada 1.000 habitantes CV Death Número de muertes por accidentes cardiovasculares, por cada 100.000 habitantes 65.Older Porcentaje de individuos con 65 o más años 2. ANALIZAR CORRELACIÓN ENTRE VARIABLES 3. “CORRER” EL MODELO 4. ¿CÓMO ANALIZAR EL MODELO? a. N° de observaciones b. Test F, test de significancia global c. Coeficiente de determinación: R cuadrado y R cuadrado ajustado d. BIC y AIC e. Error estándar de los errores f. Coeficientes y desviación estándar g. Estadístico t y valor p (significancia) 5. SI SE VE LA MATRIZ DE CORRELACIONES, SE OBSERVA QUE LA CORRELACIÓN ENTRE CVDEATH Y BIRTHRATE ES .85 ¿CONTRIBUIRÁ LA COLINEALIDAD ENTRE ELLAS A QUE SALGAN NO SIGNIFICATIVAS? TEST DE SIGNIFICANCIA CONJUNTA. 6. ¿QUÉ HACER LUEGO? a. DEPENDE: i. Búsqueda del mejor modelo explicativo: sacar las variables de una en una y ver qué pasa en cada ocasión. 1. Sacar variables según significancia, partiendo con la menos significativa. 2. Detener proceso cuando todas las variables del modelo son significativas. 3. Probar supuestos 4. Analizar resultados ii. Si el modelo busca explicar un fenómeno con variables específicas de análisis (teoría) y variables de control. 1. No sacar variables y probar supuestos. 2. Si todo OK, analizar resultados En el caso de buscar el mejor modelo explicativo: 7. EVALUACIÓN DE SUPUESTOS a. Linealidad, por construcción el modelo es lineal en lo parámetros. b. Muestreo aleatorio simple, se puede testear pero no lo haremos en este curso. Se asume c. Media condicional cero En el caso i, el modelo final elegido fue: COMANDOS STATA: Predecir valores ajustados, residuos y residuos estandarizados: . predict v_ajust, xb . predict residual, r . predict resest, rsta RVFPLOT RVPPLOT varlist d. No colinealidad perfecta Índice VIF – Análisis de Inflación de Varianza e. Homocedasticidad 2 Test posibles: Breusch-Pagan White f. Normalidad de residuos qnorm residual pnorm residual . summ residual Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- residual | 110 .0000144 16269.13 -38155.67 40067.94 . ksmirnov residual = normal((residual-r(mean))/r(sd)) One-sample Kolmogorov-Smirnov test against theoretical distribution normal((residual-r(mean))/r(sd)) Smaller group D P-value Corrected ---------------------------------------------- residual: 0.0614 0.436 Cumulative: -0.0334 0.783 Combined K-S: 0.0614 0.801 0.766 g. Otros test importantes: Bondad de Ajuste: Linktest Test de Omisión de Variables ANÁLISIS GRÁFICO: LVR2PLOT – leverage (influencia de observaciones – outliers) . predict lev, h . summ lev Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- lev | 110 .0272727 .0295457 .0093771 .1820894 , criterio máximo 3 GRÁFICO DE REGRESIÓN twoway (scatter v_ajust profit, sort) (lfit v_ajust profit), ytitle(Valores ajustados) xtitle(Profit) 12 N o t e : N = O b s u s e d i n c a l c u l a t i n g B I C ; s e e [ R ] B I C n o t e . 1 1 0 - 1 2 7 6 . 5 3 2 - 1 2 2 1 . 1 1 3 4 2 4 5 0 . 2 2 6 2 4 6 1 . 0 2 8 M o d e l O b s l l ( n u l l ) l l ( m o d e l ) d f A I C B I C . e s t a t i c _ c o n s 1 1 9 9 2 0 . 3 7 1 7 7 . 7 7 5 1 6 . 7 1 0 . 0 0 0 1 0 5 6 8 9 . 7 1 3 4 1 5 1 o l d e r 1 0 6 4 4 . 2 5 1 4 5 9 . 9 5 1 7 . 2 9 0 . 0 0 0 7 7 4 9 . 7 5 8 1 3 5 3 8 . 7 5 c v d e a t h - 5 3 . 6 2 5 3 9 3 5 . 9 8 0 4 6 - 1 . 4 9 0 . 1 3 9 - 1 2 4 . 9 6 0 2 1 7 . 7 0 9 3 7 s o c s e c u r i t y - 3 0 3 . 6 0 0 8 1 2 4 . 2 4 2 6 - 2 . 4 4 0 . 0 1 6 - 5 4 9 . 9 2 3 8 - 5 7 . 2 7 7 8 6 p r o f i t C o e f . S t d . E r r . t P > | t | [ 9 5 % C o n f . I n t e r v a l ] T o t a l 7 . 7 4 0 2 e + 1 0 1 0 9 7 1 0 1 0 5 9 6 8 R o o t M S E = 1 6 3 2 8 A d j R - s q u a r e d = 0 . 6 2 4 6 R e s i d u a l 2 . 8 2 5 8 e + 1 0 1 0 6 2 6 6 5 8 9 2 6 8 R - s q u a r e d = 0 . 6 3 4 9 M o d e l 4 . 9 1 4 3 e + 1 0 3 1 . 6 3 8 1 e + 1 0 P r o b > F = 0 . 0 0 0 0 F ( 3 , 1 0 6 ) = 6 1 . 4 5 S o u r c e S S d f M SN u m b e r o f o b s = 1 1 0 . r e g r e s s p r o f i t s o c s e c u r i t y c v d e a t h o l d e r Note: N=Obs used in calculating BIC; see [R] BIC note . 110 -1276.532 -1221.113 4 2450.226 2461.028 Model Obs ll(null) ll(model) df AIC BIC . estat ic _cons 119920.3 7177.775 16.71 0.000 105689.7 134151 older 10644.25 1459.951 7.29 0.000 7749.758 13538.75 cvdeath -53.62539 35.98046 -1.49 0.139 -124.9602 17.70937 socsecurity -303.6008 124.2426 -2.44 0.016 -549.9238 -57.27786 profit Coef. Std. Err. t P>|t| [95% Conf. Interval] Total 7.7402e+10 109 710105968 Root MSE = 16328 Adj R-squared = 0.6246 Residual 2.8258e+10 106 266589268 R-squared = 0.6349 Model 4.9143e+10 3 1.6381e+10 Prob > F = 0.0000 F( 3, 106) = 61.45 Source SS df MS Number of obs = 110 . regress profit socsecurity cvdeath older N o t e : N = O b s u s e d i n c a l c u l a t i n g B I C ; s e e [ R ] B I C n o t e . 1 1 0 - 1 2 7 6 . 5 3 2 - 1 2 2 2 . 2 5 4 3 2 4 5 0 . 5 0 7 2 4 5 8 . 6 0 9 M o d e l O b s l l ( n u l l ) l l ( m o d e l ) d f A I C B I C . e s t a t i c _ c o n s 1 1 8 2 4 0 . 7 7 1 2 9 . 0 8 8 1 6 . 5 9 0 . 0 0 0 1 0 4 1 0 8 . 1 1 3 2 3 7 3 . 2 o l d e r 9 8 3 8 . 9 9 4 1 3 6 4 . 0 1 4 7 . 2 1 0 . 0 0 0 7 1 3 4 . 9 9 6 1 2 5 4 2 . 9 9 s o c s e c u r i t y - 3 4 5 . 9 3 9 3 1 2 1 . 6 3 9 7 - 2 . 8 4 0 . 0 0 5 - 5 8 7 . 0 7 5 7 - 1 0 4 . 8 0 2 8 p r o f i t C o e f . S t d . E r r . t P > | t | [ 9 5 % C o n f . I n t e r v a l ] T o t a l 7 . 7 4 0 2 e + 1 0 1 0 9 7 1 0 1 0 5 9 6 8 R o o t M S E = 1 6 4 2 0 A d j R - s q u a r e d = 0 . 6 2 0 3 R e s i d u a l 2 . 8 8 5 1 e + 1 0 1 0 7 2 6 9 6 3 2 1 2 7 R - s q u a r e d = 0 . 6 2 7 3 M o d e l 4 . 8 5 5 1 e + 1 0 2 2 . 4 2 7 5 e + 1 0 P r o b > F = 0 . 0 0 0 0 F ( 2 , 1 0 7 ) = 9 0 . 0 3 S o u r c e S S d f M S N u m b e r o f o b s = 1 1 0 . r e g r e s s p r o f i t s o c s e c u r i t y o l d e r Note: N=Obs used in calculating BIC; see [R] BIC note . 110 -1276.532 -1222.254 3 2450.507 2458.609 Model Obs ll(null) ll(model) df AIC BIC . estat ic _cons 118240.7 7129.088 16.59 0.000 104108.1 132373.2 older 9838.994 1364.014 7.21 0.000 7134.996 12542.99 socsecurity -345.9393 121.6397 -2.84 0.005 -587.0757 -104.8028 profit Coef. Std. Err. t P>|t| [95% Conf. Interval] Total 7.7402e+10 109 710105968 Root MSE = 16420 Adj R-squared = 0.6203 Residual 2.8851e+10 107 269632127 R-squared = 0.6273 Model 4.8551e+10 2 2.4275e+10 Prob > F = 0.0000 F( 2, 107) = 90.03 Source SS df MS Number of obs = 110 . regress profit socsecurity older_ c o n s 1 1 8 2 4 0 . 7 7 1 2 9 . 0 8 8 1 6 . 5 9 0 . 0 0 0 1 0 4 1 0 8 . 1 1 3 2 3 7 3 . 2 o l d e r 9 8 3 8 . 9 9 4 1 3 6 4 . 0 1 4 7 . 2 1 0 . 0 0 0 7 1 3 4 . 9 9 6 1 2 5 4 2 . 9 9 s o c s e c u r i t y - 3 4 5 . 9 3 9 3 1 2 1 . 6 3 9 7 - 2 . 8 4 0 . 0 0 5 - 5 8 7 . 0 7 5 7 - 1 0 4 . 8 0 2 8 p r o f i t C o e f . S t d . E r r . t P > | t | [ 9 5 % C o n f . I n t e r v a l ] T o t a l 7 . 7 4 0 2 e + 1 0 1 0 9 7 1 0 1 0 5 9 6 8 R o o t M S E = 1 6 4 2 0 A d j R - s q u a r e d = 0 . 6 2 0 3 R e s i d u a l 2 . 8 8 5 1 e + 1 0 1 0 7 2 6 9 6 3 2 1 2 7 R - s q u a r e d = 0 . 6 2 7 3 M o d e l 4 . 8 5 5 1 e + 1 0 2 2 . 4 2 7 5 e + 1 0 P r o b > F = 0 . 0 0 0 0 F ( 2 , 1 0 7 ) = 9 0 . 0 3 S o u r c e S S d f M S N u m b e r o f o b s = 1 1 0 . r e g r e s s p r o f i t s o c s e c u r i t y o l d e r _cons 118240.7 7129.088 16.59 0.000 104108.1 132373.2 older 9838.994 1364.014 7.21 0.000 7134.996 12542.99 socsecurity -345.9393 121.6397 -2.84 0.005 -587.0757 -104.8028 profit Coef. Std. Err. t P>|t| [95% Conf. Interval] Total 7.7402e+10 109 710105968 Root MSE = 16420 Adj R-squared = 0.6203 Residual 2.8851e+10 107 269632127 R-squared = 0.6273 Model 4.8551e+10 2 2.4275e+10 Prob > F = 0.0000 F( 2, 107) = 90.03 Source SS df MS Number of obs = 110 . regress profit socsecurity older -40000 -20000 0 20000 40000 Residuals 150000200000250000300000 Fitted values -40000 -20000 0 20000 40000 Residuals 50100150200250300 Número de habitantes con seguro social, por cada 1000 habitantes -40000 -20000 0 20000 40000 Residuals 510152025 Porcentaje de individuos con 65 o más años M e a n V I F 8 . 3 2 s o c s e c u r i t y 8 . 3 2 0 . 1 2 0 1 4 9 o l d e r 8 . 3 2 0 . 1 2 0 1 4 9 V a r i a b l e V I F 1 / V I F . v i f Mean VIF 8.32 socsecurity 8.32 0.120149 older 8.32 0.120149 Variable VIF 1/VIF . vif P r o b > c h i 2 = 0 . 4 0 1 9 c h i 2 ( 1 ) = 0 . 7 0 V a r i a b l e s : f i t t e d v a l u e s o f p r o f i t H o : C o n s t a n t v a r i a n c e B r e u s c h - P a g a n / C o o k - W e i s b e r g t e s t f o r h e t e r o s k e d a s t i c i t y . h e t t e s t Prob > chi2 = 0.4019 chi2(1) = 0.70 Variables: fitted values of profit Ho: Constant variance Breusch-Pagan / Cook-Weisberg test for heteroskedasticity . hettest T o t a l 2 2 . 9 6 8 0 . 0 0 3 4 K u r t o s i s 1 . 6 8 1 0 . 1 9 5 5 S k e w n e s s 7 . 0 7 2 0 . 0 2 9 2 H e t e r o s k e d a s t i c i t y 1 4 . 2 1 5 0 . 0 1 4 3 S o u r c e c h i 2 d f p C a m e r o n & T r i v e d i ' s d e c o m p o s i t i o n o f I M - t e s t P r o b > c h i 2 = 0 . 0 1 4 3 c h i 2 ( 5 ) = 1 4 . 2 1 a g a i n s t H a : u n r e s t r i c t e d h e t e r o s k e d a s t i c i t y W h i t e ' s t e s t f o r H o : h o m o s k e d a s t i c i t y . i m t e s t , w h i t e Total 22.96 8 0.0034Kurtosis 1.68 1 0.1955 Skewness 7.07 2 0.0292 Heteroskedasticity 14.21 5 0.0143 Source chi2 df p Cameron & Trivedi's decomposition of IM-test Prob > chi2 = 0.0143 chi2(5) = 14.21 against Ha: unrestricted heteroskedasticity White's test for Ho: homoskedasticity . imtest, white ( b i n = 1 0 , s t a r t = - 3 8 1 5 5 . 6 7 2 , w i d t h = 7 8 2 2 . 3 6 0 9 ) . h i s t o g r a m r e s i d u a l , n o r m a l (bin=10, start=-38155.672, width=7822.3609) . histogram residual, normal 0 1.0e-05 2.0e-05 3.0e-05 Density -40000-2000002000040000 Residuals -40000 -20000 0 20000 40000 Residuals -40000-2000002000040000 Inverse Normal 0.00 0.25 0.50 0.75 1.00 Normal F[(residual-m)/s] 0.000.250.500.751.00 Empirical P[i] = i/(N+1) r e s i d u a l 1 1 0 0 . 5 1 7 2 0 . 4 6 2 7 0 . 9 8 0 . 6 1 3 6 V a r i a b l e O b s P r ( S k e w n e s s ) P r ( K u r t o s i s ) a d j c h i 2 ( 2 ) P r o b > c h i 2 j o i n t S k e w n e s s / K u r t o s i s t e s t s f o r N o r m a l i t y . s k t e s t r e s i d u a l residual 110 0.5172 0.4627 0.98 0.6136 Variable Obs Pr(Skewness) Pr(Kurtosis) adj chi2(2) Prob>chi2 joint Skewness/Kurtosis tests for Normality . sktest residual r e s i d u a l 1 1 0 0 . 9 9 0 8 0 0 . 8 2 3 - 0 . 4 3 5 0 . 6 6 8 0 7 V a r i a b l e O b s W V z P r o b > z S h a p i r o - W i l k W t e s t f o r n o r m a l d a t a . s w i l k r e s i d u a l residual 110 0.99080 0.823 -0.435 0.66807 Variable Obs W V z Prob>z Shapiro-Wilk W test for normal data . swilk residual _ c o n s 3 6 5 8 1 . 6 7 6 9 3 6 . 7 8 0 . 4 8 0 . 6 3 5 - 1 1 5 9 3 6 . 6 1 8 9 0 9 9 . 8 _ h a t s q 9 . 4 0 e - 0 7 1 . 9 4 e - 0 6 0 . 4 8 0 . 6 3 0 - 2 . 9 2 e - 0 6 4 . 7 9 e - 0 6 _ h a t . 6 2 6 0 0 2 9 . 7 7 7 4 1 4 2 0 . 8 1 0 . 4 2 2 - . 9 1 5 1 3 0 1 2 . 1 6 7 1 3 6 p r o f i t C o e f . S t d . E r r . t P > | t | [ 9 5 % C o n f . I n t e r v a l ] T o t a l 7 . 7 4 0 2 e + 1 0 1 0 9 7 1 0 1 0 5 9 6 8 R o o t M S E = 1 6 4 0 3 A d j R - s q u a r e d = 0 . 6 2 1 1 R e s i d u a l 2 . 8 7 8 8 e + 1 0 1 0 7 2 6 9 0 4 4 8 0 8 R - s q u a r e d = 0 . 6 2 8 1 M o d e l 4 . 8 6 1 4 e + 1 0 2 2 . 4 3 0 7 e + 1 0 P r o b > F = 0 . 0 0 0 0 F ( 2 , 1 0 7 ) = 9 0 . 3 5 S o u r c e S S d f M S N u m b e r o f o b s = 1 1 0 . l i n k t e s t _cons 36581.6 76936.78 0.48 0.635 -115936.6 189099.8 _hatsq 9.40e-07 1.94e-06 0.48 0.630 -2.92e-06 4.79e-06 _hat .6260029 .7774142 0.81 0.422 -.9151301 2.167136 profit Coef. Std. Err. t P>|t| [95% Conf. Interval] Total 7.7402e+10 109 710105968 Root MSE = 16403 Adj R-squared = 0.6211 Residual 2.8788e+10 107 269044808 R-squared = 0.6281 Model 4.8614e+10 2 2.4307e+10 Prob > F = 0.0000 F( 2, 107) = 90.35 Source SS df MS Number of obs = 110 . linktest P r o b > F = 0 . 0 0 6 5 F ( 3 , 1 0 4 ) = 4 . 3 2 H o : m o d e l h a s n o o mi t t e d v a r i a b l e s R a m s e y R E S E T t e s t u s i n g p o w e r s o f t h e f i t t e d v a l u e s o f p r o f i t . o v t e s t Prob > F = 0.0065 F(3, 104) = 4.32 Ho: model has no omitted variables Ramsey RESET test using powers of the fitted values of profit . ovtest 0 .05 .1 .15 .2 Leverage 0.02.04.06 Normalized residual squared 150000 200000 250000 300000 Valores ajustados 150000200000250000300000 Profit Linear predictionFitted values o l d e r 0 . 7 7 4 0 - 0 . 5 5 3 9 0 . 9 3 8 0 0 . 8 6 6 7 1 . 0 0 0 0 c v d e a t h 0 . 6 0 9 2 - 0 . 5 4 9 9 0 . 8 5 2 5 1 . 0 0 0 0 s o c s e c u r i t y 0 . 6 6 7 8 - 0 . 5 8 4 5 1 . 0 0 0 0 b i r t h r a t e - 0 . 3 4 7 0 1 . 0 0 0 0 p r o f i t 1 . 0 0 0 0 p r o f i t b i r t h r ~ e s o c s e c ~ y c v d e a t h o l d e r ( o b s = 1 1 0 ) . c o r r p r o f i t b i r t h r a t e s o c s e c u r i t y c v d e a t h o l d e r older 0.7740 -0.5539 0.9380 0.8667 1.0000 cvdeath 0.6092 -0.5499 0.8525 1.0000 socsecurity 0.6678 -0.5845 1.0000 birthrate -0.3470 1.0000 profit 1.0000 profit birthr~e socsec~y cvdeath older (obs=110) . corr profit birthrate socsecurity cvdeath older N o t e : N = O b s u s e d i n c a l c u l a t i n g B I C ; s e e [ R ] B I C n o t e . 1 1 0 - 1 2 7 6 . 5 3 2 - 1 2 2 0 . 7 0 9 5 2 4 5 1 . 4 1 8 2 4 6 4 . 9 2 M o d e l O b s l l ( n u l l ) l l ( m o d e l ) d f A I C B I C . e s t a t i c _ c o n s 1 0 7 0 0 2 . 4 1 6 3 4 4 . 4 3 6 . 5 5 0 . 0 0 0 7 4 5 9 4 . 4 1 1 3 9 4 1 0 . 4 o l d e r 1 0 6 0 9 . 4 7 1 4 6 2 . 0 4 2 7 . 2 6 0 . 0 0 0 7 7 1 0 . 5 0 6 1 3 5 0 8 . 4 3 c v d e a t h - 4 9 . 6 9 9 2 9 3 6 . 2 9 4 1 1 - 1 . 3 7 0 . 1 7 4 - 1 2 1 . 6 6 3 8 2 2 . 2 6 5 2 3 s o c s e c u r i t y - 2 8 1 . 9 0 8 2 1 2 6 . 7 9 4 6 - 2 . 2 2 0 . 0 2 8 - 5 3 3 . 3 1 8 5 - 3 0 . 4 9 8 0 2 b i r t h r a t e 5 7 0 . 1 9 3 2 6 4 7 . 9 8 1 4 0 . 8 8 0 . 3 8 1 - 7 1 4 . 6 3 4 2 1 8 5 5 . 0 2 1 p r o f i t C o e f . S t d . E r r . t P > | t | [ 9 5 % C o n f . I n t e r v a l ] T o t a l 7 . 7 4 0 2 e + 1 0 1 0 9 7 1 0 1 0 5 9 6 8 R o o t M S E = 1 6 3 4 5 A d j R - s q u a r e d = 0 . 6 2 3 8 R e s i d u a l 2 . 8 0 5 2 e + 1 0 1 0 5 2 6 7 1 5 8 0 7 0 R - s q u a r e d = 0 . 6 3 7 6 M o d e l 4 . 9 3 5 0 e + 1 0 4 1 . 2 3 3 7 e + 1 0 P r o b > F = 0 . 0 0 0 0 F ( 4 , 1 0 5 ) = 4 6 . 1 8 S o u r c e S S d f M S N u m b e r o f o b s = 1 1 0 . r e g r e s s p r o f i t b i r t h r a t e s o c s e c u r i t y c v d e a t h o l d e r Note: N=Obs used in calculating BIC; see [R] BIC note . 110 -1276.532 -1220.709 5 2451.418 2464.92 Model Obs ll(null) ll(model) df AIC BIC . estat ic _cons 107002.4 16344.43 6.55 0.000 74594.41 139410.4 older 10609.47 1462.042 7.26 0.000 7710.506 13508.43 cvdeath -49.69929 36.29411 -1.37 0.174 -121.6638 22.26523 socsecurity -281.9082 126.7946 -2.220.028 -533.3185 -30.49802 birthrate 570.1932 647.9814 0.88 0.381 -714.6342 1855.021 profit Coef. Std. Err. t P>|t| [95% Conf. Interval] Total 7.7402e+10 109 710105968 Root MSE = 16345 Adj R-squared = 0.6238 Residual 2.8052e+10 105 267158070 R-squared = 0.6376 Model 4.9350e+10 4 1.2337e+10 Prob > F = 0.0000 F( 4, 105) = 46.18 Source SS df MS Number of obs = 110 . regress profit birthrate socsecurity cvdeath older P r o b > F = 0 . 2 2 8 9 F ( 2 , 1 0 5 ) = 1 . 5 0 ( 2 ) c v d e a t h = 0 ( 1 ) b i r t h r a t e = 0 . t e s t b i r t h r a t e c v d e a t h Prob > F = 0.2289 F( 2, 105) = 1.50 ( 2) cvdeath = 0 ( 1) birthrate = 0 . test birthrate cvdeath
Compartir