Matthew Jackson
Matthew Jackson

Reputation: 309

R: Caret Package preProcess()

I am fairly new to data modelling and R, I wonder if anyone could give me some advice.

I am using R to replicate a model I have built in SPSS modeller with the view of then trying to improve it. Currently I am building a basic linear model using the caret package.

I have used preProcess() to scale and centre my numeric fields, including the numeric variable which the model is predicting.

preProcValues <- preProcess(Data_Numeric, method = c("center", "scale"))
Data_PreProc <- predict(preProcValues, Data_Numeric)

When I produce the model I find that this pre-processing results in a more accurate model, however, I am unsure how to take the scaled and centred result and get a 'result'. The model is used as a pricing tool so I need to unscale and centre it if that makes sense?

Upvotes: 3

Views: 4046

Answers (1)

Jaehyeon Kim
Jaehyeon Kim

Reputation: 1417

For centering, the sample mean is subtracted while the centered values are divided by the standard deviation for scaling.

It'd be easily recovered from the following relationships.

  • data
  • centered = data - mean(data)
  • scaled = centered / sd(data)

Upvotes: 5

Related Questions