Sunteți pe pagina 1din 4

UNIVERSIDAD NACIONAL DEL ALTIPLANO

FACULTAD DE INGENIERIA ECONOMICA


CURSO : ECONOMETRIA II
Profesor : Dr. Alfredo Pelayo Calatayud Mendoza

PRACTICA DIRIGIDA N 1

Tema: Estimacin de modelos lineales por MCO y MV


Considere la siguiente base de datos de corte transversal:
obs y x1 x2
1 1 23 87
2 2 21 67
3 3 45 45
4 4 65 34
5 1 67 78
6 2 54 98
7 3 32 67
8 4 43 43
9 5 76 23
10 6 87 45

Se pide:
Estimar el modelo lineal por MCO y MV:
Yi 0 1 X 1i 1 X 2i i
a. Solver
b. Stata (comando regre y en el ambiente mata)
c. E-Views (ventana program con el comando LS)
d. SPSS

1. E-Views
File \ New\Program

open "h:\datos1.wf1"

'''''''''''''''''''''' ESTIMACION DE MODELO LINEAL'''''''''''''''''''''''''''''''''''

LS y=c(1)+c(2)*x1+c(3)*x2

''''Para graficar""""""

scat x1 y

2. Stata

Window\Do-file-Editor\New Do-fiel Editor


****Regresin lineal*****
use "H:\Carabaya\datos1.dta" , clear
regre y x1 x2
estimates store Modelo
estimate table Modelo, star(0.01 0.05 0.1) stat(r2, F)
sum y x1 x2
twoway (scatter y x1)
2

a. Minimos Cuadrados Ordinarios (MCO)

*MODELO DE REGRESION LINEAL* METODO DE MCO


use "H:\Carabaya\datos1.dta" , clear
gen cons=1
mata
mata clear
st_view(y=., ., "y")
st_view(X=., ., ("x1", "x2", "cons"))
b=invsym(X'X)*X'y
b
e = y:-X*b
n = rows(X)
k = cols(X)
s2= (e'e)/(n-k)
V = s2*invsym(X'X)
V
se = sqrt(diagonal(V))
(b, se)
(b, se, b:/se)
(b, se, b:/se, 2*ttail(n-k, abs(b:/se)))
end

b. Mtodo de Mxima Verosimilitud (MV)

use "D:\Curso_stata_basico\Datos\Datos_generales.dta", clear


mata
mata clear
function linregeval(transmorphic M, real rowvector b,real colvector lnf)
{
real colvector p1, p2
real colvector y1
p1 = moptimize_util_xb(M, b,1)
p2 = moptimize_util_xb(M, b, 2)
y1 = moptimize_util_depvar(M, 1)
lnf = ln(normalden(y1:-p1, 0, sqrt(p2)))
}
M = moptimize_init()
moptimize_init_evaluator(M, &linregeval())
moptimize_init_depvar(M, 1, "y")
moptimize_init_eq_indepvars(M, 1,"x1 x2")
moptimize_init_eq_cons(M, 1, "on")
moptimize_init_eq_indepvars(M, 2, "")
moptimize(M)
moptimize_result_display(M)
end
3

3. SPSS

Archivo\Nuevo\Sintaxis

GET
FILE='H:\datos.sav'.
REGRESSION
/DEPENDENT y
/METHOD=ENTER x1 x2

DESCRIPTIVES VARIABLES=y x1 x2
/STATISTICS=MEAN STDDEV VARIANCE RANGE MIN MAX KURTOSIS SKEWNESS.

GRAPH
/SCATTERPLOT(BIVAR)=x1 WITH y
/MISSING=LISTWISE.

Interprete 1 y 2 de acuerdo a la teora econmica.


regre y x1 x2

Source | SS df MS Number of obs = 10


-------------+------------------------------ F( 2, 7) = 10.11
Model | 18.4964539 2 9.24822694 Prob > F = 0.0086
Residual | 6.40354612 7 .914792303 R-squared = 0.7428
-------------+------------------------------ Adj R-squared = 0.6694
Total | 24.9 9 2.76666667 Root MSE = .95645

------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | .0248607 .0160688 1.55 0.166 -.0131359 .0628573
x2 | -.0445007 .0147631 -3.01 0.020 -.0794099 -.0095916
_cons | 4.436842 1.479147 3.00 0.020 .9392158 7.934467
------------------------------------------------------------------------------

Dependent Variable: Y
Method: Least Squares
Date: 10/01/15 Time: 13:28
Sample: 1 10
Included observations: 10
Y=C(1)+C(2)*X1+C(3)*X2

Coefficient Std. Error t-Statistic Prob.

C(1) 4.436842 1.479147 2.999596 0.0200


C(2) 0.024861 0.016069 1.547142 0.1658
C(3) -0.044501 0.014763 -3.014326 0.0195

R-squared 0.742829 Mean dependent var 3.100000


Adjusted R-squared 0.669352 S.D. dependent var 1.663330
S.E. of regression 0.956448 Akaike info criterion 2.992144
Sum squared resid 6.403546 Schwarz criterion 3.082919
Log likelihood -11.96072 Hannan-Quinn criter. 2.892563
F-statistic 10.10965 Durbin-Watson stat 1.562472
Prob(F-statistic) 0.008625
4

S-ar putea să vă placă și