Skip to contents

This function provides a matrix containing the class-specific predicted trajectories computed in the latent process scale, that is the latent process underlying the curvilinear outcome(s), for a profile of covariates specified by the user. This function applies only to lcmm and multlcmm objects. The function plot.predict provides directly the plot of these class-specific predicted trajectories. The function predictY provides the class-specific predicted trajectories computed in the natural scale of the outcome(s).

Usage

predictL(x, newdata, var.time, na.action = 1, confint = FALSE, ...)

Arguments

x

an object inheriting from class lcmm,multlcmm or Jointlcmm representing a (joint) (latent class) mixed model involving a latent process and estimated link function(s).

newdata

data frame containing the data from which predictions are computed. The data frame should include at least all the covariates listed in x$Xnames2. Names in the data frame should be exactly x$Xnames2 that are the names of covariates specified in lcmm or multlcmm calls.

var.time

A character string containing the name of the variable that corresponds to time in the data frame (x axis in the plot).

na.action

Integer indicating how NAs are managed. The default is 1 for 'na.omit'. The alternative is 2 for 'na.fail'. Other options such as 'na.pass' or 'na.exclude' are not implemented in the current version.

confint

logical indicating if confidence should be provided. Default to FALSE.

...

further arguments to be passed to or from other methods. They are ignored in this function.

Value

An object of class predictL with values :

- pred : a matrix containing the class-specific predicted values in the latent process scale, the lower and the upper limits of the confidence intervals (if calculated).

- times : the var.time variable from newdata

Author

Cecile Proust-Lima, Viviane Philipps

Examples


#### Prediction from a 2-class model with a Splines link function
# \dontrun{
## fitted model
m<-lcmm(Ydep2~Time*X1,mixture=~Time,random=~Time,classmb=~X2+X3,
subject='ID',ng=2,data=data_lcmm,link="splines",B=c(
-0.175,      -0.191,       0.654,      -0.443, 
-0.345,      -1.780,       0.913,       0.016, 
 0.389,       0.028,       0.083,      -7.349, 
 0.722,       0.770,       1.376,       1.653, 
 1.640,       1.285))
