Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Alumno:
Carlos Yalta
Profesor:
Rafael Caparo
3 de mayo de 2015
Resumen
El presente trabajo tiene como objetivo determinar la mejor predicci
on de un portafolio con tres activos, una serie financiera de renta
variable y un commodity. La primera parte consiste en obtener los mejores modelos para los precios de los activos, seg
un la metodologa Box Jenkins, pasando luego a estudiar la varianza condicional con un modelo
GARCH. La ultima parte tienen como materia de estudio el poder de
predicci
on y acercamiento de los modelos para poder establecer planes
de acci
on frente a las variaciones aleatorios propias de la incertidumbre.
1.
Serie financiera
Pt
)
Pt1
2.
Serie Agrcola
10
15
16
mnimos de los retornos en base a los intervalos de confianza. Finalmente comparando la muestra observada con la predecida, se tiene un comportamiento
similar pero sigue siendo lejano a los valores reales.
3.
Anexos
seriefinanciera.m
clear , c l c ;
2
3
4
5
6
7
8
% A n a l i s i s de p r e c i o s de l a s a c c i o n e s de Apple
y=yahoo ;
q u o t e s={ AAPL } ;
f e c h a i n i c i o = 1/1/2000 ;
f e c h a f i n = 1/1/2015 ;
A=f e t c h ( y , q u o t e s { 1 } , { Adj C l o s e } , f e c h a i n i c i o , f e c h a f i n , m ) ;
9
10
11
tiempo = A( : , 1 ) ;
p r e c i o = A( : , 2 ) ;
12
13
14
15
16
17
18
19
20
21
22
% G r a f i c a de l a f u n c i
on financiera
figure (1)
plot ( tiempo , p r e c i o , b , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( P r e c i o Ajustado , F o n t s i z e , 1 0 ) ;
legend ( Apple , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
title ( Precios Hist
o r i c o s de Apple I n c . , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
23
24
25
26
27
28
29
% Correlograma p r e c i o
figure (2)
subplot ( 2 , 1 , 1 ) ;
autocorr ( precio ,36) ;
subplot ( 2 , 1 , 2 ) ;
parcorr ( precio ,36) ;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Gra
f i c a de l a primera d i f e r e n c i a
figure (3)
d p r e c i o = zeros ( 1 8 0 , 1 ) ;
f o r k =1:179
d p r e c i o ( k )=p r e c i o ( k+1)p r e c i o ( k ) ;
end
plot ( tiempo , d p r e c i o , r , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( \ D e l t a ( P r e c i o Ajustado ) , F o n t s i z e , 1 0 ) ;
legend ( \ DeltaApple , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
t i t l e ( Primera d i f e r e n c i a d e l P r e c i o , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
45
17
46
47
48
49
50
51
% Correlograma primera d i f e r e n c i a p r e c i o
figure (4)
subplot ( 2 , 1 , 1 ) ;
autocorr ( dprecio ,36) ;
subplot ( 2 , 1 , 2 ) ;
parcorr ( dprecio ,36) ;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% FORECAST PRECIO
% separamos l a d a t a 80 % 20 %
t 1 = zeros ( 1 4 4 , 1 ) ;
p1 = zeros ( 1 4 4 , 1 ) ;
t 2 = zeros ( 3 6 , 1 ) ;
p2 = zeros ( 3 6 , 1 ) ;
76
77
78
t 1 ( 1 : 1 4 4 , 1 ) = tiempo ( 1 8 0 : 1 : 3 7 , 1 ) ;
t 2 ( 1 : 3 6 , 1 ) = tiempo ( 3 6 : 1 : 1 , 1 ) ;
79
80
81
p1 ( 1 : 1 4 4 , 1 ) = p r e c i o ( 1 8 0 : 1 : 3 7 , 1 ) ;
p2 ( 1 : 3 6 , 1 ) = p r e c i o ( 3 6 : 1 : 1 , 1 ) ;
82
83
84
85
86
87
% C
aclulo del f orec ast
yt1 = s i m u l a t e ( estmdl , 3 6 , numPaths , 1 0 0 0 , Y0 , p1 ) ;
mn1 = mean( yt1 , 2 ) ;
lowp = p r c t i l e ( yt1 , 2 . 5 , 2 ) ;
upp = p r c t i l e ( yt1 , 9 7 . 5 , 2 ) ;
88
89
90
91
92
93
94
95
96
97
98
99
100
101
% Gra
fica
figure (6)
h1 = plot ( t1 , p1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
hold on
h2 = plot ( t2 , mn1 , b , LineWidth , 2 ) ;
h3 = plot ( t2 , upp , k , LineWidth , 1 . 5 ) ;
plot ( t2 , lowp , k , LineWidth , 1 . 5 ) ;
d a t e t i c k ( x , mmmyy ) ;
legend ( [ h1 , h2 , h3 ] , A d j P r i c e , F o r e c a s t , . . .
18
102
103
104
F o r e c a s t I n t e r v a l , L o c a t i o n , Northwest )
t i t l e ( F o r e c a s t Adj P r i c e Apple i n c . )
hold o f f
105
106
107
108
% Validadndo d a t o s p r e d e c i d o s
error = abs ( ( yFp2 ) . / p2 ) . 1 0 0 ;
v a l i d o = 100error ;
109
110
111
mvalido = mean( v a l i d o ) ;
myF = mean( yF ) ;
112
113
114
115
116
117
N=[yF p2 v a l i d o ] ;
fprintf (
Tabla de v a l i d a c i o n de d a t o s
\n ) ;
f p r i n t f ( ===================================\n ) ;
fprintf ( Forecast
Muestra
V a l i d a c i o n
\n ) ;
disp (N) ;
118
119
120
121
122
123
124
125
126
127
figure (7)
subplot ( 2 , 1 , 1 ) ;
h4 = plot ( t2 , p2 , t2 , mn1) ;
d a t e t i c k ( x , mmmyy ) ;
set ( h4 ( 1 ) , L i n e S t y l e , , C o l o r , b ) ;
legend ( Adj P r i c e , F o r e c a s t , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
t i t l e ( Muestra o b s e r v a d a vs . F o r e c a s t )
grid on
128
129
130
131
132
133
134
135
subplot ( 2 , 1 , 2 ) ;
h5 = plot ( t2 , v a l i d o ) ;
d a t e t i c k ( x , mmmyyyy ) ;
legend ( V
a l i d o ( %) , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
title ( Validaci
o n de d a t o s ( en p o r c e n t a j e ) ) ;
grid on
136
137
138
139
140
%% % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%MODELO GARCH RETORNOS
r = price2ret ( precio ) ;
141
142
143
144
145
146
147
148
149
150
151
figure (8)
subplot ( 2 , 1 , 1 ) ;
plot ( tiempo , p r e c i o , b , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( P r e c i o Ajustado , F o n t s i z e , 1 0 ) ;
legend ( Apple , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
title ( Precios Hist
o r i c o s de Apple I n c . , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
152
153
154
155
156
157
subplot ( 2 , 1 , 2 ) ;
plot ( tiempo ( 1 8 0 : 1 : 2 ) , r , k , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( Retornos , F o n t s i z e , 1 0 ) ;
legend ( R t , O r i e n t a t i o n , H o r i z o n t a l , . . .
19
158
159
160
161
L o c a t i o n , NorthWest ) ;
t i t l e ( Retornos de Apple I n c . , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
162
163
164
165
% E s p e c i f i c a n d o e l modelo ARIMAGARCH
mdl1 = arima ( ARLags , 1 , D , 1 , MALags , 2 , V a r i a n c e , g a r c h ( 1 , 1 ) ) ;
e s t m d l 1 = e s t i m a t e ( mdl1 , r ) ;
166
167
168
169
170
171
172
173
174
175
176
% Bondad de a j u s t e
figure (9)
r e s 1 = i n f e r ( estmdl1 , r ) ;
t i t l e ( Residuos Estandarizados )
subplot ( 3 , 1 , 1 )
qqplot ( res1 )
subplot ( 3 , 1 , 2 )
autocorr ( res1 , 3 6 )
subplot ( 3 , 1 , 3 )
parcorr ( res1 , 3 6 )
177
178
179
180
181
182
183
% FORECAST RETORNO
% separamos l a d a t a 80 % 20 %
t r 1 = zeros ( 1 4 3 , 1 ) ;
r 1 = zeros ( 1 4 3 , 1 ) ;
t r 2 = zeros ( 3 6 , 1 ) ;
r 2 = zeros ( 3 6 , 1 ) ;
184
185
186
t r 1 ( 1 : 1 4 3 , 1 ) = tiempo ( 3 7 : 1 : 1 7 9 , 1 ) ;
t r 2 ( 1 : 3 6 , 1 ) = tiempo ( 3 6 : 1 : 1 , 1 ) ;
187
188
189
190
191
192
193
194
195
196
197
% C
aclulo del f orec ast
yt=s i m u l a t e ( estmdl1 , 3 6 , numPaths , 1 0 0 , Y0 , r 1 ) ;
[ rF , rMSE ] = f o r e c a s t ( estmdl1 , 3 6 , Y0 , yt ) ;
% I n t e r v a l o de c o n f i a n z a y promedio de l a s i m u l a c i
on
mn = mean( yt , 2 ) ;
low = p r c t i l e ( yt , 2 . 5 , 2 ) ;
up = p r c t i l e ( yt , 9 7 . 5 , 2 ) ;
198
199
200
201
202
203
204
205
% Gra
fica simulaci
on
figure (10)
plot ( t r 1 , r1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
hold on
plot ( t r 2 , yt ) ;
d a t e t i c k ( x , mmmyy ) ;
t i t l e ( Simulaci
o n de Retornos Apple i n c . , F o n t s i z e , 1 5 )
206
207
208
209
210
211
212
213
% Gra
f i c a de
figure (11)
h6 = plot ( t r 1
hold on
h7 = plot ( t r 2
h8 = plot ( t r 2
plot ( t r 2 , low ,
la prediccio
n forecast
, r1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
, mn, b , LineWidth , 2 ) ;
, up , k , LineWidth , 1 . 5 ) ;
k , LineWidth , 1 . 5 ) ;
20
214
215
216
217
218
d a t e t i c k ( x , mmmyy ) ;
legend ( [ h6 , h7 , h8 ] , Retorno R t , F o r e c a s t , . . .
F o r e c a s t I n t e r v a l , L o c a t i o n , Northwest )
t i t l e ( F o r e c a s t Retornos Apple i n c . , F o n t s i z e , 1 5 )
hold o f f
219
220
221
222
% Validadndo d a t o s p r e d e c i d o s
e r r o r r = ( abs ( r 2 )abs (mn) ) . / abs ( r 2 ) . 1 0 0 ;
v a l i d o r = 100 e r r o r r ;
223
224
225
m v a l i d o r = mean( v a l i d o r ) ;
mrF = mean(mn) ;
226
227
228
229
230
231
N1=[mn r 2 v a l i d o r ] ;
fprintf (
Tabla de v a l i d a c i o n de d a t o s
\n ) ;
f p r i n t f ( ===================================\n ) ;
fprintf ( Forecast
Muestra
V a l i d a c i o n
\n ) ;
disp (N1) ;
232
233
234
235
236
237
238
239
240
241
242
% Gra
f i c a aumentada d e l f o r e c a s t v s v a l o r e s o b s e r v a d o s
figure (12)
subplot ( 2 , 1 , 1 ) ;
h9 = plot ( t r 2 , r2 , t r 2 ,mn) ;
d a t e t i c k ( x , mmmyy ) ;
set ( h9 ( 2 ) , L i n e S t y l e , , LineWidth , 1 . 5 ) ;
legend ( Retorno R t , F o r e c a s t , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
t i t l e ( Muestra o b s e r v a d a vs . F o r e c a s t )
grid on
243
244
245
246
247
248
249
250
subplot ( 2 , 1 , 2 ) ;
h10 = plot ( t2 , v a l i d o r ) ;
d a t e t i c k ( x , mmmyyyy ) ;
legend ( V
a l i d o ( %) , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
title ( Validaci
o n de d a t o s ( en p o r c e n t a j e ) ) ;
grid on
serieagricola.m
1
clear , c l c ;
2
3
4
5
6
7
% % L e c t u r a de d a t o s d e s d e l i b r o e x c e l
DATA = x l s r e a d ( p r e c i o p a p a y u n g a y , 1 , A2 : B93 ) ;
8
9
10
11
% Separaci
o n de s e r i e s
tiempo = DATA( : , 1 ) ;
p r e c i o = DATA( : , 2 ) ;
12
13
14
15
% G r a f i c a de l o s p r e c i o s d i a r i o s de l a papa Yungay
figure (1)
plot ( tiempo , p r e c i o , b , LineWidth , 1 ) ;
21
16
17
18
19
20
21
22
d a t e t i c k ( x , ddmmmyy ) ;
ylabel ( P r e c i o S / . por kg , F o n t s i z e , 1 0 ) ;
legend ( Papa Yungay , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
t i t l e ( P r e c i o s d i a r i o s a l Mayorista , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Gra
f i c a de l a primera d i f e r e n c i a
figure (3)
d p r e c i o = zeros ( 9 2 , 1 ) ;
f o r k =1:91
d p r e c i o ( k )=p r e c i o ( k+1)p r e c i o ( k ) ;
end
plot ( tiempo , d p r e c i o , r , LineWidth , 1 ) ;
d a t e t i c k ( x , ddmmmyy ) ;
ylabel ( \ D e l t a ( P r e c i o ) , F o n t s i z e , 1 0 ) ;
legend ( \ DeltaPapa Yungay , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
t i t l e ( Primera d i f e r e n c i a d e l P r e c i o , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
45
46
47
48
49
50
51
% Correlograma primera d i f e r e n c i a p r e c i o
figure (4)
subplot ( 2 , 1 , 1 ) ;
autocorr ( dprecio ,36) ;
subplot ( 2 , 1 , 2 ) ;
parcorr ( dprecio ,36) ;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
22
72
73
74
75
t1
p1
t2
p2
=
=
=
=
zeros ( 7 4 , 1 ) ;
zeros ( 7 4 , 1 ) ;
zeros ( 1 8 , 1 ) ;
zeros ( 1 8 , 1 ) ;
76
77
78
t 1 ( 1 : 7 4 , 1 ) = tiempo ( 1 : 7 4 , 1 ) ;
t 2 ( 1 : 1 8 , 1 ) = tiempo ( 7 5 : 9 2 , 1 ) ;
79
80
81
p1 ( 1 : 7 4 , 1 ) = p r e c i o ( 1 : 7 4 , 1 ) ;
p2 ( 1 : 1 8 , 1 ) = p r e c i o ( 7 5 : 9 2 , 1 ) ;
82
83
84
85
86
87
% C
aclulo del f orec ast
yt1 = s i m u l a t e ( estmdl , 1 8 , numPaths , 1 0 0 0 , Y0 , p1 ) ;
mn1 = mean( yt1 , 2 ) ;
lowp = p r c t i l e ( yt1 , 2 . 5 , 2 ) ;
upp = p r c t i l e ( yt1 , 9 7 . 5 , 2 ) ;
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
% Gra
fica
figure (6)
h1 = plot ( t1 , p1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
hold on
h2 = plot ( t2 , mn1 , b , LineWidth , 2 ) ;
h3 = plot ( t2 , upp , k , LineWidth , 1 . 5 ) ;
plot ( t2 , lowp , k , LineWidth , 1 . 5 ) ;
d a t e t i c k ( x , mmmyy ) ;
legend ( [ h1 , h2 , h3 ] , P r e c i o papa , F o r e c a s t , . . .
F o r e c a s t I n t e r v a l , L o c a t i o n , Northwest )
t i t l e ( F o r e c a s t P r e c i o papa Yungay )
hold o f f
105
106
107
108
% Validando d a t o s p r e d e c i d o s
error = abs ( ( mn1p2 ) . / p2 ) . 1 0 0 ;
v a l i d o = 100error ;
109
110
111
mvalido = mean( v a l i d o ) ;
myF = mean(mn1) ;
112
113
114
115
116
117
N=[mn1 p2 v a l i d o ] ;
fprintf (
Tabla de v a l i d a c i o n de d a t o s
\n ) ;
f p r i n t f ( ===================================\n ) ;
fprintf ( Forecast
Muestra
V a l i d a c i o n
\n ) ;
disp (N) ;
118
119
120
121
122
123
124
125
126
127
figure (7)
subplot ( 2 , 1 , 1 ) ;
h4 = plot ( t2 , p2 , t2 , mn1) ;
d a t e t i c k ( x , mmmyy ) ;
set ( h4 ( 1 ) , L i n e S t y l e , , C o l o r , b ) ;
legend ( P r e c i o papa , F o r e c a s t , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
t i t l e ( Muestra o b s e r v a d a vs . F o r e c a s t )
grid on
23
128
129
130
131
132
133
134
135
subplot ( 2 , 1 , 2 ) ;
h5 = plot ( t2 , v a l i d o ) ;
d a t e t i c k ( x , mmmyy ) ;
legend ( V
a l i d o ( %) , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
title ( Validaci
o n de d a t o s ( en p o r c e n t a j e ) ) ;
grid on
136
137
138
139
140
%% % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%MODELO GARCH RETORNOS PAPA YUNGAY
r = price2ret ( precio , periodic ) ;
141
142
143
144
145
146
147
148
149
150
151
figure (8)
subplot ( 2 , 1 , 1 ) ;
plot ( tiempo , p r e c i o , b , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( P r e c i o S / . por kg , F o n t s i z e , 1 0 ) ;
legend ( Papa Yungay , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
title ( Precios Hist
o r i c o s de l a papa Yungay , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
152
153
154
155
156
157
158
159
160
161
subplot ( 2 , 1 , 2 ) ;
plot ( tiempo ( 2 : 9 2 ) , r , k , LineWidth , 1 ) ;
d a t e t i c k ( x , mmmyy ) ;
ylabel ( Retornos , F o n t s i z e , 1 0 ) ;
legend ( R t , O r i e n t a t i o n , H o r i z o n t a l , . . .
L o c a t i o n , NorthWest ) ;
t i t l e ( Retornos de l a papa Yungay , . . .
Fontsize ,15) ;
set ( gca , F o n t s i z e , 1 0 ) ;
162
163
164
165
% E s p e c i f i c a n d o e l modelo ARIMAGARCH
mdl1 = arima ( ARLags , 8 , D , 1 , MALags , 8 , V a r i a n c e , g a r c h ( 2 , 1 ) ) ;
e s t m d l 1 = e s t i m a t e ( mdl1 , r ) ;
166
167
168
169
170
171
172
173
174
175
176
% Bondad de a j u s t e
figure (9)
r e s 1 = i n f e r ( estmdl1 , r ) ;
t i t l e ( Residuos Estandarizados )
subplot ( 3 , 1 , 1 )
qqplot ( res1 )
subplot ( 3 , 1 , 2 )
autocorr ( res1 , 3 6 )
subplot ( 3 , 1 , 3 )
parcorr ( res1 , 3 6 )
177
178
179
180
181
182
183
24
184
185
186
t r 1 ( 1 : 7 3 , 1 ) = tiempo ( 1 : 7 3 , 1 ) ;
t r 2 ( 1 : 1 8 , 1 ) = tiempo ( 7 4 : 9 1 , 1 ) ;
187
188
189
r1 ( 1 : 7 3 , 1 ) = r ( 1 : 7 3 , 1 ) ;
r2 ( 1 : 1 8 , 1 ) = r ( 7 4 : 9 1 , 1 ) ;
190
191
192
193
194
195
196
197
% C
aclulo del f orec ast
yt=s i m u l a t e ( estmdl1 , 1 8 , numPaths , 1 0 0 , Y0 , r 1 ) ;
[ rF , rMSE ] = f o r e c a s t ( estmdl1 , 1 8 , Y0 , yt ) ;
% I n t e r v a l o de c o n f i a n z a y promedio de l a s i m u l a c i
on
mn = mean( yt , 2 ) ;
low = p r c t i l e ( yt , 2 . 5 , 2 ) ;
up = p r c t i l e ( yt , 9 7 . 5 , 2 ) ;
198
199
200
201
202
203
204
205
% Gra
fica simulaci
on
figure (10)
plot ( t r 1 , r1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
hold on
plot ( t r 2 , yt ) ;
d a t e t i c k ( x , mmmyy ) ;
t i t l e ( Simulaci
o n de Retornos d e l p r e c i o papa Yungay , F o n t s i z e
,15)
206
207
208
209
210
211
212
213
214
215
216
217
218
% Gra
f i c a de l a p r e d i c c i o
n forecast
figure (11)
h6 = plot ( t r 1 , r1 , C o l o r , [ . 8 0 , . 7 5 , . 7 5 ] ) ;
hold on
h7 = plot ( t r 2 , mn, b , LineWidth , 2 ) ;
h8 = plot ( t r 2 , up , k , LineWidth , 1 . 5 ) ;
plot ( t r 2 , low , k , LineWidth , 1 . 5 ) ;
d a t e t i c k ( x , mmmyy ) ;
legend ( [ h6 , h7 , h8 ] , Retorno R t , F o r e c a s t , . . .
F o r e c a s t I n t e r v a l , L o c a t i o n , Northwest )
t i t l e ( F o r e c a s t Retornos p r e c i o papa Yungay , F o n t s i z e , 1 5 )
hold o f f
219
220
221
222
% Validadndo d a t o s p r e d e c i d o s
e r r o r r = ( abs ( r 2 )abs (mn) ) . / abs ( r 2 ) . 1 0 0 ;
v a l i d o r = 100 e r r o r r ;
223
224
225
m v a l i d o r = mean( v a l i d o r ) ;
mrF = mean(mn) ;
226
227
228
229
230
231
N1=[mn r 2 v a l i d o r ] ;
fprintf (
Tabla de v a l i d a c i o n de d a t o s
\n ) ;
f p r i n t f ( ===================================\n ) ;
fprintf ( Forecast
Muestra
V a l i d a c i o n
\n ) ;
disp (N1) ;
232
233
234
235
236
237
238
% Gra
f i c a aumentada d e l f o r e c a s t v s v a l o r e s o b s e r v a d o s
figure (12)
h9 = plot ( t r 2 , r2 , t r 2 ,mn) ;
d a t e t i c k ( x , mmmyy ) ;
set ( h9 ( 2 ) , L i n e S t y l e , , LineWidth , 1 . 5 ) ;
legend ( Retorno R t , F o r e c a s t , O r i e n t a t i o n , H o r i z o n t a l , . . .
25
239
240
241
Location , Southoutside ) ;
t i t l e ( Muestra o b s e r v a d a vs . F o r e c a s t )
grid on
242
243
244
245
246
247
248
249
figure (13)
h10 = plot ( t2 , v a l i d o r ) ;
d a t e t i c k ( x , mmmyyyy ) ;
legend ( V
a l i d o ( %) , O r i e n t a t i o n , H o r i z o n t a l , . . .
Location , Southoutside ) ;
title ( Validaci
o n de d a t o s ( en p o r c e n t a j e ) ) ;
grid on
26