Skip to contents

Predict response from new data

Usage

# S3 method for class 'pibblefit'
predict(
  object,
  newdata = NULL,
  response = "LambdaX",
  size = NULL,
  use_names = TRUE,
  summary = FALSE,
  iter = NULL,
  from_scratch = FALSE,
  ...
)

Arguments

object

An object of class pibblefit

newdata

An optional matrix for which to evaluate predictions. If NULL (default), the original data of the model is used.

response

Options = "LambdaX":Mean of regression, "Eta", "Y": counts

size

the number of counts per sample if response="Y" (as vector or matrix), default if newdata=NULL and response="Y" is to use colsums of m$Y. Otherwise uses median colsums of m$Y as default. If passed as a matrix should have dimensions ncol(newdata) x iter.

use_names

if TRUE apply names to output

summary

if TRUE, posterior summary of predictions are returned rather than samples

iter

number of iterations to return if NULL uses object$iter

from_scratch

should predictions of Y come from fitted Eta or from predictions of Eta from posterior of Lambda? (default: false)

...

other arguments passed to summarise_posterior

Value

(if summary==FALSE) array D x N x iter; (if summary==TRUE) tibble with calculated posterior summaries

Details

currently only implemented for pibblefit objects in coord_system "default" "alr", or "ilr".

Examples