summary(m)
#> General latent class mixed model 
#>      fitted by maximum likelihood method 
#>  
#> lcmm(fixed = Ydep2 ~ Time * X1, mixture = ~Time, random = ~Time, 
#>     subject = "ID", classmb = ~X2 + X3, ng = 2, link = "splines", 
#>     data = data_lcmm)
#>  
#> Statistical Model: 
#>      Dataset: data_lcmm 
#>      Number of subjects: 300 
#>      Number of observations: 1678 
#>      Number of latent classes: 2 
#>      Number of parameters: 18  
#>      Link function: Quadratic I-splines with nodes  
#> 0 7.5 15 22.5 30  
#>  
#> Iteration process: 
#>      Convergence criteria satisfied 
#>      Number of iterations:  2 
#>      Convergence criteria: parameters= 2.9e-07 
#>                          : likelihood= 1.8e-06 
#>                          : second derivatives= 1.1e-09 
#>  
#> Goodness-of-fit statistics: 
#>      maximum log-likelihood: -3960.43  
#>      AIC: 7956.86  
#>      BIC: 8023.52  
#>  
#>      Discrete posterior log-likelihood: -3946.06  
#>      Discrete AIC: 7928.12  
#>  
#>      Mean discrete AIC per subject: 13.2135  
#>      Mean UACV per subject: 13.2152  
#>      Mean discrete LL per subject: -13.1535  
#>  
#> Maximum Likelihood Estimates: 
#>  
#> Fixed effects in the class-membership model:
#> (the class of reference is the last class) 
#> 
#>                      coef      Se    Wald p-value
#> intercept class1 -0.17512 0.23496  -0.745 0.45610
#> X2 class1        -0.19156 0.35836  -0.535 0.59295
#> X3 class1         0.65455 0.19492   3.358 0.00079
#> 
#> Fixed effects in the longitudinal model:
#> 
#>                                      coef      Se    Wald p-value
#> intercept class1 (not estimated)        0                        
#> intercept class2                 -0.44319 0.19768  -2.242 0.02496
#> Time class1                      -0.34568 0.11917  -2.901 0.00372
#> Time class2                      -1.78053 0.14188 -12.550 0.00000
#> X1                                0.91348 0.14896   6.133 0.00000
#> Time:X1                           0.01635 0.14302   0.114 0.90899
#> 
#> 
#> Variance-covariance matrix of the random-effects:
#>           intercept    Time
#> intercept   0.38917        
#> Time        0.02830 0.08307
#> 
#> Residual standard error (not estimated) = 1
#> 
#> Parameters of the link function:
#> 
#>                coef      Se    Wald p-value
#> I-splines1 -7.34981 0.56642 -12.976 0.00000
#> I-splines2  0.72200 0.26698   2.704 0.00684
#> I-splines3  0.77031 0.40833   1.886 0.05923
#> I-splines4  1.37681 0.13169  10.455 0.00000
#> I-splines5  1.65381 0.06419  25.763 0.00000
#> I-splines6  1.64064 0.04902  33.467 0.00000
#> I-splines7  1.28585 0.05117  25.130 0.00000
#> 
## predictions for times from 0 to 5 for X1=0
newdata<-data.frame(Time=seq(0,5,length=100),
X1=rep(0,100),X2=rep(0,100),X3=rep(0,100))
predictL(m,newdata,var.time="Time")
#> $pred
#>        pred_class1 pred_class2
#>   [1,]  0.00000000  -0.4431914
#>   [2,] -0.01745865  -0.5331172
#>   [3,] -0.03491730  -0.6230430
#>   [4,] -0.05237596  -0.7129689
#>   [5,] -0.06983461  -0.8028947
#>   [6,] -0.08729326  -0.8928205
#>   [7,] -0.10475191  -0.9827463
#>   [8,] -0.12221056  -1.0726721
#>   [9,] -0.13966922  -1.1625979
#>  [10,] -0.15712787  -1.2525237
#>  [11,] -0.17458652  -1.3424496
#>  [12,] -0.19204517  -1.4323754
#>  [13,] -0.20950382  -1.5223012
#>  [14,] -0.22696247  -1.6122270
#>  [15,] -0.24442113  -1.7021528
#>  [16,] -0.26187978  -1.7920786
#>  [17,] -0.27933843  -1.8820044
#>  [18,] -0.29679708  -1.9719303
#>  [19,] -0.31425573  -2.0618561
#>  [20,] -0.33171439  -2.1517819
#>  [21,] -0.34917304  -2.2417077
#>  [22,] -0.36663169  -2.3316335
#>  [23,] -0.38409034  -2.4215593
#>  [24,] -0.40154899  -2.5114851
#>  [25,] -0.41900765  -2.6014110
#>  [26,] -0.43646630  -2.6913368
#>  [27,] -0.45392495  -2.7812626
#>  [28,] -0.47138360  -2.8711884
#>  [29,] -0.48884225  -2.9611142
#>  [30,] -0.50630090  -3.0510400
#>  [31,] -0.52375956  -3.1409658
#>  [32,] -0.54121821  -3.2308917
#>  [33,] -0.55867686  -3.3208175
#>  [34,] -0.57613551  -3.4107433
#>  [35,] -0.59359416  -3.5006691
#>  [36,] -0.61105282  -3.5905949
#>  [37,] -0.62851147  -3.6805207
#>  [38,] -0.64597012  -3.7704465
#>  [39,] -0.66342877  -3.8603724
#>  [40,] -0.68088742  -3.9502982
#>  [41,] -0.69834608  -4.0402240
#>  [42,] -0.71580473  -4.1301498
#>  [43,] -0.73326338  -4.2200756
#>  [44,] -0.75072203  -4.3100014
#>  [45,] -0.76818068  -4.3999272
#>  [46,] -0.78563933  -4.4898531
#>  [47,] -0.80309799  -4.5797789
#>  [48,] -0.82055664  -4.6697047
#>  [49,] -0.83801529  -4.7596305
#>  [50,] -0.85547394  -4.8495563
#>  [51,] -0.87293259  -4.9394821
#>  [52,] -0.89039125  -5.0294079
#>  [53,] -0.90784990  -5.1193338
#>  [54,] -0.92530855  -5.2092596
#>  [55,] -0.94276720  -5.2991854
#>  [56,] -0.96022585  -5.3891112
#>  [57,] -0.97768451  -5.4790370
#>  [58,] -0.99514316  -5.5689628
#>  [59,] -1.01260181  -5.6588886
#>  [60,] -1.03006046  -5.7488145
#>  [61,] -1.04751911  -5.8387403
#>  [62,] -1.06497777  -5.9286661
#>  [63,] -1.08243642  -6.0185919
#>  [64,] -1.09989507  -6.1085177
#>  [65,] -1.11735372  -6.1984435
#>  [66,] -1.13481237  -6.2883693
#>  [67,] -1.15227102  -6.3782952
#>  [68,] -1.16972968  -6.4682210
#>  [69,] -1.18718833  -6.5581468
#>  [70,] -1.20464698  -6.6480726
#>  [71,] -1.22210563  -6.7379984
#>  [72,] -1.23956428  -6.8279242
#>  [73,] -1.25702294  -6.9178500
#>  [74,] -1.27448159  -7.0077759
#>  [75,] -1.29194024  -7.0977017
#>  [76,] -1.30939889  -7.1876275
#>  [77,] -1.32685754  -7.2775533
#>  [78,] -1.34431620  -7.3674791
#>  [79,] -1.36177485  -7.4574049
#>  [80,] -1.37923350  -7.5473307
#>  [81,] -1.39669215  -7.6372566
#>  [82,] -1.41415080  -7.7271824
#>  [83,] -1.43160945  -7.8171082
#>  [84,] -1.44906811  -7.9070340
#>  [85,] -1.46652676  -7.9969598
#>  [86,] -1.48398541  -8.0868856
#>  [87,] -1.50144406  -8.1768114
#>  [88,] -1.51890271  -8.2667373
#>  [89,] -1.53636137  -8.3566631
#>  [90,] -1.55382002  -8.4465889
#>  [91,] -1.57127867  -8.5365147
#>  [92,] -1.58873732  -8.6264405
#>  [93,] -1.60619597  -8.7163663
#>  [94,] -1.62365463  -8.8062921
#>  [95,] -1.64111328  -8.8962180
#>  [96,] -1.65857193  -8.9861438
#>  [97,] -1.67603058  -9.0760696
#>  [98,] -1.69348923  -9.1659954
#>  [99,] -1.71094788  -9.2559212
#> [100,] -1.72840654  -9.3458470
#> 
#> $times
#>           Time
#> 1   0.00000000
#> 2   0.05050505
#> 3   0.10101010
#> 4   0.15151515
#> 5   0.20202020
#> 6   0.25252525
#> 7   0.30303030
#> 8   0.35353535
#> 9   0.40404040
#> 10  0.45454545
#> 11  0.50505051
#> 12  0.55555556
#> 13  0.60606061
#> 14  0.65656566
#> 15  0.70707071
#> 16  0.75757576
#> 17  0.80808081
#> 18  0.85858586
#> 19  0.90909091
#> 20  0.95959596
#> 21  1.01010101
#> 22  1.06060606
#> 23  1.11111111
#> 24  1.16161616
#> 25  1.21212121
#> 26  1.26262626
#> 27  1.31313131
#> 28  1.36363636
#> 29  1.41414141
#> 30  1.46464646
#> 31  1.51515152
#> 32  1.56565657
#> 33  1.61616162
#> 34  1.66666667
#> 35  1.71717172
#> 36  1.76767677
#> 37  1.81818182
#> 38  1.86868687
#> 39  1.91919192
#> 40  1.96969697
#> 41  2.02020202
#> 42  2.07070707
#> 43  2.12121212
#> 44  2.17171717
#> 45  2.22222222
#> 46  2.27272727
#> 47  2.32323232
#> 48  2.37373737
#> 49  2.42424242
#> 50  2.47474747
#> 51  2.52525253
#> 52  2.57575758
#> 53  2.62626263
#> 54  2.67676768
#> 55  2.72727273
#> 56  2.77777778
#> 57  2.82828283
#> 58  2.87878788
#> 59  2.92929293
#> 60  2.97979798
#> 61  3.03030303
#> 62  3.08080808
#> 63  3.13131313
#> 64  3.18181818
#> 65  3.23232323
#> 66  3.28282828
#> 67  3.33333333
#> 68  3.38383838
#> 69  3.43434343
#> 70  3.48484848
#> 71  3.53535354
#> 72  3.58585859
#> 73  3.63636364
#> 74  3.68686869
#> 75  3.73737374
#> 76  3.78787879
#> 77  3.83838384
#> 78  3.88888889
#> 79  3.93939394
#> 80  3.98989899
#> 81  4.04040404
#> 82  4.09090909
#> 83  4.14141414
#> 84  4.19191919
#> 85  4.24242424
#> 86  4.29292929
#> 87  4.34343434
#> 88  4.39393939
#> 89  4.44444444
#> 90  4.49494949
#> 91  4.54545455
#> 92  4.59595960
#> 93  4.64646465
#> 94  4.69696970
#> 95  4.74747475
#> 96  4.79797980
#> 97  4.84848485
#> 98  4.89898990
#> 99  4.94949495
#> 100 5.00000000
#> 
#> attr(,"class")
#> [1] "predictL"
## predictions for times from 0 to 5 for X1=1
newdata$X1 <- 1
predictY(m,newdata,var.time="Time")
#> $pred
#>        Ypred_class1 Ypred_class2
#>   [1,]     26.86654    26.093656
#>   [2,]     26.83833    25.929600
#>   [3,]     26.80998    25.764062
#>   [4,]     26.78153    25.597010
#>   [5,]     26.75295    25.428430
#>   [6,]     26.72425    25.258264
#>   [7,]     26.69543    25.086491
#>   [8,]     26.66650    24.913101
#>   [9,]     26.63745    24.736599
#>  [10,]     26.60825    24.558394
#>  [11,]     26.57897    24.378220
#>  [12,]     26.54954    24.196194
#>  [13,]     26.51999    24.012331
#>  [14,]     26.49032    23.826628
#>  [15,]     26.46053    23.639031
#>  [16,]     26.43063    23.449497
#>  [17,]     26.40058    23.257993
#>  [18,]     26.37042    23.064460
#>  [19,]     26.34014    22.868868
#>  [20,]     26.30973    22.671032
#>  [21,]     26.27551    22.471003
#>  [22,]     26.24444    22.268730
#>  [23,]     26.21323    22.064193
#>  [24,]     26.18186    21.857318
#>  [25,]     26.15038    21.648047
#>  [26,]     26.11876    21.436368
#>  [27,]     26.08700    21.222151
#>  [28,]     26.05513    21.005367
#>  [29,]     26.02313    20.785921
#>  [30,]     25.99100    20.563747
#>  [31,]     25.95874    20.338764
#>  [32,]     25.92635    20.110921
#>  [33,]     25.89387    19.880139
#>  [34,]     25.86126    19.646256
#>  [35,]     25.82852    19.409219
#>  [36,]     25.79566    19.168915
#>  [37,]     25.76270    18.925199
#>  [38,]     25.72960    18.677957
#>  [39,]     25.69642    18.426995
#>  [40,]     25.66308    18.172234
#>  [41,]     25.62965    17.914179
#>  [42,]     25.59609    17.652444
#>  [43,]     25.56243    17.386596
#>  [44,]     25.52862    17.116584
#>  [45,]     25.49473    16.842272
#>  [46,]     25.46072    16.563483
#>  [47,]     25.42657    16.279932
#>  [48,]     25.39230    15.991300
#>  [49,]     25.35791    15.697466
#>  [50,]     25.32342    15.402078
#>  [51,]     25.28878    15.104793
#>  [52,]     25.25404    14.802168
#>  [53,]     25.21918    14.494476
#>  [54,]     25.18418    14.181951
#>  [55,]     25.14908    13.864671
#>  [56,]     25.11383    13.542504
#>  [57,]     25.07848    13.215046
#>  [58,]     25.04298    12.881765
#>  [59,]     25.00736    12.542549
#>  [60,]     24.97163    12.220935
#>  [61,]     24.93576    11.899501
#>  [62,]     24.89974    11.571886
#>  [63,]     24.86361    11.239108
#>  [64,]     24.82736    10.902179
#>  [65,]     24.79094    10.561970
#>  [66,]     24.75442    10.219008
#>  [67,]     24.71774     9.873385
#>  [68,]     24.68095     9.524742
#>  [69,]     24.64400     9.172386
#>  [70,]     24.60692     8.822232
#>  [71,]     24.56971     8.536943
#>  [72,]     24.53236     8.244459
#>  [73,]     24.49487     7.945917
#>  [74,]     24.45721     7.642777
#>  [75,]     24.41943     7.336671
#>  [76,]     24.38151     7.029192
#>  [77,]     24.34343     6.721653
#>  [78,]     24.30520     6.414984
#>  [79,]     24.26683     6.109628
#>  [80,]     24.22829     5.805566
#>  [81,]     24.18962     5.502358
#>  [82,]     24.15077     5.199329
#>  [83,]     24.11177     5.008255
#>  [84,]     24.07264     4.812659
#>  [85,]     24.03335     4.611975
#>  [86,]     23.99390     4.407093
#>  [87,]     23.95426     4.199179
#>  [88,]     23.91446     3.989567
#>  [89,]     23.87450     3.779634
#>  [90,]     23.83437     3.570649
#>  [91,]     23.79404     3.363655
#>  [92,]     23.75355     3.159381
#>  [93,]     23.71290     2.958247
#>  [94,]     23.67207     2.760384
#>  [95,]     23.63106     2.565667
#>  [96,]     23.58989     2.373786
#>  [97,]     23.54854     2.274609
#>  [98,]     23.50702     2.186959
#>  [99,]     23.46532     2.096579
#> [100,]     23.42345     2.003659
#> 
#> $times
#>           Time
#> 1   0.00000000
#> 2   0.05050505
#> 3   0.10101010
#> 4   0.15151515
#> 5   0.20202020
#> 6   0.25252525
#> 7   0.30303030
#> 8   0.35353535
#> 9   0.40404040
#> 10  0.45454545
#> 11  0.50505051
#> 12  0.55555556
#> 13  0.60606061
#> 14  0.65656566
#> 15  0.70707071
#> 16  0.75757576
#> 17  0.80808081
#> 18  0.85858586
#> 19  0.90909091
#> 20  0.95959596
#> 21  1.01010101
#> 22  1.06060606
#> 23  1.11111111
#> 24  1.16161616
#> 25  1.21212121
#> 26  1.26262626
#> 27  1.31313131
#> 28  1.36363636
#> 29  1.41414141
#> 30  1.46464646
#> 31  1.51515152
#> 32  1.56565657
#> 33  1.61616162
#> 34  1.66666667
#> 35  1.71717172
#> 36  1.76767677
#> 37  1.81818182
#> 38  1.86868687
#> 39  1.91919192
#> 40  1.96969697
#> 41  2.02020202
#> 42  2.07070707
#> 43  2.12121212
#> 44  2.17171717
#> 45  2.22222222
#> 46  2.27272727
#> 47  2.32323232
#> 48  2.37373737
#> 49  2.42424242
#> 50  2.47474747
#> 51  2.52525253
#> 52  2.57575758
#> 53  2.62626263
#> 54  2.67676768
#> 55  2.72727273
#> 56  2.77777778
#> 57  2.82828283
#> 58  2.87878788
#> 59  2.92929293
#> 60  2.97979798
#> 61  3.03030303
#> 62  3.08080808
#> 63  3.13131313
#> 64  3.18181818
#> 65  3.23232323
#> 66  3.28282828
#> 67  3.33333333
#> 68  3.38383838
#> 69  3.43434343
#> 70  3.48484848
#> 71  3.53535354
#> 72  3.58585859
#> 73  3.63636364
#> 74  3.68686869
#> 75  3.73737374
#> 76  3.78787879
#> 77  3.83838384
#> 78  3.88888889
#> 79  3.93939394
#> 80  3.98989899
#> 81  4.04040404
#> 82  4.09090909
#> 83  4.14141414
#> 84  4.19191919
#> 85  4.24242424
#> 86  4.29292929
#> 87  4.34343434
#> 88  4.39393939
#> 89  4.44444444
#> 90  4.49494949
#> 91  4.54545455
#> 92  4.59595960
#> 93  4.64646465
#> 94  4.69696970
#> 95  4.74747475
#> 96  4.79797980
#> 97  4.84848485
#> 98  4.89898990
#> 99  4.94949495
#> 100 5.00000000
#> 
#> attr(,"class")
#> [1] "predictY"
# }