knitr::opts_chunk$set(echo = TRUE)
rm(list = ls())
devtools::install_github("aminaghoul/ARRW") #devtools::install_github("gtromano/DeCAFS", force = TRUE)
library(DeCAFS) library(ARRW, quietly = TRUE) library(tidyverse, quietly = TRUE) library("gridExtra")
On prend comme paramètres :
n <- 400 phi <- 0 sdEta <- 0.8 sdNu <- 0.7
Y <- dataRWAR(n = n, poisParam = .01, meanGap = 15, phi = phi, sdEta = sdEta, sdNu = sdNu)
signal <- data.frame(1:n,Y$signal) colnames(signal) <- c("i", "mu") signal_decafs <- ggplot(signal) + ggtitle("Signal généré par DeCAFS") + geom_point(aes(x = i ,y = mu))
On définit les paramètres suivants :
val <- def(sdEta = sdEta, sdNu = sdNu, phi = phi) kis <- ki(val, n) omega <- val$om u <- val$u rp <- val$rp
estim <- muhat(y = Y$y, kis = kis, omega) estimateur <- data.frame(1:n,estim) colnames(estimateur) <- c("i", "muhat") signal_calc <- ggplot(estimateur) + ggtitle("Estimateur du signal") + geom_point(aes(x = i ,y = muhat))
estim <- muhat1(y = Y$y, u, rp) estimateur <- data.frame(1:n,estim) colnames(estimateur) <- c("i", "muhat") signal_calc <- ggplot(estimateur) + ggtitle("Estimateur du signal") + geom_point(aes(x = i ,y = muhat))
On a alors les deux signaux suivants :
grid.arrange(signal_calc, signal_decafs, ncol=2, nrow = 1)
res1 <- var_log(val, sdNu, n) res1 <- data.frame(1:n, res1) colnames(res1) <- c("i", "variance") maxi <- max(res1$variance) ggplot(res1,aes(x = i, y = variance) ) + ggtitle("Variance de l'estimateur du modèle marche aléatoire plus bruit") + ylim(0, maxi)+geom_line()+ geom_point(shape=3,size=1,color="darkblue")
res1 <- var1(val, sdNu, n) res1 <- data.frame(1:n, res1) colnames(res1) <- c("i", "variance") maxi <- max(res1$variance) ggplot(res1,aes(x = i, y = variance) ) + ggtitle("Variance de l'estimateur du modèle marche aléatoire plus bruit") + ylim(0, maxi)+geom_line()+ geom_point(shape=3,size=1,color="darkblue")
cost <- cost(y = Y$y, estim )
cout <- data.frame(1:n, cost) colnames(cout) <- c("index", "cout") ggplot(cout) + ggtitle("Fonction de coût") + geom_point(aes(x = index , y = cout))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.