简体   繁体   中英

Extract data from Partial least square regression on R

I want to use the partial least squares regression to find the most representative variables to predict my data. Here is my code:

library(pls)
potion<-read.table("potion-insomnie.txt",header=T)

potionTrain <- potion[1:182,]
potionTest <- potion[183:192,]

potion1 <- plsr(Sommeil ~ Aubepine + Bave + Poudre + Pavot, data = potionTrain, validation = "LOO")

The summary(lm(potion1)) give me this answer:

Call:
lm(formula = potion1)

Residuals:
     Min       1Q   Median       3Q      Max 
-14.9475  -5.3961   0.0056   5.2321  20.5847 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 37.63931    1.67955  22.410  < 2e-16 ***
Aubepine    -0.28226    0.05195  -5.434 1.81e-07 ***
Bave        -1.79894    0.26849  -6.700 2.68e-10 ***
Poudre       0.35420    0.72849   0.486    0.627    
Pavot       -0.47678    0.52027  -0.916    0.361    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.845 on 177 degrees of freedom
Multiple R-squared:  0.293,     Adjusted R-squared:  0.277 
F-statistic: 18.34 on 4 and 177 DF,  p-value: 1.271e-12

I deduced that only the variables Aubepine et Bave are representative. So I redid the model just with this two variables:

potion1 <- plsr(Sommeil ~ Aubepine + Bave, data = potionTrain, validation = "LOO")

And I plot:

plot(potion1, ncomp = 2, asp = 1, line = TRUE)

Here is the plot of predicted vs measured values:

预测值与测量值的关系图

The problem is that I see the linear regression on the plot, but I can not know its equation and . Is it possible ?

Is the first part is the same as a multiple regression linear (ANOVA)?

pacman::p_load(pls)
data(mtcars)
potion <- mtcars

potionTrain <- potion[1:28,]
potionTest <- potion[29:32,]

potion1 <- plsr(mpg ~ cyl + disp + hp + drat, data = potionTrain, validation = "LOO")

coef(potion1) # coefficeints
scores(potion1) # scores

## R^2:
R2(potion1, estimate = "train")
## cross-validated R^2:
R2(potion1)
## Both:
R2(potion1, estimate = "all") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM