fortify.MSM.lm: Convert 'MSwM::MSM.lm' to 'data.frame'

Description Usage Arguments Value Examples

View source: R/fortify_MSwM.R

Description

Convert MSwM::MSM.lm to data.frame

Usage

1
2
## S3 method for class 'MSM.lm'
fortify(model, data = NULL, melt = FALSE, ...)

Arguments

model

MSwM::MSM.lm instance

data

original dataset, if needed

melt

Logical flag indicating whether to melt each models

...

other arguments passed to methods

Value

data.frame

Examples

1
2
3
4
5
6
library(MSwM)
d <- data.frame(Data = c(rnorm(50, mean = -10), rnorm(50, mean = 10)),
                exog = cos(seq(-pi/2, pi/2, length.out = 100)))
d.mswm <- MSwM::msmFit(lm(Data ~.-1, data = d), k=2, sw=rep(TRUE, 2),
                       control = list(parallelization = FALSE))
fortify(d.mswm)

Example output

Loading required package: ggplot2
Loading required package: parallel
    Index       Data         exog       Fitted  Residuals   FiltProb.1
1       1  -9.454536 6.123234e-17 7.105427e-15  -9.454536 9.991525e-01
2       2 -11.397515 3.172793e-02 1.882476e-04 -11.397703 9.989584e-01
3       3 -11.169835 6.342392e-02 3.763057e-04 -11.170211 9.992443e-01
4       4 -11.231160 9.505604e-02 5.639848e-04 -11.231724 9.995875e-01
5       5  -9.577638 1.265925e-01 7.510961e-04  -9.578389 9.997236e-01
6       6  -9.343181 1.580014e-01 9.374511e-04  -9.344118 9.998212e-01
7       7 -10.032693 1.892512e-01 1.122862e-03 -10.033816 9.999035e-01
8       8  -7.190369 2.203105e-01 1.307143e-03  -7.191676 9.998660e-01
9       9  -8.699784 2.511480e-01 1.490107e-03  -8.701274 9.999346e-01
10     10 -10.304542 2.817326e-01 1.671571e-03 -10.306214 9.999752e-01
11     11  -8.758893 3.120334e-01 1.851351e-03  -8.760744 9.999704e-01
12     12 -10.642209 3.420201e-01 2.029268e-03 -10.644238 9.999905e-01
13     13 -10.562292 3.716625e-01 2.205141e-03 -10.564497 9.999935e-01
14     14  -9.369127 4.009305e-01 2.378794e-03  -9.371506 9.999919e-01
15     15  -9.869524 4.297949e-01 2.550052e-03  -9.872074 9.999956e-01
16     16  -9.248582 4.582265e-01 2.718741e-03  -9.251301 9.999956e-01
17     17 -10.167929 4.861967e-01 2.884694e-03 -10.170813 9.999982e-01
18     18 -12.735680 5.136774e-01 3.047742e-03 -12.738728 9.999998e-01
19     19  -8.911101 5.406408e-01 3.207720e-03  -8.914309 9.999979e-01
20     20 -11.518295 5.670599e-01 3.364469e-03 -11.521659 9.999997e-01
21     21  -9.952423 5.929079e-01 3.517831e-03  -9.955941 9.999994e-01
22     22  -7.455535 6.181590e-01 3.667650e-03  -7.459203 9.999972e-01
23     23 -10.835780 6.427876e-01 3.813776e-03 -10.839594 9.999999e-01
24     24 -10.948840 6.667690e-01 3.956062e-03 -10.952796 9.999999e-01
25     25  -9.843542 6.900790e-01 4.094365e-03  -9.847636 9.999998e-01
26     26 -10.465926 7.126942e-01 4.228544e-03 -10.470155 9.999999e-01
27     27 -10.066023 7.345917e-01 4.358466e-03 -10.070382 9.999999e-01
28     28  -9.245252 7.557496e-01 4.484000e-03  -9.249736 9.999999e-01
29     29  -8.926756 7.761465e-01 4.605018e-03  -8.931361 9.999998e-01
30     30  -7.677072 7.957618e-01 4.721400e-03  -7.681794 9.999996e-01
31     31  -8.388324 8.145760e-01 4.833028e-03  -8.393157 9.999998e-01
32     32 -11.785295 8.325699e-01 4.939789e-03 -11.790235 1.000000e+00
33     33 -10.138871 8.497254e-01 5.041576e-03 -10.143913 1.000000e+00
34     34 -10.570321 8.660254e-01 5.138287e-03 -10.575460 1.000000e+00
35     35 -11.279152 8.814534e-01 5.229823e-03 -11.284382 1.000000e+00
36     36  -9.583589 8.959938e-01 5.316094e-03  -9.588905 1.000000e+00
37     37  -9.551346 9.096320e-01 5.397012e-03  -9.556743 1.000000e+00
38     38  -9.541324 9.223543e-01 5.472496e-03  -9.546796 1.000000e+00
39     39 -11.906134 9.341479e-01 5.542469e-03 -11.911677 1.000000e+00
40     40 -11.245333 9.450008e-01 5.606862e-03 -11.250939 1.000000e+00
41     41  -8.542429 9.549022e-01 5.665609e-03  -8.548094 1.000000e+00
42     42  -9.523170 9.638422e-01 5.718651e-03  -9.528889 1.000000e+00
43     43  -8.327151 9.718116e-01 5.765935e-03  -8.332917 1.000000e+00
44     44  -9.653859 9.788024e-01 5.807413e-03  -9.659667 1.000000e+00
45     45  -9.547587 9.848078e-01 5.843044e-03  -9.553430 1.000000e+00
46     46  -9.458208 9.898214e-01 5.872791e-03  -9.464081 1.000000e+00
47     47 -12.430251 9.938385e-01 5.896625e-03 -12.436147 1.000000e+00
48     48 -10.314295 9.968548e-01 5.914521e-03 -10.320210 1.000000e+00
49     49 -11.414278 9.988673e-01 5.926462e-03 -11.420205 1.000000e+00
50     50 -10.903844 9.998741e-01 5.932435e-03 -10.909776 1.000000e+00
51     51   9.453569 9.998741e-01 5.932435e-03   9.447637 1.044737e-02
52     52  10.520919 9.988673e-01 5.926462e-03  10.514992 7.835767e-08
53     53  11.530170 9.968548e-01 5.914521e-03  11.524255 1.530606e-08
54     54   9.671603 9.938385e-01 5.896625e-03   9.665706 1.545655e-07
55     55   7.684870 9.898214e-01 5.872791e-03   7.678997 1.821803e-06
56     56  11.349526 9.848078e-01 5.843044e-03  11.343683 2.257740e-08
57     57   9.249633 9.788024e-01 5.807413e-03   9.243826 3.068223e-07
58     58   9.338132 9.718116e-01 5.765935e-03   9.332366 2.987315e-07
59     59   8.635123 9.638422e-01 5.718651e-03   8.629405 7.528529e-07
60     60   8.785947 9.549022e-01 5.665609e-03   8.780281 6.929892e-07
61     61  10.715731 9.450008e-01 5.606862e-03  10.710124 8.192848e-08
62     62  11.044811 9.341479e-01 5.542469e-03  11.039269 6.476243e-08
63     63   9.531149 9.223543e-01 5.472496e-03   9.525677 4.221522e-07
64     64   9.429244 9.096320e-01 5.397012e-03   9.423847 5.487575e-07
65     65  10.013762 8.959938e-01 5.316094e-03  10.008446 3.374816e-07
66     66  10.915381 8.814534e-01 5.229823e-03  10.910151 1.520127e-07
67     67  11.498851 8.660254e-01 5.138287e-03  11.493713 1.005205e-07
68     68   9.740239 8.497254e-01 5.041576e-03   9.735197 7.918262e-07
69     69  10.425463 8.325699e-01 4.939789e-03  10.420524 4.823451e-07
70     70   8.121695 8.145760e-01 4.833028e-03   8.116862 6.084716e-06
71     71  10.396189 7.957618e-01 4.721400e-03  10.391468 7.947087e-07
72     72  10.503206 7.761465e-01 4.605018e-03  10.498601 9.214225e-07
73     73  11.431443 7.557496e-01 4.484000e-03  11.426959 5.071714e-07
74     74   9.329822 7.345917e-01 4.358466e-03   9.325463 4.530756e-06
75     75  11.174852 7.126942e-01 4.228544e-03  11.170623 1.161424e-06
76     76   9.754194 6.900790e-01 4.094365e-03   9.750099 5.264888e-06
77     77  11.481257 6.667690e-01 3.956062e-03  11.477301 1.699061e-06
78     78  10.045317 6.427876e-01 3.813776e-03  10.041503 7.374586e-06
79     79  10.811168 6.181590e-01 3.667650e-03  10.807500 5.600097e-06
80     80  10.347830 5.929079e-01 3.517831e-03  10.344312 1.096014e-05
81     81  11.767605 5.670599e-01 3.364469e-03  11.764240 5.695375e-06
82     82  10.639182 5.406408e-01 3.207720e-03  10.635974 1.757918e-05
83     83   9.269020 5.136774e-01 3.047742e-03   9.265972 5.915407e-05
84     84  10.919825 4.861967e-01 2.884694e-03  10.916940 3.043525e-05
85     85   9.285205 4.582265e-01 2.718741e-03   9.282486 1.103578e-04
86     86  11.283765 4.297949e-01 2.550052e-03  11.281215 5.384550e-05
87     87   6.933079 4.009305e-01 2.378794e-03   6.930700 6.722811e-04
88     88  10.193877 3.716625e-01 2.205141e-03  10.191672 2.030818e-04
89     89   8.431644 3.420201e-01 2.029268e-03   8.429614 5.990409e-04
90     90  10.680572 3.120334e-01 1.851351e-03  10.678720 3.560970e-04
91     91   9.945079 2.817326e-01 1.671571e-03   9.943408 6.735214e-04
92     92   8.284977 2.511480e-01 1.490107e-03   8.283487 1.645819e-03
93     93  11.124540 2.203105e-01 1.307143e-03  11.123233 1.113689e-03
94     94  10.203508 1.892512e-01 1.122862e-03  10.202385 2.046838e-03
95     95   8.604356 1.580014e-01 9.374511e-04   8.603418 4.270537e-03
96     96   9.636581 1.265925e-01 7.510961e-04   9.635830 5.620247e-03
97     97   8.989039 9.505604e-02 5.639848e-04   8.988475 9.245066e-03
98     98  10.410036 6.342392e-02 3.763057e-04  10.409660 1.352386e-02
99     99  11.135220 3.172793e-02 1.882476e-04  11.135032 2.264278e-02
100   100   9.962006 6.123234e-17 0.000000e+00   9.962006 4.348702e-02
      FiltProb.2    SmoProb.1    SmoProb.2 ProbableModel
