Skip to contents

Using key_slope you can fit a linear model to each key in the tsibble. add_key_slope adds this slope information back to the data, and returns the full dimension tsibble.

Usage

key_slope(.data, formula, ...)

add_key_slope(.data, formula)

add_key_slope.default(.data, formula)

Arguments

.data

tsibble

formula

formula

...

extra arguments

Value

tibble with coefficient information

Examples

key_slope(heights, height_cm ~ year)
#> # A tibble: 144 × 3
#>    country     .intercept .slope_year
#>    <chr>            <dbl>       <dbl>
#>  1 Afghanistan      217.      -0.0263
#>  2 Albania          202.      -0.0170
#>  3 Algeria          111.       0.0297
#>  4 Angola            43.9      0.0648
#>  5 Argentina        147.       0.0117
#>  6 Armenia           87.9      0.0419
#>  7 Australia         46.1      0.0665
#>  8 Austria           38.2      0.0695
#>  9 Azerbaijan       150.       0.0111
#> 10 Bahrain         -157.       0.165 
#> # ℹ 134 more rows