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.696655     1.802219 5.455667  6.063087    1.6184395
#> Mazda RX4 Wag           1.696655     1.802219 5.455667  6.063087    1.7681710
#> Datsun 710              1.608668     1.727752 4.996152  5.627989    1.0229879
#> Hornet 4 Drive          1.677740     1.784669 5.353444  5.957606    1.7630792
#> Hornet Sportabout       1.802893     1.899376 6.067176  6.681724    1.9513892
#> Valiant                 1.828760     1.927339 6.226160  6.871202    1.9169612
#> Duster 360              1.981153     2.108663 7.251100  8.237220    3.0388432
#> Merc 240D               1.525914     1.666879 4.599346  5.295616    1.2012097
#> Merc 230                1.608668     1.727752 4.996152  5.627989    1.0657058
#> Merc 280                1.778969     1.877397 5.923746  6.536469    1.9086476
#> Merc 280C               1.841707     1.940798 6.307296  6.964305    2.0485863
#> Merc 450SE              1.896624     2.005722 6.663361  7.431458    2.6569580
#> Merc 450SL              1.862177     1.962742 6.437739  7.118821    2.6596228
#> Merc 450SLC             1.945714     2.063190 6.998627  7.871035    2.1134432
#> Cadillac Fleetwood      2.130481     2.307179 8.418914 10.046048    3.0998211
#> Lincoln Continental     2.130481     2.307179 8.418914 10.046048    3.9882060
#> Chrysler Imperial       1.965590     2.088430 7.139123  8.072233    2.8718627
#> Fiat 128                1.111221     1.374947 3.038066  3.954866    0.7887606
#> Honda Civic             1.215517     1.446733 3.372036  4.249209    0.8042950
#> Toyota Corolla          1.032517     1.319607 2.808126  3.741952    0.0000000
#> Toyota Corona           1.673145     1.780227 5.328899  5.931204    1.8329931
#> Dodge Challenger        1.933798     2.048144 6.915730  7.753499    2.1581064
#> AMC Javelin             1.945714     2.063190 6.998627  7.871035    2.8090910
#> Camaro Z28              2.020355     2.157973 7.541000  8.653577    2.9002678
#> Pontiac Firebird        1.778969     1.877397 5.923746  6.536469    1.9438387
#> Fiat X1-9               1.378674     1.560952 3.969633  4.763356    0.9532843
#> Porsche 914-2           1.446164     1.606902 4.246792  4.987335    0.9676876
#> Lotus Europa            1.215517     1.446733 3.372036  4.249209    0.8166978
#> Ford Pantera L          1.921124     2.033783 6.828630  7.642949    2.6228794
#> Ferrari Dino            1.757029     1.856869 5.795196  6.403657    1.8788985
#> Maserati Bora           1.953572     2.073227 7.053836  7.950437    2.1299563
#> Volvo 142E              1.677740     1.784669 5.353444  5.957606    1.7826565
#>                     PI_log_upper  PI_lower    PI_upper
#> Mazda RX4              10.545147  5.045211   37992.600
#> Mazda RX4 Wag          11.032326  5.860126   61841.246
#> Datsun 710              9.975755  2.781493   21498.851
#> Hornet 4 Drive         10.855559  5.830363   51821.404
#> Hornet Sportabout      11.894744  7.038458  146494.672
#> Valiant                12.255080  6.800263  210045.650
#> Duster 360             13.782163 20.881074  967202.544
#> Merc 240D               9.895260  3.324136   19836.123
#> Merc 230               10.307998  2.902887   29971.375
#> Merc 280               11.710292  6.743962  121819.089
#> Merc 280C              12.276301  7.756927  214550.535
#> Merc 450SE             12.924508 14.252865  410244.363
#> Merc 450SL             12.125150 14.290898  184452.918
#> Merc 450SLC            13.513979  8.276690  739684.114
#> Cadillac Fleetwood     15.171395 22.193979 3880193.004
#> Lincoln Continental    15.551967 53.958004 5677190.778
#> Chrysler Imperial      13.600583 17.669901  806599.944
#> Fiat 128                7.402888  2.200667    1640.715
#> Honda Civic             8.209344  2.235120    3675.132
#> Toyota Corolla          7.440546  1.000000    1703.680
#> Toyota Corona          10.994498  6.252573   59545.593
#> Dodge Challenger       12.824935  8.654734  371362.798
#> AMC Javelin            13.081558 16.594826  480008.129
#> Camaro Z28             14.821971 18.179013 2735899.130
#> Pontiac Firebird       11.919335  6.985515  150141.710
#> Fiat X1-9               8.885730  2.594216    7228.090
#> Porsche 914-2           9.293656  2.631851   10868.846
#> Lotus Europa            8.129313  2.263015    3392.469
#> Ford Pantera L         12.334997 13.775332  227520.732
#> Ferrari Dino           11.381486  6.546290   87683.203
#> Maserati Bora          13.497700  8.414499  727740.896
#> Volvo 142E             11.098968  5.945630   66102.931