1   8.475391e-04 9.999675e-01 3.246781e-05             1
2   1.041629e-03 9.999683e-01 3.165778e-05             1
3   7.556980e-04 9.999801e-01 1.991329e-05             1
4   4.124748e-04 9.999897e-01 1.032999e-05             1
5   2.764305e-04 9.999935e-01 6.483528e-06             1
6   1.788082e-04 9.999960e-01 3.957436e-06             1
7   9.654831e-05 9.999978e-01 2.216751e-06             1
8   1.339698e-04 9.999971e-01 2.863228e-06             1
9   6.542889e-05 9.999987e-01 1.347252e-06             1
10  2.477123e-05 9.999995e-01 5.129791e-07             1
11  2.957636e-05 9.999994e-01 5.992871e-07             1
12  9.528674e-06 9.999998e-01 1.924762e-07             1
13  6.539169e-06 9.999999e-01 1.323175e-07             1
14  8.098721e-06 9.999998e-01 1.632036e-07             1
15  4.424537e-06 9.999999e-01 8.916409e-08             1
16  4.440721e-06 9.999999e-01 8.922992e-08             1
17  1.838021e-06 1.000000e+00 3.686670e-08             1
18  2.472474e-07 1.000000e+00 4.969847e-09             1
19  2.149579e-06 1.000000e+00 4.311612e-08             1
20  2.524646e-07 1.000000e+00 5.065649e-09             1
21  5.559708e-07 1.000000e+00 1.118347e-08             1
22  2.793234e-06 9.999999e-01 5.601994e-08             1
23  1.476745e-07 1.000000e+00 2.961523e-09             1
24  9.692987e-08 1.000000e+00 1.944058e-09             1
25  1.828668e-07 1.000000e+00 3.667212e-09             1
26  7.961893e-08 1.000000e+00 1.596691e-09             1
27  8.631696e-08 1.000000e+00 1.731125e-09             1
28  1.434585e-07 1.000000e+00 2.877161e-09             1
29  1.542680e-07 1.000000e+00 3.094904e-09             1
30  4.277432e-07 1.000000e+00 8.578873e-09             1
31  1.735588e-07 1.000000e+00 3.480255e-09             1
32  4.223497e-09 1.000000e+00 8.469224e-11             1
33  1.879516e-08 1.000000e+00 3.768886e-10             1
34  9.594942e-09 1.000000e+00 1.924006e-10             1
35  3.590377e-09 1.000000e+00 7.199656e-11             1
36  1.943898e-08 1.000000e+00 3.898020e-10             1
37  1.712143e-08 1.000000e+00 3.433283e-10             1
38  1.487682e-08 1.000000e+00 2.983134e-10             1
39  8.232242e-10 1.000000e+00 1.650749e-11             1
40  1.526290e-09 1.000000e+00 3.060663e-11             1
41  3.306635e-08 1.000000e+00 6.630602e-10             1
42  9.264215e-09 1.000000e+00 1.857755e-10             1
43  3.579274e-08 1.000000e+00 7.177288e-10             1
44  6.609500e-09 1.000000e+00 1.325361e-10             1
45  7.002006e-09 1.000000e+00 1.404068e-10             1
46  7.362447e-09 1.000000e+00 1.476334e-10             1
47  1.769698e-10 1.000000e+00 3.548644e-12             1
48  2.340608e-09 1.000000e+00 4.693439e-11             1
49  5.800988e-10 1.000000e+00 1.242538e-11             1
50  1.080149e-09 9.999988e-01 1.215236e-06             1
51  9.895526e-01 9.383901e-06 9.999906e-01             2
52  9.999999e-01 6.964666e-11 1.000000e+00             2
53  1.000000e+00 1.360458e-11 1.000000e+00             2
54  9.999998e-01 1.373949e-10 1.000000e+00             2
55  9.999982e-01 1.619277e-09 1.000000e+00             2
56  1.000000e+00 2.006776e-11 1.000000e+00             2
57  9.999997e-01 2.727168e-10 1.000000e+00             2
58  9.999997e-01 2.655314e-10 1.000000e+00             2
59  9.999992e-01 6.691814e-10 1.000000e+00             2
60  9.999993e-01 6.159521e-10 1.000000e+00             2
61  9.999999e-01 7.282068e-11 1.000000e+00             2
62  9.999999e-01 5.756397e-11 1.000000e+00             2
63  9.999996e-01 3.752317e-10 1.000000e+00             2
64  9.999995e-01 4.877603e-10 1.000000e+00             2
65  9.999997e-01 2.999659e-10 1.000000e+00             2
66  9.999998e-01 1.351140e-10 1.000000e+00             2
67  9.999999e-01 8.934909e-11 1.000000e+00             2
68  9.999992e-01 7.038159e-10 1.000000e+00             2
69  9.999995e-01 4.288528e-10 1.000000e+00             2
70  9.999939e-01 5.408522e-09 1.000000e+00             2
71  9.999992e-01 7.063934e-10 1.000000e+00             2
72  9.999991e-01 8.190089e-10 1.000000e+00             2
73  9.999995e-01 4.508909e-10 1.000000e+00             2
74  9.999955e-01 4.027321e-09 1.000000e+00             2
75  9.999988e-01 1.032580e-09 1.000000e+00             2
76  9.999947e-01 4.680009e-09 1.000000e+00             2
77  9.999983e-01 1.510733e-09 1.000000e+00             2
78  9.999926e-01 6.556628e-09 1.000000e+00             2
79  9.999944e-01 4.980279e-09 1.000000e+00             2
80  9.999890e-01 9.744567e-09 1.000000e+00             2
81  9.999943e-01 5.066695e-09 1.000000e+00             2
82  9.999824e-01 1.567129e-08 1.000000e+00             2
83  9.999408e-01 5.266100e-08 9.999999e-01             2
84  9.999696e-01 2.720165e-08 1.000000e+00             2
85  9.998896e-01 9.837090e-08 9.999999e-01             2
86  9.999462e-01 4.947961e-08 1.000000e+00             2
87  9.993277e-01 6.039816e-07 9.999994e-01             2
88  9.997969e-01 1.859797e-07 9.999998e-01             2
89  9.994010e-01 5.422833e-07 9.999995e-01             2
90  9.996439e-01 3.279823e-07 9.999997e-01             2
91  9.993265e-01 6.508499e-07 9.999993e-01             2
92  9.983542e-01 1.593028e-06 9.999984e-01             2
93  9.988863e-01 1.681900e-06 9.999983e-01             2
94  9.979532e-01 1.311744e-05 9.999869e-01             2
95  9.957295e-01 1.217182e-04 9.998783e-01             2
96  9.943798e-01 6.691819e-04 9.993308e-01             2
97  9.907549e-01 3.020527e-03 9.969795e-01             2
98  9.864761e-01 9.485503e-03 9.905145e-01             2
99  9.773572e-01 2.333042e-02 9.766696e-01             2
100 9.565130e-01 4.348702e-02 9.565130e-01             2

ggfortify documentation built on July 8, 2021, 1:07 a.m.