library(tidyverse)
library(BatchGetSymbols)
library(fGarch)
library(profvis)

# set temporary file for results
profiling_file <-  tempfile(pattern = 'profiling_exercise', 
                            fileext = '.out')

# initialize profiling
Rprof(filename = profiling_file)

# run code
profiling <- profvis(expr = {
  ticker <- '^GSPC'
  df_prices <- BatchGetSymbols(tickers = ticker, 
                               first.date = '2000-01-01', do.cache = FALSE)[[2]]

  my_garch <- garchFit(formula = ret.adjusted.prices ~ arma(1,1) + garch(1,1), 
                       data =  na.omit(df_prices) )
})

# create visualization
temp_html <- tempfile(pattern = 'profile',
                      fileext = '.html')

htmlwidgets::saveWidget(profiling, temp_html)

# open in browser from R
browseURL(temp_html)
# none
#my_answers <- make_random_answers(my_sol)
my_answers <- rep(NA, 5)

type_question <- 'string'
ex_name <- 'otimizing 13-01'

Question

Considere o seguinte código:

library(tidyverse)
library(forecast)
library(BatchGetSymbols)

ticker <- '^GSPC'
df_prices <- BatchGetSymbols(tickers = ticker, 
                             first.date = '2010-01-01')[[2]]

my_arima <- auto.arima(df_prices$ret.adjusted.prices)
summary(my_arima)

Use funcões Rprof e profvis para identificar o gargalo do código. Qual número da linha que está tomando maior tempo de execução?

Solution


Meta-information

extype: r type_question exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE) exname: r ex_name exshuffle: TRUE



msperlin/adfeR documentation built on March 26, 2021, 3:05 a.m.