Questions tagged [modelr]

modelr is an R package by Hadley Wickham designed to allow common operations with models to be piped. It is part of the larger tidyverse group of packages.

modelr is an R package by Hadley Wickham designed to allow common operations with models to be piped. It is part of the larger tidyverse group of packages.

28 questions
10
votes
1 answer

Using modelr::add_predictions for glm

I am trying to calculate the logistic regression prediction for a set of data using the tidyverse and modelr packages. Clearly I am doing something wrong in the add_predictions as I am not receiving the "response" of the logistic function as I would…
Farmer
  • 137
  • 1
  • 8
7
votes
2 answers

when to use map() function and when to use summarise_at()/mutate_at()

Can anyone give a suggestion regarding when to use the map() (all map_..() functions) and when to use summarise_at()/mutate_at()? E.g. if we are doing some modification to the column of vectors then we do not need to think map() ? If we have a df /…
CloverCeline
  • 511
  • 3
  • 18
5
votes
0 answers

R tidyverse - data_grid .model parameter

following an update of my R environment, I keep receiving this error: Error in overscope_eval_next(overscope, expr) : object 'G' not found Documentation says: "A model. If supplied, any predictors needed for the model not present in ... will be…
Jan
  • 51
  • 2
4
votes
1 answer

Using predictNLS to create confidence intervals around fitted values in R?

I want to build confidence intervals around a large set of fitted values using predictNLS from the propogate package in R. As an example, I will use the data set they reference in the function description…
Cameron
  • 164
  • 14
4
votes
3 answers

Add predictions for models by group

I'm estimating regressions models by groups in my dataset and then I wish to add the correct fitted values for all groups. I'm trying the following: library(dplyr) library(modelr) df <- tribble( ~year, ~country, ~value, 2001, "France", 55, …
ulima2_
  • 1,276
  • 1
  • 13
  • 23
3
votes
1 answer

Iterating though slightly different models in purrr

I have the following code comparing the rmse of models that differ only in the polynomial term. library(tidyverse) data(mtcars) cv_mtcars = mtcars %>% crossv_kfold(k = 10) cv_mtcars %>% mutate(model1 = map(train, ~lm(disp ~ wt, data = .)), …
Alex
  • 2,603
  • 4
  • 40
  • 73
3
votes
2 answers

Using modelrs bootstrap in R for medians

I have found that the following works iris %>% select(Sepal.Length) %>% modelr::bootstrap(100) %>% mutate(mean = map(strap, mean)) but the below does not iris %>% select(Sepal.Length) %>% modelr::bootstrap(100) %>% …
Alex
  • 2,603
  • 4
  • 40
  • 73
2
votes
1 answer

Using predict() across multiple models to generate confidence intervals in R

My goal is to create multiple models from a dataframe and then generate confidence intervals around the fitted values that correspond to those different models. Pulling in libraries: library(purrr) library(dplyr) library(modelr) Assigning data_1 as…
Cameron
  • 164
  • 14
2
votes
3 answers

How do I extract parameters from listed models in R?

I am trying to extract the parameters of a model I have designed for my work, but am having trouble doing so. I will use the iris data provided with R as an example data set. I pull in the data: library(dplyr) df <- iris I design a model that…
Cameron
  • 164
  • 14
2
votes
1 answer

Getting predictions from one dataset for multiple models in R

I am trying to perform the following task: take a dataset, and feed it through multiple pre-designed models so that I can see how the predictions differ based on the different models. The following is what the data generally looks like: data_1: …
Cameron
  • 164
  • 14
2
votes
0 answers

Error message every time I try to work with tidyverse, modelr and dplyr

I get this same error message every time I try to work with tidyverse, modelr and dplyr. Error: package or namespace load failed for ‘tidyverse’ in namespaceExport(ns, exports): undefined exports: contains, ends_with, everything, last_col,…
2
votes
1 answer

Error when using broom (augment) and modelr (crossv_kfold) on glm with an offset term

I am trying to fit a poisson regression model on a k-fold cross validated data set using modelr's crossv_kfold and then get predictions using broom's augment function. In the data I'm modeling I have a count I'm trying to predict, but it needs to be…
Bart Spoon
  • 93
  • 1
  • 7
1
vote
1 answer

How to implement "broom" package in R

I have an issue that might be silly in some ways, but following this question: Linear Regression and group by in R I tried to install the broom package in order to "retrieve the coefficients and Rsquared/p.value". I know that the previous question…
Recology
  • 165
  • 1
  • 10
1
vote
1 answer

Generating multiple sets of predictions and prediction intervals for fitted points in R

My goal is to create multiple models and then using a novel dataset, create prediction values for that new data set and the corresponding prediction intervals around each of those new fitted points. Pulling in…
Cameron
  • 164
  • 14
1
vote
1 answer

Using purrr and modelr to make predictions from dose-response models (drm)

I have a data set that looks, in abbreviate form, like this: library(tidyverse) dat_s<-tibble( type=c(rep("A", 9), rep("B", 8), rep("C", 10)), ref=c("ref3", "ref3", "ref1", "ref2", "ref2", "ref1", "ref2", "ref2", "ref2", "ref2", …
aleoconn
  • 57
  • 8
1
2