fit_linear_model_groups: Linear model fitting on subgroups of data

Description Usage Arguments Examples

View source: R/fit_linear_model.R

Description

This function allows you to fit a (multiple) linear model between dependend and independend variables and perform cross validation to variable subgroups of the data.

Usage

1
2
3
4
5
6
7
8
9
fit_linear_model_groups(
  df,
  frml,
  group.cols = NULL,
  rowname.col = NULL,
  min.size = 30,
  output = "full",
  ...
)

Arguments

df

data.frame, A data.frame that is used to fit a linear model between dependent and independent variables.

frml

formula, A formula object for building the linear model

group.cols

string, column names that are used to group df

rowname.col

string, name of the column that is used to give rownames to the nested dataframes within df. Only useful if the desired output is 'augment' as the rownames are used to name the output rows.

min.size

integer, minimal amount of observations that have to be within a group in order to fit the linear model. If the group is smaller, it will be discarded.

output

string, one of 'full', 'minimal', 'augmented', 'glanced' or 'tidied'. 'full' will give all columns, 'minimal' only the linear model fits. For further information about the rest see the respective function in package::broom.

...

further arguments passed on to caret::trainControl (method, number, repeats). Defaults correspond to repeated crossvalidation using 5 folds repeated for 3 times.

Examples

1
2
3
4
5
fit_linear_model_groups(df = df.interp,
  frml = huglin ~ elevation,
  predictor.raster = dem.st,
  file.name = data/huglin.tif,
  set.zero = T)

sitscholl/rebecka_package documentation built on Aug. 25, 2020, 4:20 a.m.