Comments (4)
- rolling_func: A function that can return a rolling function for whatever function you want to roll. Here is just rolling mean but I think we can abstract this further
roll_mean <- function(n, vec) seq(from = 0, to = n) %>% map(~ lag(vec, n = .x)) %>% do.call(cbind, .) %>% rowMeans(na.rm = T)
from modeler.
- safe_ifelse returns the arguments in the same structure as the true and false options
safe_ifelse <- function(cond, yes, no) structure(ifelse(cond, yes, no), class = class(yes))
from modeler.
- acf_by_group: finds auto correlations by group
acf_by_group <- function(.df, .group_var, .value_var, ...){
group_var <- enquo(.group_var)
value_var <- deparse(substitute(.value_var))
nest_cols <- names(.df)
group_col <- deparse(substitute(.group_var))
nest_cols <- nest_cols[nest_cols != group_col]
.df %>%
tidyr::nest_(key_col = "data", nest_cols = nest_cols) %>%
dplyr::mutate(acf_results = purrr::map(data, ~ acf(.x[[value_var]], plot = F, ...)),
acf_values = purrr::map(acf_results, ~ drop(.x$acf))) %>%
tidyr::unnest(acf_values) %>%
dplyr::group_by(!!group_var) %>%
dplyr::mutate(lag = seq(0, n() - 1)) %>%
dplyr::ungroup()
}
from modeler.
Rolling functions could also just use sequences like so
roll_numeric <- function(x, n, func, ...){
stopifnot(length(x) > 0)
positions <- seq_along(x)
vapply(positions, function(i, .x = x, .n = n){
start <- max(i - .n, 0) + 1
func(.x[seq(start, i)], ...)
}, numeric(1))
}
roll_mean <- function(...) roll_numeric(func = mean, ...)
roll_sum <- function(...) roll_numeric(func = sum, ...)
from modeler.
Related Issues (20)
- The current standard errors are on the overall prediction, not the variable fit itself
- Write a model_matrix function HOT 1
- write a one-hot function HOT 2
- Think of a better name HOT 1
- Create a profile/prepare/track function HOT 1
- Create n_distinct for data frames HOT 1
- Write function to sort within groups HOT 1
- Impact Code Function Structure HOT 4
- create wrapper for project template spin calls
- Look into ways to incorporate multiple variables into partial_plot
- binary model evaluation HOT 3
- assigning training/test with option for groups
- check_drift changes HOT 1
- Function for working with grouped time series HOT 2
- Create rolling functions HOT 1
- Turn partial_plot into an S3 generic to include functions for different model objects HOT 1
- Incorporate a rug plot into partial_plot HOT 1
- Add tests to partial_plot HOT 1
- Add options for plotting in linear or response terms and SEs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modeler.