Predicts outcome from features with stacked model.
# S3 method for joinet
predict(object, newx, type = "response", ...)
joinet object
covariates: numeric matrix with \(n\) rows (samples) and \(p\) columns (variables)
character "link" or "response"
further arguments (not applicable)
This function returns predictions from base and meta learners.
The slots base
and meta
each contain a matrix
with \(n\) rows (samples) and \(q\) columns (variables).
# \dontshow{
if(!grepl('SunOS',Sys.info()['sysname'])){
n <- 50; p <- 100; q <- 3
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Y <- replicate(n=q,expr=rnorm(n=n,mean=rowSums(X[,1:5])))
Y[,1] <- 1*(Y[,1]>median(Y[,1]))
object <- joinet(Y=Y,X=X,family=c("binomial","gaussian","gaussian"))
predict(object,newx=X)}# }
#> $base
#> [,1] [,2] [,3]
#> [1,] 0.93976714 0.415111192 1.73158332
#> [2,] 0.23234020 0.575905369 -0.45306653
#> [3,] 0.61644810 0.028398842 0.78072674
#> [4,] 0.72271264 0.271378500 1.74156728
#> [5,] 0.18139279 -1.805411184 -1.83820879
#> [6,] 0.76810222 -0.445806417 0.27555135
#> [7,] 0.68557476 0.498155202 2.24401782
#> [8,] 0.87724343 1.611584297 1.05026376
#> [9,] 0.82336015 3.529858454 2.78077957
#> [10,] 0.68953245 2.078789191 1.28948672
#> [11,] 0.08536887 -1.194101525 -0.69789763
#> [12,] 0.01054648 -5.315189124 -5.35839788
#> [13,] 0.14543137 -1.957692382 -2.53833401
#> [14,] 0.21315943 -0.437860601 -0.16824322
#> [15,] 0.25225512 -2.169113885 -2.07563316
#> [16,] 0.08036213 -1.761456971 -1.78930766
#> [17,] 0.61585905 -0.432505494 -1.61355683
#> [18,] 0.52419902 -0.178279640 -0.13513128
#> [19,] 0.18154451 -1.392180042 -1.87401408
#> [20,] 0.31124111 0.005965261 1.61066769
#> [21,] 0.98001836 3.445952387 3.45264697
#> [22,] 0.89172207 0.192186020 -0.61940321
#> [23,] 0.86364036 2.196477239 1.58147875
#> [24,] 0.26971059 -2.114007376 -2.25871501
#> [25,] 0.19438305 0.229224220 0.05159645
#> [26,] 0.91557418 0.845937740 1.17754651
#> [27,] 0.74766599 3.088004921 2.74231456
#> [28,] 0.33859927 -0.107023902 -0.09411185
#> [29,] 0.25014324 -1.767827618 -1.29894749
#> [30,] 0.85416177 2.435665822 3.31347055
#> [31,] 0.80398630 1.144529054 0.28429174
#> [32,] 0.21764325 -0.684340781 -0.59020617
#> [33,] 0.34450803 -0.986638946 -2.25925104
#> [34,] 0.14385721 -1.654699853 -2.13623623
#> [35,] 0.13368468 -0.634371494 -0.32486193
#> [36,] 0.88707134 3.247276124 3.38893969
#> [37,] 0.18807739 -1.149790253 -1.10706426
#> [38,] 0.22987952 -1.498036671 -1.02586411
#> [39,] 0.26989996 -0.557952677 -0.74036685
#> [40,] 0.85690536 2.713766056 2.96966261
#> [41,] 0.78698713 1.029620938 0.62841122
#> [42,] 0.99500313 3.783311342 3.09841754
#> [43,] 0.15301571 -1.186271113 -1.83100708
#> [44,] 0.71707813 -0.646798855 -0.84412421
#> [45,] 0.06811320 -1.807233836 -2.59512416
#> [46,] 0.89007583 2.427239150 2.79079128
#> [47,] 0.28780655 -1.211409687 -0.85873373
#> [48,] 0.15173480 -1.029809027 -1.01504868
#> [49,] 0.94876476 3.091613167 2.20709686
#> [50,] 0.66384756 1.597548909 1.16237409
#>
#> $meta
#> [,1] [,2] [,3]
#> [1,] 0.738139170 0.9570060 1.17006964
#> [2,] 0.639264337 0.3513108 0.16711058
#> [3,] 0.566911114 0.2715823 0.28229854
#> [4,] 0.671355179 0.7609692 0.82167791
#> [5,] 0.089127345 -2.1130699 -2.24623898
#> [6,] 0.433591235 -0.2484988 -0.16215408
#> [7,] 0.735088657 1.0863873 1.13059470
#> [8,] 0.902409469 1.7880505 1.86686564
#> [9,] 0.989829466 3.9101412 3.89896297
#> [10,] 0.935679993 2.2125834 2.17162821
#> [11,] 0.173398733 -1.3088761 -1.52452084
#> [12,] 0.000891377 -6.2464987 -6.56026492
#> [13,] 0.068322202 -2.4444157 -2.60725702
#> [14,] 0.367527249 -0.4627179 -0.60712403
#> [15,] 0.061342191 -2.4772654 -2.56158339
#> [16,] 0.086893940 -2.0995921 -2.31637413
#> [17,] 0.361597596 -0.7724595 -0.78593791
#> [18,] 0.470193531 -0.1697148 -0.20035723
#> [19,] 0.134335676 -1.7615561 -1.91338507
#> [20,] 0.559663233 0.4224024 0.33678483
#> [21,] 0.991713290 4.1129362 4.32671387
#> [22,] 0.602353688 0.1064857 0.22924222
#> [23,] 0.949945692 2.4364355 2.48872599
#> [24,] 0.064043393 -2.4744487 -2.55651977
#> [25,] 0.556736689 0.1742928 -0.00554045
#> [26,] 0.804656225 1.1701983 1.32189996
#> [27,] 0.982604299 3.4952552 3.46249589
#> [28,] 0.474354116 -0.1277880 -0.22882001
#> [29,] 0.102155741 -1.9190921 -2.00765173
#> [30,] 0.968806051 3.1060825 3.17289570
#> [31,] 0.824339548 1.1521350 1.18799420
#> [32,] 0.294353408 -0.7900039 -0.92904588
#> [33,] 0.201109472 -1.4751351 -1.57525307
#> [34,] 0.098062166 -2.0725079 -2.24232805
#> [35,] 0.302401122 -0.6993616 -0.88800514
#> [36,] 0.987717998 3.8474351 3.90616473
#> [37,] 0.184798504 -1.3425952 -1.48704354
#> [38,] 0.136682874 -1.6147679 -1.71996768
#> [39,] 0.326037275 -0.7081689 -0.83027635
#> [40,] 0.976006864 3.2579032 3.30817236
#> [41,] 0.810422432 1.1396223 1.17757873
#> [42,] 0.994750482 4.3700935 4.68693832
#> [43,] 0.161946185 -1.5785113 -1.75677686
#> [44,] 0.339264141 -0.7349174 -0.68417378
#> [45,] 0.073996904 -2.3626976 -2.60818772
#> [46,] 0.967268533 2.9719741 3.05826646
#> [47,] 0.186865933 -1.3071884 -1.39496609
#> [48,] 0.204240985 -1.2236820 -1.39463099
#> [49,] 0.984205374 3.4299529 3.54982072
#> [50,] 0.891623155 1.7532572 1.72060104
#>
if (FALSE) {
n <- 50; p <- 100; q <- 3
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Y <- replicate(n=q,expr=rnorm(n=n,mean=rowSums(X[,1:5])))
Y[,1] <- 1*(Y[,1]>median(Y[,1]))
object <- joinet(Y=Y,X=X,family=c("binomial","gaussian","gaussian"))
predict(object,newx=X)}