sim <- pibble_sim()
fit <- pibble(sim$Y, sim$X)
predict(fit)[,,1:2] # just show 2 samples
#> , , 1
#> 
#>                     s1         s2          s3         s4         s5         s6
#> log(c1/c10) -1.7541080 -1.6484152 -1.83595849 -1.7098286 -1.9030064 -1.6299860
#> log(c2/c10) -4.6367218 -4.3633032 -4.84846226 -4.5221745 -5.0219098 -4.3156284
#> log(c3/c10) -0.4404093 -0.3564041 -0.50546454 -0.4052158 -0.5587546 -0.3417565
#> log(c4/c10) -2.0441677 -1.8881727 -2.16497317 -1.9788144 -2.2639312 -1.8609725
#> log(c5/c10)  1.0182172  2.2799548  0.04110442  1.5468158 -0.7592992  2.4999586
#> log(c6/c10)  3.8787951  2.7632595  4.74268641  3.4114471  5.4503445  2.5687483
#> log(c7/c10) -1.7710388 -1.8850991 -1.68270847 -1.8188238 -1.6103525 -1.9049873
#> log(c8/c10)  1.2918321  1.1076658  1.43445398  1.2146766  1.5512829  1.0755535
#> log(c9/c10)  2.8233447  3.6907676  2.15159649  3.1867471  1.6013328  3.8420164
#>                     s7         s8          s9        s10        s11        s12
#> log(c1/c10) -1.6873601 -1.8534479 -1.38346245 -1.7822391 -1.9351062 -1.9801432
#> log(c2/c10) -4.4640506 -4.8937058 -3.67789223 -4.7094947 -5.1049492 -5.2214561
#> log(c3/c10) -0.3873578 -0.5193652 -0.14581826 -0.4627681 -0.5842677 -0.6200633
#> log(c4/c10) -1.9456526 -2.1907862 -1.49712131 -2.0856872 -2.3113081 -2.3777794
#> log(c5/c10)  1.8150387 -0.1676799  5.44290223  0.6823944 -1.1424991 -1.6801402
#> log(c6/c10)  3.1743041  4.9272781 -0.03318616  4.1757049  5.7891416  6.2644844
#> log(c7/c10) -1.8430710 -1.6638345 -2.17102744 -1.7406807 -1.5757115 -1.5271091
#> log(c8/c10)  1.1755261  1.4649287  0.64599401  1.3408497  1.6072157  1.6856912
#> log(c9/c10)  3.3711458  2.0080609  5.86523960  2.5924723  1.3378895  0.9682704
#>                    s13        s14        s15        s16        s17        s18
#> log(c1/c10) -1.8748964 -1.5986196 -2.2010202 -1.5577558 -1.7165224 -1.8368130
#> log(c2/c10) -4.9491914 -4.2344860 -5.7928469 -4.1287748 -4.5394909 -4.8506729
#> log(c3/c10) -0.5364126 -0.3168263 -0.7956175 -0.2843476 -0.4105361 -0.5061437
#> log(c4/c10) -2.2224427 -1.8146778 -2.7037782 -1.7543659 -1.9886940 -2.1662344
#> log(c5/c10) -0.4237274  2.8744042 -4.3169217  3.3622266  1.4669060  0.0309030
#> log(c6/c10)  5.1536565  2.2376910  8.5957328  1.8063943  3.4820974  4.7517058
#> log(c7/c10) -1.6406880 -1.9388369 -1.2887458 -1.9829357 -1.8116000 -1.6817863
#> log(c8/c10)  1.5023020  1.0208984  2.0705624  0.9496947  1.2263404  1.4359430
#> log(c9/c10)  1.8320326  4.0994414 -0.8444715  4.4348109  3.1318106  2.1445832
#>                    s19        s20        s21        s22        s23        s24
#> log(c1/c10) -1.6036039 -1.9901707 -1.7374903 -1.4936747 -1.5795223 -1.6844577
#> log(c2/c10) -4.2473800 -5.2473966 -4.5937330 -3.9630022 -4.1850830 -4.4565421
#> log(c3/c10) -0.3207879 -0.6280333 -0.4272015 -0.2334155 -0.3016477 -0.3850509
#> log(c4/c10) -1.8220344 -2.3925794 -2.0196411 -1.6597867 -1.7864917 -1.9413688
#> log(c5/c10)  2.8149022 -1.7998473  1.2165964  4.1272131  3.1023826  1.8496879
#> log(c6/c10)  2.2902983  6.3703206  3.7034028  1.1300495  2.0361292  3.1436699
#> log(c7/c10) -1.9334580 -1.5162876 -1.7889722 -2.0520900 -1.9594460 -1.8462032
#> log(c8/c10)  1.0295835  1.7031639  1.2628762  0.8380353  0.9876221  1.1704686
#> log(c9/c10)  4.0585348  0.8859738  2.9597270  4.9607259  4.2561726  3.3949665
#>                    s25        s26        s27        s28        s29        s30
#> log(c1/c10) -1.9523334 -1.5943117 -1.5910696 -1.8521395 -1.6574181 -1.7294884
#> log(c2/c10) -5.1495145 -4.2233419 -4.2149549 -4.8903211 -4.3865929 -4.5730329
#> log(c3/c10) -0.5979599 -0.3134024 -0.3108256 -0.5183253 -0.3635597 -0.4208415
#> log(c4/c10) -2.3367342 -1.8083198 -1.8035347 -2.1888552 -1.9014603 -2.0078309
#> log(c5/c10) -1.3481533  2.9258302  2.9645335 -0.1520607  2.1724804  1.3121207
#> log(c6/c10)  5.9709660  2.1922239  2.1580053  4.9134688  2.8582804  3.6189472
#> log(c7/c10) -1.5571205 -1.9434858 -1.9469845 -1.6652465 -1.8753835 -1.7976075
#> log(c8/c10)  1.6372335  1.0133922  1.0077429  1.4626488  1.1233530  1.2489333
#> log(c9/c10)  1.1965057  4.1347959  4.1614037  2.0187988  3.6168808  3.0253983
#> 
#> , , 2
#> 
#>                     s1         s2         s3         s4         s5         s6
#> log(c1/c10) -1.6316775 -1.6282873 -1.6343029 -1.6302572 -1.6364535 -1.6276962
#> log(c2/c10) -5.0469548 -4.9064852 -5.1557371 -4.9881058 -5.2448463 -4.8819921
#> log(c3/c10) -0.2150639 -0.1657285 -0.2532702 -0.1943951 -0.2845669 -0.1571261
#> log(c4/c10) -3.4691397 -3.0906066 -3.7622827 -3.3105552 -4.0024113 -3.0246034
#> log(c5/c10)  1.9144920  3.3261667  0.8212652  2.5059059 -0.0742535  3.5723143
#> log(c6/c10)  4.0509102  3.1467048  4.7511435  3.6720980  5.3247409  2.9890424
#> log(c7/c10) -2.0554650 -1.9529401 -2.1348621 -2.0125127 -2.1999004 -1.9350633
#> log(c8/c10)  1.4806087  1.4304432  1.5194578  1.4595921  1.5512811  1.4216961
#> log(c9/c10)  2.9056108  3.2862211  2.6108592  3.0650655  2.3694129  3.3525864
#>                     s7         s8          s9       s10        s11        s12
#> log(c1/c10) -1.6295365 -1.6348639 -1.61978876 -1.632580 -1.6374831 -1.6389277
#> log(c2/c10) -4.9582444 -5.1789811 -4.55435319 -5.084342 -5.2875081 -5.3473639
#> log(c3/c10) -0.1839073 -0.2614339 -0.04205354 -0.228195 -0.2995505 -0.3205729
#> log(c4/c10) -3.2300858 -3.8249200 -2.14169268 -3.569890 -4.1173749 -4.2786723
#> log(c5/c10)  2.8060028  0.5876703  6.86497920  1.538762 -0.5029904 -1.1045215
#> log(c6/c10)  3.4798800  4.9007657  0.88002572  4.291573  5.5993553  5.9846478
#> log(c7/c10) -1.9907177 -2.1518273 -1.69592880 -2.082753 -2.2310381 -2.2747251
#> log(c8/c10)  1.4489278  1.5277589  1.30468734  1.493961  1.5665168  1.5878929
#> log(c9/c10)  3.1459765  2.5478783  4.24034200  2.804308  2.2538185  2.0916361
#>                    s13        s14        s15        s16        s17        s18
#> log(c1/c10) -1.6355519 -1.6266901 -1.6460125 -1.6253793 -1.6304719 -1.6343303
#> log(c2/c10) -5.2074870 -4.8403049 -5.6409176 -4.7859955 -4.9970022 -5.1568728
#> log(c3/c10) -0.2714457 -0.1424848 -0.4236742 -0.1234104 -0.1975197 -0.2536691
#> log(c4/c10) -3.9017366 -2.9122662 -5.0697315 -2.7659149 -3.3345289 -3.7653433
#> log(c5/c10)  0.3011956  3.9912568 -4.0546419  4.5370489  2.4165002  0.8098515
#> log(c6/c10)  5.0842583  2.7207015  7.8742580  2.3711109  3.7293641  4.7584542
#> log(c7/c10) -2.1726329 -1.9046370 -2.4889818 -1.8649980 -2.0190059 -2.1356911
#> log(c8/c10)  1.5379391  1.4068084  1.6927289  1.3874131  1.4627693  1.5198634
#> log(c9/c10)  2.4706401  3.4655401  1.2962360  3.6126944  3.0409603  2.6077819
#>                    s19        s20        s21         s22        s23        s24
#> log(c1/c10) -1.6268500 -1.6392494 -1.6311445 -1.62332389 -1.6260775 -1.6294434
#> log(c2/c10) -4.8469293 -5.3606909 -5.0248692 -4.70082929 -4.8149240 -4.9543869
#> log(c3/c10) -0.1448114 -0.3252536 -0.2073071 -0.09349854 -0.1335706 -0.1825525
#> log(c4/c10) -2.9301174 -4.3145855 -3.4096241 -2.53641177 -2.8438705 -3.2196907
#> log(c5/c10)  3.9246839 -1.2384539  2.1364453  5.39294170  4.2463268  2.8447695
#> log(c6/c10)  2.7633427  6.0704341  3.9087447  1.82289471  2.5573242  3.4550492
#> log(c7/c10) -1.9094719 -2.2844521 -2.0393453 -1.80283762 -1.8861122 -1.9879022
#> log(c8/c10)  1.4091742  1.5926523  1.4727213  1.35699792  1.3977442  1.4475502
#> log(c9/c10)  3.4475910  2.0555257  2.9654530  3.84345694  3.5343111  3.1564286
#>                    s25       s26        s27        s28        s29       s30
#> log(c1/c10) -1.6380357 -1.626552 -1.6264479 -1.6348219 -1.6285761 -1.630888
#> log(c2/c10) -5.3104036 -4.834580 -4.8302708 -5.1772423 -4.9184503 -5.014234
#> log(c3/c10) -0.3075918 -0.140474 -0.1389607 -0.2608232 -0.1699309 -0.203572
#> log(c4/c10) -4.1790731 -2.896838 -2.8852266 -3.8202341 -3.1228499 -3.380966
#> log(c5/c10) -0.7330833  4.048794  4.0920965  0.6051455  3.2059207  2.243321
#> log(c6/c10)  5.7467343  2.683848  2.6561117  4.8895724  3.2237247  3.840289
#> log(c7/c10) -2.2477489 -1.900458 -1.8973133 -2.1505581 -1.9616731 -2.031583
#> log(c8/c10)  1.5746934  1.404764  1.4032250  1.5271379  1.4347163  1.468923
#> log(c9/c10)  2.1917818  3.481053  3.4927281  2.5525899  3.2538008  2.994268
#>