Performs a linear model for

linear_model(x, y = NULL, conf_level = 0.95)

Arguments

x

numeric vector

y

optional time variable, converted to numeric. If its not provided it will be assumed that all values in X are sequential, regularly measured, and there are no gaps in the measurements.

conf_level

numeric. Level of confidence to be used to calculate the confidence intervals

Value

a tidy data frame with the model results

Examples

x <- runif(100) * 1:100 linear_model(x)
#> # A tibble: 1 × 11 #> p_value slope conf_low conf_high conf_level intercept r_squared sigma method #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 2.09e-14 0.550 0.430 0.670 0.95 -0.242 0.451 17.7 Linear… #> # … with 2 more variables: n <int>, note <chr>
# If measurements were for example taken daily linear_model(x, y = Sys.Date() + (1:100))
#> # A tibble: 1 × 11 #> p_value slope conf_low conf_high conf_level intercept r_squared sigma method #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 2.09e-14 0.550 0.430 0.670 0.95 -10472. 0.451 17.7 Linear… #> # … with 2 more variables: n <int>, note <chr>