This fork aims at reducing computation times in the R package bfast. Parts of the improvements rely on modifications of the strucchange package (see here). You can install both packages with:
library(devtools)
install_github("appelmar/strucchange")
install_github("appelmar/bfast")
By default, the package will not make use of any modifications. Two functions change the behaviour:
set_fast_options() # use modifications
set_default_options() # use default implementation
The example below runs the first example of the bfastmonitor()
documentation for both settings.
library(bfast)
NDVIa <- as.ts(zoo(som$NDVI.a, som$Time))
f <- function() bfastmonitor(NDVIa, start = c(2010, 13))
set_default_options()
x = f()
system.time(replicate(100, f()))
set_fast_options()
y = f()
system.time(replicate(100, f()))
par(mfrow = c(1,2))
plot(x) ; plot(y)
The package comes with R Markdown reports to evaluate the modifications thoroughly. The following reports can be found in inst/reports
:
report.test.Rmd
runs test cases to make sure that modifications will return equal results,report.benchmark.Rmd
evaluates the speedup of a set of functions, andreport.profiling.Rmd
profiles some test functions to identify computational bottlenecks.
To generate html
reports, run:
library(rmarkdown)
outdir = getwd()
rmarkdown::render(system.file("reports/report.test.Rmd",package = "bfast"),output_file = paste(outdir,"/report.test.html",sep=""))
rmarkdown::render(system.file("reports/report.benchmark.Rmd",package = "bfast"),output_file = paste(outdir,"/report.benchmark.html",sep=""))
rmarkdown::render(system.file("reports/report.profiling.Rmd",package = "bfast"),output_file = paste(outdir,"/report.profiling.html",sep=""))
Notice that generating the last two reports might take some time.
Most important modifications include:
- using RcppArmadillo for computationally intensive operations in strucchange
- avoiding expensive calls of
model.frame()
andmodel.matrix
and using the design matrix and response vector instead of a data.frame and a formula - using
lm.fit()
instead oflm()
when possible