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.
# S3 method for path_coeff print(x, export = FALSE, file.name = NULL, digits = 4, ...)
x | An object of class |
---|---|
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See
|
Tiago Olivoto tiagoolivoto@gmail.com
# \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 #> Please, consider using a correction factor, or use 'brutstep = TRUE'.print(pcoeff)#> ---------------------------------------------------------------------------------------------- #> Correlation matrix between the predictor traits #> ---------------------------------------------------------------------------------------------- #> # A tibble: 14 x 14 #> PH EH EP EL ED CL CD CW #> * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 0.9318 0.6384 0.3802 0.6613 0.3252 0.3154 0.5047 #> 2 0.9318 1 0.8695 0.3627 0.6303 0.3972 0.2805 0.5193 #> 3 0.6384 0.8695 1 0.2634 0.4580 0.3908 0.1750 0.4248 #> 4 0.3802 0.3627 0.2634 1 0.3851 0.2554 0.9119 0.4582 #> 5 0.6613 0.6303 0.4580 0.3851 1 0.6975 0.3897 0.7371 #> 6 0.3252 0.3972 0.3908 0.2554 0.6975 1 0.3004 0.7383 #> 7 0.3154 0.2805 0.1750 0.9119 0.3897 0.3004 1 0.4840 #> 8 0.5047 0.5193 0.4248 0.4582 0.7371 0.7383 0.4840 1 #> 9 0.3286 0.2648 0.1404 -0.01387 0.5525 0.2619 -0.03585 0.1657 #> 10 0.3530 0.3311 0.2588 0.6172 0.2221 -0.1149 0.5933 0.3403 #> 11 -0.1920 -0.06591 0.08966 -0.01258 -0.01004 0.7080 0.04531 0.2999 #> 12 0.04081 -0.02135 -0.08709 0.03526 -0.2244 -0.5731 -0.04820 -0.6811 #> 13 0.5685 0.5624 0.4263 0.4421 0.6420 0.6187 0.4433 0.6735 #> 14 0.4584 0.3881 0.2331 0.4657 0.5051 0.04894 0.4156 0.3463 #> # ... with 6 more variables: NR <dbl>, NKR <dbl>, CDED <dbl>, PERK <dbl>, #> # TKW <dbl>, NKE <dbl> #> ---------------------------------------------------------------------------------------------- #> 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.0111 #> Response: KW #> Predictors: PH EH EP EL ED CL CD CW NR NKR CDED PERK TKW NKE #> ---------------------------------------------------------------------------------------------- #> Variance inflation factors #> ---------------------------------------------------------------------------------------------- #> # A tibble: 14 x 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 x 15 #> Eigenvalues PH EH EP EL ED CL #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 5.702 -0.3344 -3.424e-1 -0.2805 -0.2756 -0.3578 -0.2791 #> 2 2.960 0.1284 6.995e-2 -0.007025 0.1463 -0.02762 -0.3756 #> 3 1.819 -0.2329 -2.507e-1 -0.2220 0.4533 -0.1981 -0.06882 #> 4 1.364 0.2629 3.518e-1 0.3861 -0.006280 -0.2013 -0.2008 #> 5 0.7747 -0.03192 1.044e-1 0.2783 -0.2332 -0.2196 -0.1746 #> 6 0.6654 -0.1246 1.278e-1 0.4317 0.1863 -0.2731 0.1965 #> 7 0.2473 0.5967 2.245e-1 -0.3831 0.1622 -0.3374 -0.1759 #> 8 0.2214 -0.2918 4.341e-4 0.4050 0.2985 0.1087 -0.1990 #> 9 0.09185 0.1205 7.788e-2 -0.05355 -0.4210 0.4094 0.2413 #> 10 0.08453 0.01898 2.316e-2 -0.07535 0.4072 0.2085 0.1458 #> 11 0.05241 0.1106 2.531e-3 -0.1027 0.3856 0.2729 0.1481 #> 12 0.01359 -0.01388 -3.245e-2 0.04255 -0.02922 0.03773 -0.08825 #> 13 0.002298 0.5063 -7.688e-1 0.3532 0.004010 0.08191 -0.09833 #> 14 0.0007249 -0.08362 1.219e-1 -0.05200 -0.002194 0.4992 -0.6910 #> # ... with 8 more variables: CD <dbl>, CW <dbl>, NR <dbl>, NKR <dbl>, #> # CDED <dbl>, PERK <dbl>, TKW <dbl>, NKE <dbl> #> ---------------------------------------------------------------------------------------------- #> 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.125229130 0.085796739 0.0510948430 0.088874623 #> EH -0.171222875 -0.183749400 -0.159778550 -0.0666374058 -0.115809172 #> EP 0.061877581 0.084280015 0.096924162 0.0255321252 0.044393164 #> EL 0.010883761 0.010381584 0.007540955 0.0286267110 0.011025438 #> ED 0.446623699 0.425647933 0.309326800 0.2601105126 0.675357150 #> CL -0.293364515 -0.358348997 -0.352602326 -0.2304286208 -0.629252785 #> CD -0.005266683 -0.004684240 -0.002923057 -0.0152271506 -0.006507777 #> CW 0.265532835 0.273200333 0.223483792 0.2410353994 0.387789404 #> NR -0.005372332 -0.004329254 -0.002295891 0.0002268202 -0.009033294 #> NKR 0.003360398 0.003151029 0.002463615 0.0058742020 0.002113734 #> CDED -0.119615809 -0.041057967 0.055855319 -0.0078364489 -0.006251439 #> PERK 0.014201880 -0.007428705 -0.030303950 0.0122697061 -0.078081119 #> TKW 0.226823259 0.224357019 0.170080347 0.1763799916 0.256126166 #> NKE 0.184591912 0.156298420 0.093851313 0.1875394321 0.203398550 #> CL CD CW NR NKR #> PH 0.043699156 0.0423856396 0.067832246 0.0441616824 0.0474466036 #> EH -0.072984071 -0.0515438766 -0.095423559 -0.0486577768 -0.0608307635 #> EP 0.037880281 0.0169660753 0.041174330 0.0136112025 0.0250870598 #> EL 0.007311455 0.0261037034 0.013115980 -0.0003971608 0.0176670988 #> ED 0.471036554 0.2631953404 0.497826367 0.3731581095 0.1499784146 #> CL -0.902202524 -0.2709888299 -0.666130343 -0.2363192487 0.1036996491 #> CD -0.005015744 -0.0166989041 -0.008082769 0.0005986531 -0.0099078040 #> CW 0.388424598 0.2546383002 0.526079702 0.0871490589 0.1790330662 #> NR -0.004282347 0.0005861031 -0.002708307 -0.0163488330 -0.0003359844 #> NKR -0.001094028 0.0056473477 0.003239193 0.0001956084 0.0095182058 #> CDED 0.441041603 0.0282236446 0.186795501 -0.1056862609 -0.2332443226 #> PERK -0.199428897 -0.0167731280 -0.236985793 0.0419437607 0.0471631422 #> TKW 0.246835686 0.1768682462 0.268682016 -0.0433917929 0.0370478405 #> NKE 0.019709283 0.1673709558 0.139447634 0.2521277006 0.2850479201 #> CDED PERK TKW NKE linear #> PH -0.0258054437 0.0054850819 0.0764063326 0.061602057 0.75344390 #> EH 0.0121109054 0.0039228962 -0.1033327171 -0.071317081 0.70294690 #> EP 0.0086906014 -0.0084411002 0.0413198226 0.022588399 0.49741927 #> EL -0.0003601173 0.0010094234 0.0126558999 0.013331441 0.66856012 #> ED -0.0067774568 -0.1515469801 0.4335704834 0.341109955 0.82414264 #> CL -0.6387587121 0.5170825461 -0.5581928171 -0.044155815 0.47093101 #> CD -0.0007565790 0.0008049516 -0.0074030400 -0.006940346 0.62598062 #> CW 0.1577506652 -0.3582957129 0.3542928614 0.182169528 0.73486220 #> NR 0.0027736939 -0.0019707062 0.0017781427 -0.010235766 0.36214470 #> NKR -0.0035638500 0.0012901065 0.0008838738 0.006737302 0.59737013 #> CDED 0.6229407750 -0.3559362597 0.1450367294 -0.261954336 -0.14702901 #> PERK -0.1988189241 0.3479623423 -0.0966967421 0.071431363 -0.02683251 #> TKW 0.0928878649 -0.1108682872 0.3989585175 -0.025996082 0.67303715 #> NKE -0.1693424322 0.0826691839 -0.0262401985 0.402704943 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.0669 2.59 #> MODEL_2 1125 6 12.26 0.1383 0.933 0.0670 2.46 #> MODEL_3 1126 5 12.05 0.1989 0.932 0.0683 2.31 #> MODEL_4 1138 4 6.40 0.4595 0.925 0.0747 2.13 #> MODEL_5 1148 3 1.34 0.9787 0.919 0.0808 1.02 #> MODEL_6 1329 2 2.23 0.8555 0.738 0.2616 1.17 #> -------------------------------------------------------------------------- #>print(pcoeff2)#> # A tibble: 6 x 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.06694 2.592 #> 2 MODEL_2 1125. 6 12.26 0.1383 0.9330 0.06695 2.461 #> 3 MODEL_3 1126. 5 12.05 0.1989 0.9317 0.06825 2.310 #> 4 MODEL_4 1138. 4 6.402 0.4595 0.9253 0.07474 2.130 #> 5 MODEL_5 1148. 3 1.339 0.9787 0.9192 0.08077 1.021 #> 6 MODEL_6 1329. 2 2.227 0.8555 0.7384 0.2616 1.169#># }