Skip to contents

MSIR estimates a set of \(d \le p\) orthogonal direction vectors of length \(p\) which are estimates of the basis of the dimensional reduction subspace.

Usage

# S3 method for msir
predict(object, dim = 1:object$numdir, newdata, ...)

Arguments

object

an object of class 'msir' resulting from a call to msir.

dim

the dimensions of the reduced subspace used for prediction.

newdata

a data frame or matrix giving the data. If missing the data obtained from the call to msir are used.

...

further arguments passed to or from other methods.

Value

The function returns a matrix of points projected on the subspace spanned by the estimated basis vectors.

References

Scrucca, L. (2011) Model-based SIR for dimension reduction. Computational Statistics & Data Analysis, 55(11), 3010-3026.

Author

Luca Scrucca luca.scrucca@unipg.it

See also

{msir}

Examples

n <- 200
p <- 5
b <- as.matrix(c(1,-1,rep(0,p-2)))
x <- matrix(rnorm(n*p), nrow = n, ncol = p)
y <- exp(0.5 * x%*%b) + 0.1*rnorm(n)
pairs(cbind(y,x), gap = 0)


MSIR <- msir(x, y)
summary(MSIR)
#> -------------------------------------------------- 
#> Model-based SIR 
#> -------------------------------------------------- 
#> 
#> Slices:
#>           1   2   3   4   5   6  
#> GMM       XII XXX XXX XXX XXX XII
#> Num.comp. 1   1   1   1   1   1  
#> Num.obs.  33  33  33  33  33  35 
#> 
#> Estimated basis vectors:
#>          Dir1      Dir2       Dir3     Dir4     Dir5
#> x1  0.7374534 -0.361945 -0.0671382  0.52247  0.21944
#> x2 -0.6747366 -0.367874 -0.0054716  0.53156  0.34025
#> x3 -0.0252464 -0.062554 -0.6250831 -0.41030  0.68540
#> x4  0.0085002 -0.698346 -0.4165230 -0.20863 -0.47746
#> x5  0.0135438 -0.492000  0.6566903 -0.48228  0.37193
#> 
#>                 Dir1      Dir2      Dir3       Dir4       Dir5
#> Eigenvalues  0.90744  0.061375  0.023872  0.0049141 8.4855e-04
#> Cum. %      90.88494 97.031915 99.422839 99.9150139 1.0000e+02
plot(MSIR, which = 1, type = "2Dplot")

