------------------------------------------------------------------------------- log: C:\Stata8\lab20oct.smcl log type: smcl opened on: 20 Oct 2004, 09:57:44 use "C:\Documents and Settings\computob\Escritorio\Wage1.dta", clear summ desc reg wage educ Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 1, 524) = 103.36 Model | 1179.73204 1 1179.73204 Prob > F = 0.0000 Residual | 5980.68225 524 11.4135158 R-squared = 0.1648 -------------+------------------------------ Adj R-squared = 0.1632 Total | 7160.41429 525 13.6388844 Root MSE = 3.3784 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .5413593 .053248 10.17 0.000 .4367534 .6459651 _cons | -.9048516 .6849678 -1.32 0.187 -2.250472 .4407687 ------------------------------------------------------------------------------ summ wage Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- wage | 526 5.896103 3.693086 .53 24.98 ** ¿En qué porcentaje aumenta mi ingreso por cada año de educacion? . disp .54/5.89 .09168081 . reg wage educ exper tenure nonwhite female married numdep smsa Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 8, 517) = 39.99 Model | 2737.14784 8 342.14348 Prob > F = 0.0000 Residual | 4423.26645 517 8.5556411 R-squared = 0.3823 -------------+------------------------------ Adj R-squared = 0.3727 Total | 7160.41429 525 13.6388844 Root MSE = 2.925 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .5426762 .0526149 10.31 0.000 .439311 .6460414 exper | .0237285 .0121715 1.95 0.052 -.0001832 .0476402 tenure | .1342328 .0210046 6.39 0.000 .0929679 .1754978 nonwhite | -.1112358 .4238659 -0.26 0.793 -.9439471 .7214754 female | -1.785142 .2647681 -6.74 0.000 -2.305295 -1.264988 married | .544262 .2941563 1.85 0.065 -.0336266 1.122151 numdep | .1589618 .1080496 1.47 0.142 -.0533086 .3712321 smsa | .9289924 .2950604 3.15 0.002 .3493277 1.508657 _cons | -2.311886 .7830899 -2.95 0.003 -3.850315 -.7734562 ------------------------------------------------------------------------------ . . disp -1.785142*11.25 -20.082848 . reg wage educ exper tenure nonwhite female married numdep northcen south wes > t Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 10, 515) = 32.30 Model | 2760.16783 10 276.016783 Prob > F = 0.0000 Residual | 4400.24646 515 8.54416789 R-squared = 0.3855 -------------+------------------------------ Adj R-squared = 0.3735 Total | 7160.41429 525 13.6388844 Root MSE = 2.923 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .5661935 .0518269 10.92 0.000 .4643753 .6680117 exper | .0230445 .0121638 1.89 0.059 -.0008524 .0469413 tenure | .1357401 .0210177 6.46 0.000 .0944491 .177031 nonwhite | -.0770365 .4258312 -0.18 0.857 -.9136162 .7595433 female | -1.802005 .2650377 -6.80 0.000 -2.322693 -1.281317 married | .5085083 .2936322 1.73 0.084 -.0683559 1.085373 numdep | .1406064 .1081616 1.30 0.194 -.0718859 .3530987 northcen | -.6158596 .3715025 -1.66 0.098 -1.345706 .1139871 south | -.635872 .3484845 -1.82 0.069 -1.320498 .048754 west | .5483335 .4114424 1.33 0.183 -.2599785 1.356645 _cons | -1.598936 .81631 -1.96 0.051 -3.202643 .004771 ------------------------------------------------------------------------------ . reg wage educ exper tenure nonwhite female married numdep smsa construc ndu > rman trcommpu trade services profserv profocc clerocc servocc Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 17, 508) = 25.40 Model | 3289.6116 17 193.506565 Prob > F = 0.0000 Residual | 3870.80269 508 7.61969033 R-squared = 0.4594 -------------+------------------------------ Adj R-squared = 0.4413 Total | 7160.41429 525 13.6388844 Root MSE = 2.7604 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .3686201 .0583941 6.31 0.000 .2538964 .4833438 exper | .0134506 .0117101 1.15 0.251 -.0095556 .0364568 tenure | .1166532 .0202095 5.77 0.000 .0769488 .1563577 nonwhite | -.0508945 .4062449 -0.13 0.900 -.8490213 .7472323 female | -1.539117 .2798607 -5.50 0.000 -2.088944 -.9892904 married | .4010859 .282264 1.42 0.156 -.1534626 .9556344 numdep | .1483694 .1028095 1.44 0.150 -.0536147 .3503535 smsa | .8136026 .2840957 2.86 0.004 .2554555 1.37175 construc | -.6822687 .6511 -1.05 0.295 -1.961449 .5969114 ndurman | -1.092578 .4777284 -2.29 0.023 -2.031145 -.1540114 trcommpu | -1.200208 .6729804 -1.78 0.075 -2.522376 .1219591 trade | -2.240469 .4047426 -5.54 0.000 -3.035645 -1.445294 services | -1.805122 .5157804 -3.50 0.001 -2.818447 -.7917965 profserv | -1.064929 .4448272 -2.39 0.017 -1.938857 -.1910022 profocc | 1.895619 .3665917 5.17 0.000 1.175396 2.615841 clerocc | .2298437 .4319353 0.53 0.595 -.6187557 1.078443 servocc | -.2905201 .4306045 -0.67 0.500 -1.136505 .5554648 _cons | .8123524 .8476453 0.96 0.338 -.8529694 2.477674 ------------------------------------------------------------------------------ . corr wage lwage (obs=526) | wage lwage -------------+------------------ wage | 1.0000 lwage | 0.9371 1.0000 . reg wage educ exper tenure nonwhite female married numdep smsa Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 8, 517) = 39.99 Model | 2737.14784 8 342.14348 Prob > F = 0.0000 Residual | 4423.26645 517 8.5556411 R-squared = 0.3823 -------------+------------------------------ Adj R-squared = 0.3727 Total | 7160.41429 525 13.6388844 Root MSE = 2.925 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .5426762 .0526149 10.31 0.000 .439311 .6460414 exper | .0237285 .0121715 1.95 0.052 -.0001832 .0476402 tenure | .1342328 .0210046 6.39 0.000 .0929679 .1754978 nonwhite | -.1112358 .4238659 -0.26 0.793 -.9439471 .7214754 female | -1.785142 .2647681 -6.74 0.000 -2.305295 -1.264988 married | .544262 .2941563 1.85 0.065 -.0336266 1.122151 numdep | .1589618 .1080496 1.47 0.142 -.0533086 .3712321 smsa | .9289924 .2950604 3.15 0.002 .3493277 1.508657 _cons | -2.311886 .7830899 -2.95 0.003 -3.850315 -.7734562 ------------------------------------------------------------------------------ ** Obteniendo los valores predichos de la regresion (fitted values) . predict wagehat, xb . summ wage* Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- wage | 526 5.896103 3.693086 .53 24.98 wagehat | 526 5.896103 2.283334 -2.238245 12.97349 ** ... tienen la misma media, pero diferente desv. est... ** Graficando la prediccion... graph twoway scatter wage wagehat educ ** Obteniendo los residuales de la regresion . predict residuales, resid . summ res Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- residuales | 526 7.08e-10 2.902631 -6.82883 14.03759 ** ...tienen media = cero... ** Los residuales son “independientes” de las variables explicativas: . gen xres = educ*residuales . summ xres Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- xres | 526 5.30e-08 41.0189 -95.60362 247.7911 . gen xres2 = exper*residuales . summ xres* Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- xres | 526 5.30e-08 41.0189 -95.60362 247.7911 xres2 | 526 1.10e-07 66.68783 -279.982 422.1729 ** Los residuales son “independientes” de los valores predichos: . gen yres = wagehat*residuales . summ *res Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- xres | 526 5.30e-08 41.0189 -95.60362 247.7911 yres | 526 -5.64e-08 23.10927 -68.85031 155.7663 ** ¿Qué pasa si omito la constante de la regresion? . reg wage educ exper tenure nonwhite female married numdep smsa, nocons Source | SS df MS Number of obs = 526 -------------+------------------------------ F( 8, 518) = 301.57 Model | 20948.4563 8 2618.55703 Prob > F = 0.0000 Residual | 4497.83609 518 8.68308125 R-squared = 0.8232 -------------+------------------------------ Adj R-squared = 0.8205 Total | 25446.2924 526 48.3769817 Root MSE = 2.9467 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .4070849 .0258604 15.74 0.000 .3562808 .457889 exper | .0073127 .0109075 0.67 0.503 -.0141157 .0287411 tenure | .1373257 .0211342 6.50 0.000 .0958065 .1788449 nonwhite | -.2399903 .4247447 -0.57 0.572 -1.074424 .5944437 female | -1.960969 .2598971 -7.55 0.000 -2.471551 -1.450387 married | .5747046 .2961569 1.94 0.053 -.0071116 1.156521 numdep | .0440528 .1015436 0.43 0.665 -.1554352 .2435408 smsa | .8116992 .2945428 2.76 0.006 .233054 1.390344 ------------------------------------------------------------------------------ ** ... La R-2 aumenta artificalmente, pues estamos forzando la regresion a partir ** del "origen" y a ignorar el efecto de la media de la variable dependiente. . clear . use "C:\Documents and Settings\computob\Escritorio\Bwght.dta", clear . desc ** Renombrando una variable: . ren bwght peso . reg peso cigs Source | SS df MS Number of obs = 1388 -------------+------------------------------ F( 1, 1386) = 32.24 Model | 13060.4194 1 13060.4194 Prob > F = 0.0000 Residual | 561551.3 1386 405.159668 R-squared = 0.0227 -------------+------------------------------ Adj R-squared = 0.0220 Total | 574611.72 1387 414.283864 Root MSE = 20.129 ------------------------------------------------------------------------------ peso | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.5137721 .0904909 -5.68 0.000 -.6912861 -.3362581 _cons | 119.7719 .5723407 209.27 0.000 118.6492 120.8946 ------------------------------------------------------------------------------ . reg peso packs Source | SS df MS Number of obs = 1388 -------------+------------------------------ F( 1, 1386) = 32.24 Model | 13060.4194 1 13060.4194 Prob > F = 0.0000 Residual | 561551.3 1386 405.159668 R-squared = 0.0227 -------------+------------------------------ Adj R-squared = 0.0220 Total | 574611.72 1387 414.283864 Root MSE = 20.129 ------------------------------------------------------------------------------ peso | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- packs | -10.27544 1.809819 -5.68 0.000 -13.82572 -6.725162 _cons | 119.7719 .5723407 209.27 0.000 118.6492 120.8946 ------------------------------------------------------------------------------ . reg bwghtlbs packs Source | SS df MS Number of obs = 1388 -------------+------------------------------ F( 1, 1386) = 32.24 Model | 51.0172634 1 51.0172634 Prob > F = 0.0000 Residual | 2193.55977 1386 1.58265495 R-squared = 0.0227 -------------+------------------------------ Adj R-squared = 0.0220 Total | 2244.57703 1387 1.61829634 Root MSE = 1.258 ------------------------------------------------------------------------------ bwghtlbs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- packs | -.6422151 .1131137 -5.68 0.000 -.8641076 -.4203226 _cons | 7.485744 .0357713 209.27 0.000 7.415572 7.555915 ------------------------------------------------------------------------------ ** ¿Cuanto pesara un bebe si la mama fuma 2 cajetillas? . disp 2*-.6422 + 7.48 6.1956 . reg bwghtlbs cigs faminc fatheduc motheduc parity male white Source | SS df MS Number of obs = 1191 -------------+------------------------------ F( 7, 1183) = 9.67 Model | 102.082587 7 14.5832267 Prob > F = 0.0000 Residual | 1783.64668 1183 1.50773176 R-squared = 0.0541 -------------+------------------------------ Adj R-squared = 0.0485 Total | 1885.72927 1190 1.58464644 Root MSE = 1.2279 ------------------------------------------------------------------------------ bwghtlbs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0373816 .0068584 -5.45 0.000 -.0508375 -.0239257 faminc | .0027353 .0023111 1.18 0.237 -.0017989 .0072695 fatheduc | .0257042 .017563 1.46 0.144 -.0087539 .0601623 motheduc | -.0205227 .0198663 -1.03 0.302 -.0594997 .0184544 parity | .1197428 .0409619 2.92 0.004 .0393767 .200109 male | .2372211 .0714173 3.32 0.001 .0971024 .3773399 white | .2945917 .1004828 2.93 0.003 .0974473 .491736 _cons | 6.813988 .2460986 27.69 0.000 6.33115 7.296827 ------------------------------------------------------------------------------ . reg cigs faminc *educ cigprice cigtax Source | SS df MS Number of obs = 1191 -------------+------------------------------ F( 5, 1185) = 13.72 Model | 1859.88558 5 371.977116 Prob > F = 0.0000 Residual | 32121.6174 1185 27.1068501 R-squared = 0.0547 -------------+------------------------------ Adj R-squared = 0.0507 Total | 33981.5029 1190 28.5558848 Root MSE = 5.2064 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- faminc | -.0187592 .0097368 -1.93 0.054 -.0378624 .000344 fatheduc | -.104299 .0744393 -1.40 0.161 -.2503466 .0417485 motheduc | -.3468991 .0833427 -4.16 0.000 -.5104148 -.1833834 cigprice | -.0141586 .0312008 -0.45 0.650 -.0753737 .0470564 cigtax | .04186 .0409706 1.02 0.307 -.0385231 .1222431 _cons | 9.332524 3.490324 2.67 0.008 2.48462 16.18043 ------------------------------------------------------------------------------ . log close log: C:\Stata8\lab20oct.smcl log type: smcl closed on: 20 Oct 2004, 10:59:36 -------------------------------------------------------------------------------