Conditional Predictions for Multivariate Linear Model Fits
cpredict.Rd
Predicted values using full conditional models derived from a multivariate
linear model (mlm
) object. The full conditionals model each response as a
linear model with all other responses used as predictors in addition to the
regressors specified in the formula of the mlm
object.
Arguments
- object
a
mlm
object, typically the result of callinglm
with a matrix response.- standardize
logical defaults to
TRUE
, standardising responses so they are comparable across responses.- ...
further arguments passed to
predict.lm
, in particular,newdata
. However, this function was not written to accept non-default values forse.fit
,interval
orterms
.
Details
Predictions using an mlm
object but based on the full conditional model,
that is, from a linear model for each response as a function of all responses
as well as predictors. This can be used in plots to diagnose the multivariate
normality assumption.
By default predictions are standardised to facilitate overlay plots of multiple
responses, as in plotenvelope
.
This function behaves much like predict.lm
, but currently, standard
errors and confidence intervals around predictions are not available.
References
Warton DI (2022) Eco-Stats - Data Analysis in Ecology, from t-tests to multivariate abundances. Springer, ISBN 978-3-030-88442-0
Examples
data(iris)
# fit a mlm:
iris.mlm=lm(cbind(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width)~Species,data=iris)
# predict each response conditionally on the values of all other responses:
cpredict(iris.mlm)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1 -1.08736105 1.11990451 -1.30535734 -1.289102302
#> 2 -1.40887637 0.90240104 -1.32330348 -1.426809568
#> 3 -1.38780021 0.73889341 -1.41361199 -1.369307187
#> 4 -1.23704333 0.52215000 -1.43809128 -1.324287689
#> 5 -1.02305799 1.01115277 -1.35051159 -1.244083452
#> 6 -0.58929269 1.64442572 -1.17328586 -1.098807930
#> 7 -1.19253101 0.75627260 -1.43461819 -1.259218023
#> 8 -1.04413414 0.95715694 -1.32983663 -1.276618123
#> 9 -1.47317943 0.35864237 -1.48704987 -1.396925289
#> 10 -1.19617643 0.66827844 -1.36812650 -1.361739254
#> 11 -0.85122496 1.39216387 -1.22158198 -1.228948557
#> 12 -0.93660417 0.68565763 -1.39947018 -1.219115095
#> 13 -1.36800947 0.61352254 -1.39260579 -1.414325713
#> 14 -1.69059938 0.23175138 -1.56668966 -1.449512396
#> 15 -0.98090568 1.98915831 -1.11332732 -1.278884948
#> 16 -0.48283732 2.07867260 -1.12052294 -1.038655157
#> 17 -1.01941257 1.86040907 -1.17328586 -1.228949205
#> 18 -1.12822795 1.30003127 -1.27087180 -1.289102302
#> 19 -0.61272885 1.79055416 -1.09298359 -1.168794489
#> 20 -0.82778879 1.24603543 -1.30188424 -1.158961998
#> 21 -0.82907420 1.28417220 -1.19056953 -1.261482905
#> 22 -0.93295875 1.42616220 -1.25706122 -1.191496993
#> 23 -1.45317787 0.79212919 -1.48977869 -1.324289309
#> 24 -1.01597796 1.49829728 -1.18122575 -1.256566335
#> 25 -0.61401426 0.52367012 -1.39947018 -1.121509138
#> 26 -1.19381642 0.90316110 -1.28848670 -1.374222785
#> 27 -1.01833797 1.26341462 -1.26086555 -1.244082804
#> 28 -0.97983108 1.17466040 -1.27054056 -1.269050838
#> 29 -1.15166411 1.22865624 -1.26020308 -1.334121152
#> 30 -1.06521030 0.57690590 -1.41361199 -1.271701230
#> 31 -1.12951336 0.68565763 -1.36845773 -1.316720080
#> 32 -1.12586794 1.75241740 -1.12159845 -1.326553543
#> 33 -0.55314581 0.99453364 -1.36705099 -1.073840868
#> 34 -0.63723961 1.55491144 -1.23845261 -1.111292756
#> 35 -1.23704333 0.84840520 -1.33364096 -1.361739254
#> 36 -1.49533018 1.11914445 -1.30916167 -1.439294070
#> 37 -1.19489102 1.60890728 -1.16609024 -1.371573040
#> 38 -0.98219109 0.72227428 -1.41981391 -1.231599597
#> 39 -1.51640634 0.41263821 -1.49738735 -1.396925613
#> 40 -1.04413414 1.06590867 -1.29501985 -1.289101978
#> 41 -1.23575792 1.24527537 -1.30568857 -1.309153766
#> 42 -2.00739467 0.70151670 -1.35572266 -1.637154433
#> 43 -1.38780021 0.41263821 -1.51806231 -1.331855623
#> 44 -1.03576870 1.62366815 -1.20223195 -1.211547809
#> 45 -0.43853581 1.21017885 -1.26739870 -1.028820722
#> 46 -1.44974326 0.97377607 -1.32363471 -1.414325713
#> 47 -0.67939192 1.01191283 -1.33636978 -1.126426679
#> 48 -1.28027024 0.57614584 -1.44842876 -1.324288013
#> 49 -0.85122496 1.28341214 -1.25639875 -1.216464703
#> 50 -1.21596718 1.01115277 -1.31949915 -1.341688437
#> 51 0.83955654 0.22566811 0.63898330 0.320380078
#> 52 0.58362970 -0.13872386 0.46456820 0.330212569
#> 53 0.94944652 0.18905146 0.64898955 0.365399575
#> 54 -0.45101392 -1.20776380 0.17528348 -0.012924288
#> 55 0.43394742 -0.08396796 0.54073490 0.220124053
#> 56 0.40815125 -1.26023952 0.19322962 0.287459572
#> 57 0.82212581 -0.17534050 0.45389948 0.440302056
#> 58 -1.01681996 -2.02268364 -0.14741127 -0.133233397
#> 59 0.57998428 -0.33546976 0.49624311 0.240175193
#> 60 -0.34219854 -1.29989640 0.06396877 0.122131938
#> 61 -1.05897227 -2.02192358 -0.07124457 -0.210786594
#> 62 0.13243366 -0.52049502 0.31115929 0.229955896
#> 63 -0.39271629 -1.20438543 0.25624821 -0.107878557
#> 64 0.64664735 -0.75309750 0.35664478 0.335129786
#> 65 -0.49531543 -0.88302872 0.14807537 0.039660552
#> 66 0.45266357 0.06140042 0.54487046 0.227690690
#> 67 0.45502358 -1.00873773 0.20670897 0.365013417
#> 68 0.03632900 -1.47588473 0.13492726 0.112299447
#> 69 -0.05940092 -0.35622733 0.49830947 0.029830328
#> 70 -0.34820397 -1.40526976 0.12045421 0.007126528
#> 71 0.78361892 -0.30408975 0.39394095 0.490237799
#> 72 -0.12949861 -0.55525340 0.33249672 0.074847558
#> 73 0.56362815 -0.46345894 0.50211380 0.245092734
#> 74 0.66407809 -1.11335102 0.29801118 0.302594791
#> 75 0.25739437 -0.39098571 0.42660956 0.167536946
#> 76 0.38836050 -0.04735132 0.52039117 0.207639550
#> 77 0.68987426 -0.04583120 0.61069968 0.247743126
#> 78 0.91093963 0.27780568 0.65866457 0.390367609
#> 79 0.39072051 -0.57373079 0.35631355 0.282543003
#> 80 -0.67315389 -1.26066144 0.11044796 -0.102963607
#> 81 -0.52003700 -1.46002566 0.09597492 -0.045459931
#> 82 -0.58670008 -1.58615658 0.06148938 -0.077995250
#> 83 -0.26046474 -1.00763953 0.20389834 0.047228809
#> 84 0.86642732 -0.71757905 0.41147405 0.412684926
#> 85 0.45502358 -1.22624120 0.13707542 0.389981127
#> 86 0.67136893 -0.39360403 0.33911168 0.445217978
#> 87 0.73438658 0.07953967 0.57935600 0.325296647
#> 88 -0.02089404 -0.55373328 0.45381768 0.017346149
#> 89 0.10663749 -1.15300791 0.13773789 0.234872141
#> 90 -0.32240780 -1.20776380 0.15460852 0.052145702
#> 91 0.21288205 -1.60387391 0.10978550 0.214821973
#> 92 0.60342044 -0.69910166 0.34630730 0.335129462
#> 93 -0.21723783 -1.06163537 0.21423582 0.047229133
#> 94 -1.08112302 -1.91393190 -0.10225701 -0.178252246
#> 95 0.02125827 -1.20700374 0.16875033 0.169802475
#> 96 0.25503436 -1.27837877 0.13806912 0.254923605
#> 97 0.14986440 -1.09825201 0.18289214 0.222388610
#> 98 0.25739437 -0.60848918 0.35697601 0.192504655
#> 99 -1.31597371 -1.46306590 -0.05362966 -0.223272068
#> 100 -0.02196864 -1.04425617 0.19322962 0.157318297
#> 101 1.46327960 0.05879821 1.05680304 1.398244181
#> 102 0.35489288 -1.07975851 0.73783081 0.972635614
#> 103 1.32630803 0.26230086 1.22840751 1.168233038
#> 104 1.06201575 -0.98610578 0.85675418 1.137962925
#> 105 1.17791117 -0.15608694 1.05399241 1.210600848
#> 106 2.07901783 0.42808867 1.40249138 1.333560997
#> 107 -0.33715928 -2.09480261 0.37618372 0.824708404
#> 108 1.81472555 -0.27655931 1.20492192 1.240871609
#> 109 1.01986345 -0.65909052 1.03737120 1.022958163
#> 110 1.76371876 0.98356798 1.33914156 1.416029792
#> 111 0.63554129 -0.13836961 0.96434636 1.047923606
#> 112 0.56995282 -0.53523978 0.94673145 0.962803123
#> 113 0.89618815 0.15202901 1.12395719 1.075543327
#> 114 0.07788988 -0.95438764 0.75817454 0.887514160
#> 115 0.21486145 -0.17912469 0.89992103 1.005170609
#> 116 0.72800054 0.18526727 1.03298621 1.125478098
#> 117 1.01878885 -0.71460648 0.91605024 1.112994891
#> 118 2.66010540 0.66297133 1.38909385 1.613892421
#> 119 2.06266170 0.73510642 1.54762917 1.288543119
#> 120 0.08931519 -1.52876625 0.72120960 0.752457610
#> 121 1.15812042 0.51304260 1.20707008 1.193200100
#> 122 0.16326910 -1.00914354 0.69234532 0.965067681
#> 123 2.09880858 0.30271781 1.42349758 1.288542471
#> 124 0.18069983 -0.60813493 0.87742914 0.845145702
#> 125 1.30415728 -0.06471440 1.05812797 1.250702805
#> 126 1.68504483 -0.22332353 1.13909270 1.253354493
#> 127 0.13747292 -0.66289082 0.83227488 0.857629233
#> 128 0.37360902 -0.82563839 0.77678315 0.967718397
#> 129 0.87511200 -0.33697376 1.00536505 1.092944075
#> 130 1.42311256 -0.47558538 1.09079658 1.123213865
#> 131 1.49449565 0.12031086 1.28456172 1.130782122
#> 132 2.41924929 0.68220878 1.38975631 1.491318755
#> 133 0.83424510 -0.15684700 1.03985060 1.092944075
#> 134 0.58266353 -1.25650689 0.76363504 0.942751335
#> 135 1.03257416 -1.92411630 0.68019091 1.065325649
#> 136 1.45963418 1.16707312 1.50627924 1.158400547
#> 137 1.13832968 0.09465479 1.01198001 1.300637900
#> 138 1.08309191 -0.82335821 0.87089599 1.158013741
#> 139 0.26607905 -0.88039429 0.74196637 0.947666933
#> 140 0.85296124 0.31477658 1.14843648 1.063059148
#> 141 0.94542049 0.52966173 1.18225956 1.153097496
#> 142 0.44863753 0.83701762 1.21740756 0.965453192
#> 143 0.35489288 -1.07975851 0.73783081 0.972635614
#> 144 1.37318036 0.29629919 1.17225331 1.270754593
#> 145 1.14068969 0.65579265 1.19607013 1.250702805
#> 146 0.49186444 0.56551831 1.15811150 0.990421225
#> 147 0.11875678 -0.48200400 0.93258964 0.812611031
#> 148 0.61446514 -0.19236544 0.98502133 1.015388935
#> 149 0.96413663 -0.08623203 0.94267770 1.248051117
#> 150 0.58866896 -1.15113354 0.70714960 1.057756744
#> attr(,"scaled:center")
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 5.843333 3.057333 3.758000 1.199333
#> attr(,"scaled:scale")
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 0.7711747 0.3473723 1.7463014 0.7444306