SDF4.rts <- as.rts(SDF4) SDF4time <- time(SDF4.rts) ts.plot(log(SDF4.rts),reference.grid=F,main="cobre desest y con log") serie.acf=acf(log(SDF4.rts)) serie.pacf=acf(log(SDF4.rts),type="partial") library(finmetrics) nonlinearTest(log(SDF4.rts), method="threshold", p=2, d=1:2) nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF1.rts), nonlinearTest(log(SDF4.rts), method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", method="threshold", p=13, d=1:13) p=12, d=1:12) p=11, d=1:11) p=10, d=1:10) p=9, d=1:9) p=8, d=1:8) p=7, d=1:7) p=6, d=1:6) p=5, d=1:5) p=4, d=1:4) p=3, d=1:3) p=2, d=1:2) ndx.test = nonlinearTest(log(SDF4.rts), method="threshold", p=2, d=1, save.RLS=T) names(ndx.test) #####grafico de umbrales### par(mfrow=c(2,1)) plot(ndx.test$yd, ndx.test$tRatio[,1], xlab="Y_{t-1}",ylab="t-ratio of AR(1)",col="blue") plot(ndx.test$yd, ndx.test$tRatio[,2], xlab="Y_{t-1}",ylab="t-ratio of AR(2)",col="green") nonlinearTest(log(SDF4.rts), method="sup-LR", p=2, d=1, n.boot=1000) nonlinearTest(log(SDF4.rts), method="sup-LR", p=2, d=1, n.boot=1000, hetero=T) ndx.setar.r = TAR(log(SDF4.rts), p=2, d=1) ndx.setar.r ###estimacion del setar### library(finmetrics) ndx.setar = SETAR(log(SDF4.rts), c(4.9859), p=2, d=1) summary(ndx.setar) ndx.resid=resid(ndx.setar) ndx.resid histogram(ndx.resid,probability=T,ylim=c(0,30)) dens<- density(ndx.resid,n=130) points(dens,type="1") AutoccoResid = acf(ndx.resid,col="blue",main="ACF de los residuos") ndx.fitted = fitted(ndx.setar) tsplot(cbind(ndx.fitted)) tsplot(log(SDF4.rts),ndx.fitted) 4.6 4.8 5.0 5.2 5.4 Produccion de cobre en Perъ(2007-2018) 0 20 40 60 80 100 120 140 Time -0.2 0.0 0.2 ACF 0.4 0.6 0.8 1.0 Series : log(SDF4.rts) 0 5 10 Lag 15 20 1 2 3 of AR(2) t-ratio 4 0 2 4 of AR(1) t-ratio 6 8 -0.2 0.0 0.2 Partial ACF 0.4 0.6 0.8 1.0 Series : log(SDF4.rts) 0 5 4.8 4.8 10 Lag 5.0 5.0 Y_{t-1} 15 20 Y_{t-1} 5.2 5.4 5.2 5.4 -0.2 0.0 0.2 ACF 0.4 0.6 0.8 1.0 ACF de los residuos 5 10 Lag 15 20 4.6 4.8 5.0 5.2 5.4 0 0 20 40 60 80 Time 100 120 140 200 400 600 800 1000 Produccion de hierro en Peru(2007-2018) 0 20 40 60 80 100 120 140 Time serie tratada 5.0 5.5 6.0 6.5 7.0 Produccion de hierro en Peru(2007-2018) 0 20 40 60 80 Time 100 120 140 0.5 1.0 1.5 of AR(2) t-ratio 2.0 0 1 2 of AR(1) t-ratio 3 4 -0.2 -0.1 Partial ACF 0.1 0.3 ACF 0.2 0.4 0.6 0.8 1.0 ACF 0 5 6.0 6.0 10 Lag 6.2 6.2 ACP 15 20 0 6.4 6.4 Y_{t-1} 5 10 Lag 15 Y_{t-1} 6.6 6.8 6.6 6.8 20 -0.2 0.0 0.2 ACF 0.4 0.6 0.8 1.0 ACF de los residuos 0 5 10 Lag 15 20