Computes CI from posterior, and PI for Tweedie and scat gams.

predict_intervals(object_fit, new_data, n = 1000, CI = TRUE, PI = TRUE, ...)

Arguments

object_fit

[gam OR bam] The fit to use for predictions.

new_data

[data.frame] The data to predict onto.

n

[numeric] The number of simulations to run for parameters.

CI

[logical] Whether to compute the CI.

PI

[logical] Whether to compute the PI.

...

further arguments passed to the quantile function.

Value

A data.frame with intervals.

Examples

gam1 <- gam(cyl ~ mpg, data=mtcars, family = tw)
predict_intervals(gam1)
#>                     CI_log_lower CI_log_upper CI_lower  CI_upper PI_log_lower
#> Mazda RX4               1.691631     1.801299 5.428326  6.057512    1.1876569
#> Mazda RX4 Wag           1.691631     1.801299 5.428326  6.057512    1.8185234
#> Datsun 710              1.605077     1.729543 4.978242  5.638075    1.0490354
#> Hornet 4 Drive          1.673478     1.785413 5.330674  5.962039    1.0598809
#> Hornet Sportabout       1.797631     1.898657 6.035330  6.676919    2.0614170
#> Valiant                 1.823332     1.926216 6.192458  6.863490    2.0814527
#> Duster 360              1.979619     2.113194 7.239982  8.274628    2.9549751
#> Merc 240D               1.521916     1.667232 4.580993  5.297483    0.9974699
#> Merc 230                1.605077     1.729543 4.978242  5.638075    0.9981540
#> Merc 280                1.775317     1.876953 5.902150  6.533567    1.9245587
#> Merc 280C               1.836138     1.939422 6.272267  6.954727    1.9755361
#> Merc 450SE              1.896614     2.007768 6.663295  7.446675    2.1299219
#> Merc 450SL              1.857960     1.963392 6.410643  7.123448    2.0404379
#> Merc 450SLC             1.942421     2.066952 6.975616  7.900704    2.8505686
#> Cadillac Fleetwood      2.133065     2.318035 8.440699 10.155699    3.9372201
#> Lincoln Continental     2.133065     2.318035 8.440699 10.155699    3.9207300
#> Chrysler Imperial       1.963084     2.092319 7.121255  8.103684    2.8011578
#> Fiat 128                1.098404     1.373010 2.999374  3.947212    0.0000000
#> Honda Civic             1.207864     1.443272 3.346330  4.234530    0.8263986
#> Toyota Corolla          1.018176     1.319360 2.768140  3.741025    0.0000000
#> Toyota Corona           1.668097     1.781887 5.302070  5.941056    1.8182878
#> Dodge Challenger        1.930027     2.051808 6.889696  7.781954    2.7836958
#> AMC Javelin             1.942421     2.066952 6.975616  7.900704    2.8054883
#> Camaro Z28              2.019415     2.165414 7.533915  8.718208    2.9542774
#> Pontiac Firebird        1.775317     1.876953 5.902150  6.533567    1.8220893
#> Fiat X1-9               1.372786     1.558502 3.946332  4.751699    0.9340159
#> Porsche 914-2           1.440982     1.607346 4.224843  4.989550    0.9968057
#> Lotus Europa            1.207864     1.443272 3.346330  4.234530    0.8486657
#> Ford Pantera L          1.917633     2.036897 6.804835  7.666781    2.1512167
#> Ferrari Dino            1.753057     1.856197 5.772219  6.399353    1.9236575
#> Maserati Bora           1.950683     2.076886 7.033490  7.979583    2.8493515
#> Volvo 142E              1.673478     1.785413 5.330674  5.962039    1.8553117
#>                     PI_log_upper  PI_lower     PI_upper
#> Mazda RX4              10.944271  3.279388    56628.716
#> Mazda RX4 Wag          11.207608  6.162752    73688.912
#> Datsun 710             10.400620  2.854896    32880.006
#> Hornet 4 Drive         10.723687  2.886027    45419.041
#> Hornet Sportabout      11.858988  7.857096   141349.046
#> Valiant                12.333795  8.016105   227247.599
#> Duster 360             14.228383 19.201246  1511151.826
#> Merc 240D              10.017632  2.711413    22418.280
#> Merc 230               10.153664  2.713269    25685.037
#> Merc 280               11.293412  6.852124    80290.896
#> Merc 280C              11.868110  7.210484   142644.330
#> Merc 450SE             12.302936  8.414210   220341.974
#> Merc 450SL             12.747317  7.693977   343628.674
#> Merc 450SLC            13.300815 17.297614   597682.657
#> Cadillac Fleetwood     15.552723 51.275859  5681485.848
#> Lincoln Continental    16.165463 50.437250 10485067.905
#> Chrysler Imperial      13.214313 16.463698   548155.060
#> Fiat 128                7.845297  1.000000     2553.696
#> Honda Civic             8.251226  2.285074     3832.320
#> Toyota Corolla          7.120237  1.000000     1236.744
#> Toyota Corona          10.585965  6.161300    39575.470
#> Dodge Challenger       13.680158 16.178704   873407.678
#> AMC Javelin            13.180619 16.535148   529993.076
#> Camaro Z28             13.827164 19.187852  1011721.821
#> Pontiac Firebird       11.879982  6.184767   144348.002
#> Fiat X1-9               8.836187  2.544708     6878.716
#> Porsche 914-2           9.560349  2.709613    14190.795
#> Lotus Europa            8.269858  2.336527     3904.396
#> Ford Pantera L         13.350696  8.595310   628251.452
#> Ferrari Dino           10.644303  6.845951    41952.913
#> Maserati Bora          13.592575 17.276575   800166.337
#> Volvo 142E             10.920324  6.393691    55288.727