Pronostico

Como primer paso se obtiene los datos y se evalua la longitud de los mismos.

library(pdfetch)
## Warning: package 'pdfetch' was built under R version 4.2.2
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.2
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   1.0.1 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 1.0.0
## Warning: package 'readr' was built under R version 4.2.2
## Warning: package 'purrr' was built under R version 4.2.2
## Warning: package 'forcats' was built under R version 4.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(yuima)
## Warning: package 'yuima' was built under R version 4.2.2
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Loading required package: stats4
## Loading required package: expm
## Warning: package 'expm' was built under R version 4.2.2
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## Attaching package: 'expm'
## 
## The following object is masked from 'package:Matrix':
## 
##     expm
## 
## Loading required package: cubature
## Warning: package 'cubature' was built under R version 4.2.2
## Loading required package: mvtnorm
## ########################################
## This is YUIMA Project package v.1.15.22
## Why don't you try yuimaGUI package?
## Visit: http://www.yuima-project.com
## ########################################
## 
## Attaching package: 'yuima'
## 
## The following object is masked from 'package:tibble':
## 
##     char
## 
## The following object is masked from 'package:stats':
## 
##     simulate
NVCRdata <- pdfetch_YAHOO("NVS",from = c("2019-01-01"),to = c("2023-02-20"), interval = '1d')
Novocure <- NVCRdata[,4] 
length(Novocure)
## [1] 1041

Se procede a transformar en una serie de tiempo y graficar.

A continuación se realiza una diferenciación por medio de logaritmos.

Se calculan los parametros para ambos métodos.

Delta <- 1/365 
alpha <- mean(l_NovoCure)/Delta
sigma <- sqrt(var(l_NovoCure)/Delta)
mu <- alpha +0.5*sigma^2
x0<-tsNovoCure[1]

x <- tsNovoCure
gBm <- setModel(drift="mu*x", diffusion="sigma*x", xinit=x0)
## Warning in yuima.warn("Solution variable (lhs) not specified. Trying to use state variables."): 
## YUIMA: Solution variable (lhs) not specified. Trying to use state variables.
mod <- setYuima(model=gBm, data=setData(tsNovoCure, delta=Delta))
set.seed(123)
fit <- qmle(mod, start=list(mu=0, sigma=1),
            lower=list(mu=0.1, sigma=0.1),
            upper=list(mu=100, sigma=10))
summary(fit)
## Quasi-Maximum likelihood estimation
## 
## Call:
## qmle(yuima = mod, start = list(mu = 0, sigma = 1), lower = list(mu = 0.1, 
##     sigma = 0.1), upper = list(mu = 100, sigma = 10))
## 
## Coefficients:
##        Estimate  Std. Error
## sigma 0.2497151 0.005471307
## mu    0.1000462 0.147936261
## 
## -2 log L: 3210.346
## 
## Diffusion process
## Number of equations: 1
## Number of Wiener noises: 1
## Parametric model with 2 parameters
## Warning in yuima.warn("'delta' (re)defined."): 
## YUIMA: 'delta' (re)defined.

Se procede a graficar luego de los resultados de los parámetros

El resultado del modelo será:

## [1] 68.62668