[R] Caret package: coeffcients for regression
mxkuhn at gmail.com
Mon May 4 15:27:05 CEST 2009
> I am using "Caret"package for SVM regression and elastic net
> regression . I can get the final fiited vs observed values. How can I get
> the coefficients? Any ideas?
You didn't say what version of caret and R you are using, what kernel
or what type of coefficients.
If you tune a model using train:
fit <- train(x, y, "enet")
then fit$finalModel contains an enet object with the final parameters.
You can use coef() or any other appropriate function on this object.
In the case of the elastic net, see ?predict.enet, specifically the
type argument to get the regression coefficients.
If you need to get to the final tuning parameters for the model, you
can access them via x$finalModel$tuneValue. There are a few exceptions
to this: models using S4 classes won't allow adding new objects.
For SVMs, you haven't said what kernel type you used. caret uses
kernel methods from kernlab (for no other reason that I like the
package). The only package that I know gives the *regression*
coefficients for linear kernels is svmpath (there could be others). If
you want the SV coefficients (typically denoted by alpha), kernlab has
a slot called coef that you can use.
You should really provide more information for your questions to be
More information about the R-help