simple_linear_data = specify(a = ~ 2 + rnorm(n),
b = ~ 5 + 3 * x1 + rnorm(n, 0, sd = 0.5)) %>%
define(n = 100:101) %>%
generate(2)
## Can show tidy output for multiple competing models,
compare_degree = simple_linear_data %>%
fit(linear = ~lm(a ~ b, data = .),
quadratic = ~lm(a ~ b + I(b^2), data = .)) %>%
glance_fits
compare_degree
## Models can be anything supported by broom::tidy.
cor_vs_lm = simple_linear_data %>%
fit(linear = ~lm(a ~ b, data = .),
cor = ~ cor.test(.$a, .$b)) %>%
glance_fits
cor_vs_lm # has NA for non-matching terms
Run the code above in your browser using DataLab