Print an object generated by the function 'path_coeff()'. By default, the results are shown in the R console. The results can also be exported to the directory.
Usage
# S3 method for path_coeff
print(x, export = FALSE, file.name = NULL, digits = 4, ...)
Arguments
- x
An object of class
path_coeff
orgroup_path
.- export
A logical argument. If
TRUE
, a *.txt file is exported to the working directory- file.name
The name of the file if
export = TRUE
- digits
The significant digits to be shown.
- ...
Options used by the tibble package to format the output. See
tibble::print()
for more details.
Author
Tiago Olivoto tiagoolivoto@gmail.com
Examples
# \donttest{
library(metan)
# KW as dependent trait and all others as predictors
pcoeff <- path_coeff(data_ge2, resp = KW)
#> Severe multicollinearity.
#> Condition Number: 7865.84
#> Consider using a correction factor with 'correction' argument.
#> Consider identifying collinear traits with `non_collinear_vars()`
print(pcoeff)
#> ----------------------------------------------------------------------------------------------
#> Correlation matrix between the predictor traits
#> ----------------------------------------------------------------------------------------------
#> PH EH EP EL ED CL CD CW
#> PH 1.00000 0.93183 0.63841 0.38020 0.66131 0.32516 0.31539 0.5047
#> EH 0.93183 1.00000 0.86955 0.36265 0.63026 0.39719 0.28051 0.5193
#> EP 0.63841 0.86955 1.00000 0.26342 0.45802 0.39082 0.17504 0.4248
#> EL 0.38020 0.36265 0.26342 1.00000 0.38515 0.25541 0.91187 0.4582
#> ED 0.66131 0.63026 0.45802 0.38515 1.00000 0.69746 0.38971 0.7371
#> CL 0.32516 0.39719 0.39082 0.25541 0.69746 1.00000 0.30036 0.7383
#> CD 0.31539 0.28051 0.17504 0.91187 0.38971 0.30036 1.00000 0.4840
#> CW 0.50474 0.51931 0.42481 0.45817 0.73713 0.73834 0.48403 1.0000
#> NR 0.32861 0.26481 0.14043 -0.01387 0.55253 0.26194 -0.03585 0.1657
#> NKR 0.35305 0.33105 0.25883 0.61715 0.22207 -0.11494 0.59332 0.3403
#> CDED -0.19202 -0.06591 0.08966 -0.01258 -0.01004 0.70800 0.04531 0.2999
#> PERK 0.04081 -0.02135 -0.08709 0.03526 -0.22440 -0.57313 -0.04820 -0.6811
#> TKW 0.56854 0.56236 0.42631 0.44210 0.64199 0.61870 0.44332 0.6735
#> NKE 0.45838 0.38812 0.23305 0.46570 0.50508 0.04894 0.41562 0.3463
#> NR NKR CDED PERK TKW NKE
#> PH 0.32861 0.35305 -0.19202 0.04081 0.56854 0.45838
#> EH 0.26481 0.33105 -0.06591 -0.02135 0.56236 0.38812
#> EP 0.14043 0.25883 0.08966 -0.08709 0.42631 0.23305
#> EL -0.01387 0.61715 -0.01258 0.03526 0.44210 0.46570
#> ED 0.55253 0.22207 -0.01004 -0.22440 0.64199 0.50508
#> CL 0.26194 -0.11494 0.70800 -0.57313 0.61870 0.04894
#> CD -0.03585 0.59332 0.04531 -0.04820 0.44332 0.41562
#> CW 0.16566 0.34032 0.29986 -0.68107 0.67346 0.34628
#> NR 1.00000 0.02055 -0.16966 0.12054 -0.10876 0.62609
#> NKR 0.02055 1.00000 -0.37442 0.13554 0.09286 0.70783
#> CDED -0.16966 -0.37442 1.00000 -0.57138 0.23283 -0.42051
#> PERK 0.12054 0.13554 -0.57138 1.00000 -0.27789 0.20528
#> TKW -0.10876 0.09286 0.23283 -0.27789 1.00000 -0.06516
#> NKE 0.62609 0.70783 -0.42051 0.20528 -0.06516 1.00000
#> ----------------------------------------------------------------------------------------------
#> Vector of correlations between dependent and each predictor
#> ----------------------------------------------------------------------------------------------
#> PH EH EP EL ED CL CD
#> KW 0.7534439 0.7029469 0.4974193 0.6685601 0.8241426 0.470931 0.6259806
#> CW NR NKR CDED PERK TKW NKE
#> KW 0.7348622 0.3621447 0.5973701 -0.147029 -0.02683251 0.6730371 0.6810756
#> ----------------------------------------------------------------------------------------------
#> Multicollinearity diagnosis and goodness-of-fit
#> ----------------------------------------------------------------------------------------------
#> Condition number: 7865.84
#> Determinant: 0
#> R-square: 0.9889
#> Residual: 0.1052
#> Response: KW
#> Predictors: PH EH EP EL ED CL CD CW NR NKR CDED PERK TKW NKE
#> ----------------------------------------------------------------------------------------------
#> Variance inflation factors
#> ----------------------------------------------------------------------------------------------
#> # A tibble: 14 × 2
#> VAR VIF
#> <chr> <dbl>
#> 1 PH 123.6
#> 2 EH 278.3
#> 3 EP 60.31
#> 4 EL 7.569
#> 5 ED 351.3
#> 6 CL 665.1
#> 7 CD 7.219
#> 8 CW 46.46
#> 9 NR 5.768
#> 10 NKR 6.451
#> 11 CDED 327.1
#> 12 PERK 18.24
#> 13 TKW 19.69
#> 14 NKE 26.07
#> ----------------------------------------------------------------------------------------------
#> Eigenvalues and eigenvectors
#> ----------------------------------------------------------------------------------------------
#> # A tibble: 14 × 15
#> Eigenval…¹ PH EH EP EL ED CL CD
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 5.702 -0.3344 -3.424e-1 -0.2805 -0.2756 -0.3578 -0.2791 -0.2651
#> 2 2.960 0.1284 6.995e-2 -0.007025 0.1463 -0.02762 -0.3756 0.1006
#> 3 1.819 -0.2329 -2.507e-1 -0.2220 0.4533 -0.1981 -0.06882 0.4945
#> 4 1.364 0.2629 3.518e-1 0.3861 -0.006280 -0.2013 -0.2008 -0.07363
#> 5 0.7747 -0.03192 1.044e-1 0.2783 -0.2332 -0.2196 -0.1746 -0.2410
#> 6 0.6654 -0.1246 1.278e-1 0.4317 0.1863 -0.2731 0.1965 0.1220
#> 7 0.2473 0.5967 2.245e-1 -0.3831 0.1622 -0.3374 -0.1759 0.1732
#> 8 0.2214 -0.2918 4.341e-4 0.4050 0.2985 0.1087 -0.1990 0.2522
#> 9 0.09185 0.1205 7.788e-2 -0.05355 -0.4210 0.4094 0.2413 0.4507
#> 10 0.08453 0.01898 2.316e-2 -0.07535 0.4072 0.2085 0.1458 -0.4365
#> 11 0.05241 0.1106 2.531e-3 -0.1027 0.3856 0.2729 0.1481 -0.3305
#> 12 0.01359 -0.01388 -3.245e-2 0.04255 -0.02922 0.03773 -0.08825 -0.006893
#> 13 0.002298 0.5063 -7.688e-1 0.3532 0.004010 0.08191 -0.09833 0.002041
#> 14 0.0007249 -0.08362 1.219e-1 -0.05200 -0.002194 0.4992 -0.6910 -0.001490
#> # … with 7 more variables: CW <dbl>, NR <dbl>, NKR <dbl>, CDED <dbl>,
#> # PERK <dbl>, TKW <dbl>, NKE <dbl>, and abbreviated variable name
#> # ¹Eigenvalues
#> ----------------------------------------------------------------------------------------------
#> Variables with the largest weight in the eigenvalue of smallest magnitude
#> ----------------------------------------------------------------------------------------------
#> CL > ED > CDED > EH > CW > PH > NKE > EP > TKW > PERK > NR > EL > NKR > CD
#> ----------------------------------------------------------------------------------------------
#> Direct (diagonal) and indirect (off-diagonal) effects
#> ----------------------------------------------------------------------------------------------
#> PH EH EP EL ED
#> PH 0.134390791 -0.171222875 0.061877581 0.0108837614 0.446623699
#> EH 0.125229130 -0.183749400 0.084280015 0.0103815836 0.425647933
#> EP 0.085796739 -0.159778550 0.096924162 0.0075409552 0.309326800
#> EL 0.051094843 -0.066637406 0.025532125 0.0286267110 0.260110513
#> ED 0.088874623 -0.115809172 0.044393164 0.0110254381 0.675357151
#> CL 0.043699157 -0.072984071 0.037880281 0.0073114554 0.471036554
#> CD 0.042385640 -0.051543877 0.016966075 0.0261037034 0.263195341
#> CW 0.067832246 -0.095423559 0.041174330 0.0131159798 0.497826367
#> NR 0.044161682 -0.048657777 0.013611203 -0.0003971608 0.373158110
#> NKR 0.047446604 -0.060830763 0.025087060 0.0176670988 0.149978415
#> CDED -0.025805444 0.012110905 0.008690601 -0.0003601173 -0.006777457
#> PERK 0.005485082 0.003922896 -0.008441100 0.0010094234 -0.151546980
#> TKW 0.076406333 -0.103332717 0.041319823 0.0126558999 0.433570484
#> NKE 0.061602057 -0.071317081 0.022588399 0.0133314408 0.341109956
#> CL CD CW NR NKR
#> PH -0.29336452 -0.0052666833 0.26553284 -0.0053723322 0.0033603980
#> EH -0.35834900 -0.0046842398 0.27320033 -0.0043292542 0.0031510292
#> EP -0.35260233 -0.0029230571 0.22348379 -0.0022958906 0.0024636148
#> EL -0.23042862 -0.0152271506 0.24103540 0.0002268202 0.0058742020
#> ED -0.62925279 -0.0065077770 0.38778940 -0.0090332939 0.0021137341
#> CL -0.90220252 -0.0050157435 0.38842460 -0.0042823466 -0.0010940278
#> CD -0.27098883 -0.0166989041 0.25463830 0.0005861031 0.0056473477
#> CW -0.66613034 -0.0080827687 0.52607970 -0.0027083071 0.0032391928
#> NR -0.23631925 0.0005986531 0.08714906 -0.0163488330 0.0001956084
#> NKR 0.10369965 -0.0099078040 0.17903307 -0.0003359844 0.0095182058
#> CDED -0.63875871 -0.0007565790 0.15775067 0.0027736939 -0.0035638500
#> PERK 0.51708255 0.0008049516 -0.35829571 -0.0019707062 0.0012901065
#> TKW -0.55819282 -0.0074030400 0.35429286 0.0017781427 0.0008838738
#> NKE -0.04415581 -0.0069403457 0.18216953 -0.0102357663 0.0067373019
#> CDED PERK TKW NKE linear
#> PH -0.119615809 0.014201880 0.22682326 0.18459191 0.75344390
#> EH -0.041057967 -0.007428705 0.22435702 0.15629842 0.70294690
#> EP 0.055855319 -0.030303950 0.17008035 0.09385131 0.49741927
#> EL -0.007836449 0.012269706 0.17637999 0.18753943 0.66856012
#> ED -0.006251439 -0.078081119 0.25612617 0.20339855 0.82414264
#> CL 0.441041603 -0.199428897 0.24683569 0.01970928 0.47093101
#> CD 0.028223645 -0.016773128 0.17686825 0.16737096 0.62598062
#> CW 0.186795502 -0.236985794 0.26868202 0.13944763 0.73486220
#> NR -0.105686261 0.041943761 -0.04339179 0.25212770 0.36214470
#> NKR -0.233244323 0.047163142 0.03704784 0.28504792 0.59737013
#> CDED 0.622940776 -0.198818924 0.09288786 -0.16934243 -0.14702901
#> PERK -0.355936260 0.347962342 -0.11086829 0.08266918 -0.02683251
#> TKW 0.145036730 -0.096696742 0.39895852 -0.02624020 0.67303715
#> NKE -0.261954336 0.071431363 -0.02599608 0.40270494 0.68107556
#> ----------------------------------------------------------------------------------------------
# Call the algorithm for selecting a set of predictors
# With minimal multicollinearity (no VIF larger than 5)
pcoeff2 <- path_coeff(data_ge2,
resp = KW,
brutstep = TRUE,
maxvif = 5)
#> --------------------------------------------------------------------------
#> The algorithm has selected a set of 8 predictors with largest VIF = 3.346.
#> Selected predictors: NR PERK EP CDED EL NKR TKW PH
#> A forward stepwise-based selection procedure will fit 6 models.
#> --------------------------------------------------------------------------
#> Adjusting the model 1 with 7 predictors (16.67% concluded)
#> Adjusting the model 2 with 6 predictors (33.33% concluded)
#> Adjusting the model 3 with 5 predictors (50% concluded)
#> Adjusting the model 4 with 4 predictors (66.67% concluded)
#> Adjusting the model 5 with 3 predictors (83.33% concluded)
#> Adjusting the model 6 with 2 predictors (100% concluded)
#> Done!
#> --------------------------------------------------------------------------
#> Summary of the adjusted models
#> --------------------------------------------------------------------------
#> Model AIC Numpred CN Determinant R2 Residual maxVIF
#> MODEL_1 1127 7 13.67 0.0841 0.933 0.259 2.59
#> MODEL_2 1125 6 12.26 0.1383 0.933 0.259 2.46
#> MODEL_3 1126 5 12.05 0.1989 0.932 0.261 2.31
#> MODEL_4 1251 4 6.66 0.4016 0.846 0.393 1.98
#> MODEL_5 1308 3 3.05 0.7438 0.774 0.475 1.34
#> MODEL_6 1329 2 2.23 0.8555 0.738 0.512 1.17
#> --------------------------------------------------------------------------
#>
print(pcoeff2)
#> # A tibble: 6 × 8
#> Model AIC Numpred CN Determinant R2 Residual maxVIF
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 MODEL_1 1127. 7 13.67 0.08406 0.9331 0.2587 2.592
#> 2 MODEL_2 1125. 6 12.26 0.1383 0.9330 0.2587 2.461
#> 3 MODEL_3 1126. 5 12.05 0.1989 0.9317 0.2612 2.310
#> 4 MODEL_4 1251. 4 6.661 0.4016 0.8456 0.3930 1.977
#> 5 MODEL_5 1308. 3 3.049 0.7438 0.7742 0.4752 1.344
#> 6 MODEL_6 1329. 2 2.227 0.8555 0.7384 0.5115 1.169
#> Go to 'pcoeff2 > s' to select a specific model
# }