fit_model: Fit the specified model

Description Usage Arguments Details Value Examples

Description

Fits the specified model and returns a tibble containing model fit information.

Usage

1
fit_model(model_array, method, model_data, outcome, group = NA, opt = NA)

Arguments

model_array

a tibble of objects retreived from the make_distribution() function

method

the framework with which the model shoudl be fit provided as an unquoted argument. Either frequentist, bayeasian or randomforest.

model_data

the data frame or tibble containing the variables of the model

outcome

the name of the varaible to act as the dependent variable of the model specified as an expression

group

teh name of teh variable to act as the grouping variable of the data specified as an expression.

opt

additional model options provided as a fucntion call to model_options()

Details

Currently, only the binomial distribution is supported within the Bayesian and random forest frameworks. All models with a specific make_distribution() function can be fit within a Frequentist framework. Priors must be set before fitting a model within a Bayesian framework.

If a grouping variable is specified then each model is fit separately to each group contained within the grouping variable.

Value

A tibble contianing a model_results object (contains the given data set and the model fit), along with relevant information about the model including the distribution the model was fit to, what variable was set as the dependent variable, which group (if not NA) the results correpond to, and the formula for the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
trial_data <- tibble(w = runif(20, 0, 2), x = sample(c(1, 2), 20, TRUE),
                     y = rbinom(20, 1, .75), z = rbinom(20, 15, .5))
make_pois(1) %>% fit_model(frequentist, trial_data, z)
make_pois(w, x) %>% fit_model(frequentist, trial_data, z)
make_pois(w) %>% fit_model(frequentist, trial_data, z, x)
make_binom(1) %>% fit_model(frequentist, trial_data, y)
make_binom(w) %>% fit_model(frequentist, tiral_data, z, opt = model_options(max = 15))
make_binom(w) %>% set_priors(int = dnorm(0, .01), w = dunif(-100, 100)) %>%
                  fit_model(bayesian, trial_data, y)
        

bprucka/uttr documentation built on May 27, 2019, 11:54 a.m.