custom.css

Skip to contents

Formats and displays Partial Least Squares (PLS) model output from pls.regression() as either LaTeX tables (for PDF rendering) or console-friendly output.

Usage

pls.summary(x, ..., include.scores = TRUE, latex = TRUE)

Arguments

x

A list returned by pls.regression() (class "pls") containing PLS model components.

...

Further arguments passed to or from methods (unused).

include.scores

Logical. Whether to include score matrices (T and U). Default is TRUE.

latex

Logical. If TRUE, produces LaTeX output (for PDF rendering). If FALSE, prints to console. Default is FALSE.

Value

When latex = TRUE, returns a knitr::asis_output object (LaTeX code). When latex = FALSE, prints formatted tables to the console and returns NULL.

Examples

# Load example data
data(mtcars)

# Prepare data for PLS regression
X <- mtcars[, c("wt", "hp", "disp")]
Y <- mtcars[, "mpg", drop = FALSE]

# Fit PLS model with 2 components
pls.fit <- pls.regression(X, Y, n.components = 2)

# Print a console-formatted summary
pls.summary(pls.fit, latex = FALSE)
#> 
#> 
#> Table: X Weights (W)
#> 
#> --------  --------
#>  -0.6025   -0.7868
#>  -0.5390    0.2773
#>  -0.5886    0.5515
#> --------  --------
#> 
#> 
#> Table: X Loadings (P)
#> 
#> --------  --------
#>  -5.1515   -2.0903
#>  -4.8773    1.9874
#>  -5.3940    0.3199
#> --------  --------
#> 
#> 
#> Table: Y Weights (C)
#> 
#>    x
#>  ---
#>    1
#>    1
#> 
#> 
#> Table: Y Loadings (Q)
#> 
#> ---  ---
#>   1    1
#> ---  ---
#> 
#> 
#> Table: Regression Scalars (b)
#> 
#>  Component   Estimate
#> ----------  ---------
#>          1     5.0114
#>          2     0.5793
#> 
#> 
#> Table: Regression Coefficients (Original Scale)
#> 
#>         Estimate
#> -----  ---------
#> wt       -2.9704
#> hp       -0.0144
#> disp     -0.0156
#> 
#> 
#> Table: X Scores (T)
#> 
#> --------  --------
#>   0.1114    0.0201
#>   0.0937   -0.0684
#>   0.1748    0.0026
#>   0.0180   -0.0085
#>  -0.1093    0.2026
#>   0.0231   -0.1614
#>  -0.1801    0.2697
#>   0.1214   -0.2787
#>   0.0982   -0.2227
#>   0.0392   -0.2298
#>   0.0392   -0.2298
#>  -0.1124   -0.1607
#>  -0.0889   -0.0427
#>  -0.0923   -0.0601
#>  -0.3206   -0.1741
#>  -0.3351   -0.2402
#>  -0.3322   -0.2250
#>   0.2226   -0.0522
#>   0.2770    0.1229
#>   0.2528    0.0591
#>   0.1548   -0.0193
#>  -0.0704    0.0586
#>  -0.0570    0.0627
#>  -0.1934    0.1579
#>  -0.1586    0.1347
#>   0.2407    0.0403
#>   0.1825    0.0842
#>   0.2199    0.2913
#>  -0.1644    0.4227
#>   0.0516    0.0450
#>  -0.2280    0.3070
#>   0.1220   -0.1078
#> --------  --------
#> 
#> 
#> Table: Y Scores (U)
#> 
#> --------  --------
#>   0.1509   -0.4072
#>   0.1509   -0.3189
#>   0.4495   -0.4266
#>   0.2173    0.1271
#>  -0.2307    0.3171
#>  -0.3303   -0.4459
#>  -0.9608   -0.0584
#>   0.7150    0.1065
#>   0.4495   -0.0426
#>  -0.1478   -0.3440
#>  -0.3801   -0.5763
#>  -0.6124   -0.0491
#>  -0.4630   -0.0176
#>  -0.8115   -0.3487
#>  -1.6079   -0.0011
#>  -1.6079    0.0714
#>  -0.8944    0.7704
#>   2.0424    0.9269
#>   1.7105    0.3225
#>   2.2913    1.0246
#>   0.2338   -0.5421
#>  -0.7617   -0.4090
#>  -0.8115   -0.5256
#>  -1.1267   -0.1575
#>  -0.1478    0.6472
#>   1.1962   -0.0103
#>   0.9805    0.0660
#>   1.7105    0.6088
#>  -0.7119    0.1119
#>  -0.0648   -0.3236
#>  -0.8446    0.2982
#>   0.2173   -0.3941
#> --------  --------
#> 
#> 
#> Table: Variance Explained by Components (X)
#> 
#>  Latent.Vector  Explained.Variance   Cumulative 
#> --------------  -------------------  -----------
#>              1  85.3995%             85.3995%   
#>              2  9.0554%              94.4549%   
#> 
#> 
#> Table: Variance Explained by Components (Y)
#> 
#>  Latent.Vector  Explained.Variance   Cumulative 
#> --------------  -------------------  -----------
#>              1  81.0145%             81.0145%   
#>              2  1.0825%              82.0969%