all.equal(predict(MSIR), MSIR$dir)
#> [1] TRUE
predict(MSIR, dim = 1:2)
#>                Dir1         Dir2
#>   [1,]  0.893436562 -1.552799105
#>   [2,] -0.105511799  0.419415173
#>   [3,]  1.131822624 -0.301231606
#>   [4,] -1.355377719  0.462293451
#>   [5,] -1.956196595 -0.428930320
#>   [6,] -1.250022781  1.629015810
#>   [7,]  0.354136377  1.052471099
#>   [8,]  0.730452772 -0.775399672
#>   [9,] -0.746881666 -0.184059026
#>  [10,] -0.598514962 -0.167987980
#>  [11,] -0.602301714 -1.646727554
#>  [12,]  1.138521366 -0.460298220
#>  [13,]  1.494172007  0.824264760
#>  [14,] -0.155223809  0.241579686
#>  [15,] -0.066694652  1.944750561
#>  [16,]  1.436991972 -1.072869909
#>  [17,]  1.828528617  0.583651730
#>  [18,] -0.126026849  0.170089478
#>  [19,] -0.071996429  0.550567151
#>  [20,] -0.424215834  0.795837928
#>  [21,]  1.558944150  0.861121528
#>  [22,] -1.354211416 -1.156756705
#>  [23,]  2.712681974 -0.228847357
#>  [24,] -0.035808765  0.238441420
#>  [25,] -1.828147052 -4.132988602
#>  [26,] -1.080300240  1.008236317
#>  [27,] -2.028741871  0.283319382
#>  [28,]  1.427801066  0.013064141
#>  [29,] -1.714502200 -0.522475853
#>  [30,]  0.124959407 -1.175373266
#>  [31,]  0.922850208  0.379589261
#>  [32,]  0.812984365  0.279170326
#>  [33,]  1.731555527  2.658789272
#>  [34,] -1.085104431  1.254190184
#>  [35,]  0.911235811 -0.664352386
#>  [36,]  0.201762603 -0.227952428
#>  [37,] -1.283090480  0.759177512
#>  [38,] -0.686546968  0.671505029
#>  [39,] -0.488435828 -0.618513371
#>  [40,]  0.127384657 -0.930799157
#>  [41,] -0.539124768 -0.475510011
#>  [42,] -0.828916078  2.155770221
#>  [43,] -0.191808402  0.311295713
#>  [44,]  0.552720781 -0.209470150
#>  [45,] -0.213308546 -1.617871426
#>  [46,] -0.136741910  0.512875197
#>  [47,] -0.680879868  0.917678473
#>  [48,] -0.475981763  0.274991611
#>  [49,] -1.187445083  0.600812450
#>  [50,] -1.761731295  0.484944384
#>  [51,]  1.536941718 -1.207850124
#>  [52,] -0.977944973 -1.991919683
#>  [53,]  1.596762064 -0.163424353
#>  [54,] -0.357965499 -1.158955201
#>  [55,] -0.327684535 -0.683669904
#>  [56,]  0.856355282  1.702132683
#>  [57,] -0.619243076 -1.367204222
#>  [58,] -1.404182183 -0.037346426
#>  [59,]  0.624646199  1.217086310
#>  [60,]  1.824532640 -0.400959730
#>  [61,]  1.758047132 -0.784500710
#>  [62,] -1.198048486 -0.312771920
#>  [63,] -0.610690442  1.990397432
#>  [64,]  0.926724937  1.027716976
#>  [65,]  0.067340429  0.522092257
#>  [66,]  0.553827754  0.801243870
#>  [67,] -0.282901793  1.270940724
#>  [68,] -0.651617907  2.394106316
#>  [69,]  0.290034496  0.457615638
#>  [70,] -0.791020411  0.604005241
#>  [71,] -1.219520893 -1.666985166
#>  [72,]  0.139371348 -0.581513516
#>  [73,]  0.919905409  0.036016942
#>  [74,]  0.764533544  0.083215263
#>  [75,] -1.758280452 -0.565425185
#>  [76,]  0.372725483  1.695130818
#>  [77,]  1.071535382 -0.297670079
#>  [78,] -0.914556102  0.634788789
#>  [79,] -0.277686257  0.445519697
#>  [80,]  0.029727832  1.186724197
#>  [81,] -0.190924627 -0.545414646
#>  [82,] -0.830678875  0.740547916
#>  [83,]  0.162383404  1.107249157
#>  [84,] -0.032569650  1.000004207
#>  [85,]  0.879579931 -0.028210473
#>  [86,]  0.149185352 -0.045381919
#>  [87,]  0.252304688  0.277998361
#>  [88,]  0.667741378  0.763399446
#>  [89,] -0.378317536  0.308261387
#>  [90,]  0.343841134 -0.504693665
#>  [91,] -0.069428542  0.479537039
#>  [92,]  0.495518832 -0.322702388
#>  [93,] -1.093160497 -0.977997468
#>  [94,]  0.316734827  2.480880680
#>  [95,]  0.100631070 -1.125489693
#>  [96,] -2.373830535 -1.160024560
#>  [97,]  1.054521241 -0.708761959
#>  [98,] -0.897074473  0.989853632
#>  [99,]  0.560816400  0.979247354
#> [100,]  1.087704364  1.225496841
#> [101,]  2.427497197 -0.132219597
#> [102,]  0.547886889 -0.506619543
#> [103,] -0.094896425  1.057159878
#> [104,] -0.424656539  1.256101932
#> [105,]  1.455784590 -0.810198351
#> [106,] -2.140693725  0.772579344
#> [107,] -0.707273274  0.022409519
#> [108,] -2.038488646  0.242610233
#> [109,] -0.727948310 -1.296920702
#> [110,]  0.558931062  0.140608296
#> [111,]  0.572422044 -0.199501151
#> [112,] -0.525460021  0.234447566
#> [113,] -0.382128080 -0.844561948
#> [114,] -0.544185929 -0.107990528
#> [115,] -1.412678995  1.099368326
#> [116,] -1.417967181  1.263856332
#> [117,]  0.822684092  0.517581516
#> [118,] -0.109224627  0.512528620
#> [119,]  0.075751818 -0.706607380
#> [120,]  0.146948212 -0.661816081
#> [121,] -0.300434686  1.370605787
#> [122,] -0.198888556 -1.385852166
#> [123,]  0.345536367  0.881926375
#> [124,] -0.688275962  1.042227061
#> [125,] -0.257526866  0.176401054
#> [126,] -0.173890866  2.634416944
#> [127,]  0.750711180  0.001706672
#> [128,] -0.605954956  0.562503437
#> [129,]  1.068170509 -1.892374326
#> [130,]  1.604272452  1.259256005
#> [131,]  1.245846557 -0.118168917
#> [132,] -1.417613953 -1.328467615
#> [133,] -0.008032423  0.653505815
#> [134,] -1.440725908 -0.465310771
#> [135,] -0.765240464  0.513864344
#> [136,] -1.601966687 -1.414724213
#> [137,] -0.057826157 -1.100088377
#> [138,] -0.293432271 -0.658984643
#> [139,]  1.507321479 -1.198624859
#> [140,] -0.569846511 -0.152519587
#> [141,]  0.931005069  1.259847255
#> [142,] -0.724146037  0.155664820
#> [143,]  0.649459743 -3.722943839
#> [144,]  1.704800893 -0.764745558
#> [145,] -0.667880323 -0.217688570
#> [146,] -0.192149449 -0.891757366
#> [147,]  0.341528296 -0.723746092
#> [148,]  0.878385374 -2.074587917
#> [149,] -0.512146373  0.651301235
#> [150,] -0.472187290  0.485875524
#> [151,] -0.710250594  1.575736393
#> [152,]  0.003281998 -1.737541421
#> [153,]  1.809548052 -0.026200127
#> [154,]  0.331587011  0.350195759
#> [155,]  0.069083984 -1.096836115
#> [156,]  0.126078841  0.836663393
#> [157,]  1.636046869 -0.423045878
#> [158,]  0.628204336 -0.128839186
#> [159,]  0.500952853  0.337724072
#> [160,] -0.244477403 -1.148653159
#> [161,]  0.992936611 -1.150149297
#> [162,] -0.049287787 -1.740896744
#> [163,]  0.520322225  0.583110893
#> [164,]  0.309435852  0.652425526
#> [165,]  1.521004037 -0.291081336
#> [166,]  1.426157920 -0.317496412
#> [167,] -0.129592413 -0.071576945
#> [168,] -1.381424787 -1.820111591
#> [169,]  0.623273830 -0.110061652
#> [170,] -0.416422883 -0.068832803
#> [171,]  0.674736226 -0.256200866
#> [172,]  0.798066149 -1.441781229
#> [173,] -0.146102861 -1.738020707
#> [174,]  0.745705020  0.416598032
#> [175,]  0.756228705 -0.321095091
#> [176,]  0.815428315 -1.027121021
#> [177,] -0.665285773  0.806188830
#> [178,]  0.142264498  0.717633582
#> [179,] -0.106836763  1.416462056
#> [180,] -0.840626080  0.522258742
#> [181,] -0.646926190  0.049296036
#> [182,] -0.612535981  1.499462628
#> [183,]  0.931997151  0.976357101
#> [184,] -1.223784510 -0.930702406
#> [185,]  0.306270742  0.252729953
#> [186,] -0.562943567  0.594671412
#> [187,] -1.854302095 -0.484031332
#> [188,]  1.086656444  1.180627101
#> [189,] -0.300123716  0.489319274
#> [190,] -0.412039539  0.289392019
#> [191,]  0.281371968  0.365297973
#> [192,]  1.217884036 -0.270142750
#> [193,] -1.307706577 -0.109968611
#> [194,]  0.515985665 -1.001881363
#> [195,]  0.981142480 -2.092049845
#> [196,] -0.423391348 -0.281899018
#> [197,]  1.162973210  0.120370848
#> [198,] -0.652605646 -0.568508330
#> [199,] -0.283218865 -1.607301964
#> [200,] -1.285713584 -0.731859549

x0 <- matrix(rnorm(n*p), nrow = n, ncol = p)
y0 <- exp(0.5 * x0%*%b) + 0.1*rnorm(n)
plot(predict(MSIR, dim = 1, newdata = x0), y0)