After running a pcr analysis using caret and train function, I obtain an object which I call model.
I need to know how to refer to number of components (Results-ncomp )so I can do a graph. I don't know how to refer to an item at second level (results followed by ncomp). I am enclosing output. Can you help?
Thanks.
List of 24
$ method : chr "pcr"
$ modelInfo :List of 12
..$ label : chr "Principal Component Analysis"
..$ library : chr "pls"
..$ type : chr "Regression"
..$ parameters:'data.frame': 1 obs. of 3 variables:
.. ..$ parameter: chr "ncomp"
.. ..$ class : chr "numeric"
.. ..$ label : chr "#Components"
..$ grid :function (x, y, len = NULL, search = "grid")
..$ loop :function (grid)
..$ fit :function (x, y, wts, param, lev, last, classProbs, ...)
..$ predict :function (modelFit, newdata, submodels = NULL)
..$ predictors:function (x, ...)
..$ tags : chr [1:2] "Linear Regression" "Feature Extraction"
..$ prob : NULL
..$ sort :function (x)
$ modelType : chr "Regression"
$ results :'data.frame': 10 obs. of 7 variables:
..$ ncomp : num [1:10] 1 2 3 4 5 6 7 8 9 10 <---------------------------------------- ??????
..$ RMSE : num [1:10] 4371 4347 4118 4118 4122 ...
..$ Rsquared : num [1:10] 0.269 0.277 0.351 0.351 0.349 ...
..$ MAE : num [1:10] 3495 3475 3263 3263 3269 ...
..$ RMSESD : num [1:10] 122 123 130 129 127 ...
..$ RsquaredSD: num [1:10] 0.0455 0.0442 0.0415 0.0417 0.0415 ...
..$ MAESD : num [1:10] 105 107 114 115 113 ...
$ pred : NULL
$ bestTune :'data.frame': 1 obs. of 1 variable:
..$ ncomp: num 10
$ call : language train.formula(form = Y ~ ., data = train, method = "pcr", scale = TRUE, trControl = trainControl("cv", number = 1| __truncated__
$ dots :List of 1
..$ scale: logi TRUE
$ metric : chr "RMSE"
$ control :List of 28
~~~