Message Boards Message Boards

0
|
1624 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Standard deviation of residuals different from manual calculation

Posted 1 year ago

Please can someone explain why pmSD1 and pmSD2 are different?

p = Predict[{1.2, 2, 3.5, 4, 5.2} -> {2.3, 1.2, 5.5, 7.7, 9.9}];
pm = PredictorMeasurements[p, {1.4 -> 2.5, 4.5 -> 8.6, 5.4 -> 10.2, 3.3 -> 3}];
pmSD1 = pm["StandardDeviation"]
pmSD2 = Sqrt[Total[pm["Residuals"]^2]/2]
Information[p, "Method"]
POSTED BY: Pablo Gil
3 Replies
Posted 1 year ago

Many Thanks Jim, also can you tell how the baseline is computed?

POSTED BY: Pablo Gil
Posted 1 year ago

The documentation states

"StandardDeviationBaseline" standard deviation of test set values

And the formula used divides the sum of squares by the length of the test set values rather than the length of the test set values minus 1 (just as "StandardDeviation" does for a a PredictorMeasurementsObject).

The documentation isn't always very explicit but it is the first place to start and trying examples can sometimes help one figure out what formulas are being used.

POSTED BY: Jim Baldwin
Posted 1 year ago

pm["StandardDeviation"] uses the following formula:

Sqrt[Total[pm["Residuals"]^2]/Length[pm["Residuals"]]]

Here is a second example:

p = Predict[{1 -> 2, 3 -> 4.5, 5 -> 6, 7 -> 8.5}];
pm = PredictorMeasurements[p, {1.5 -> 2, 4 -> 5, 6 -> 5.5}];
pm["StandardDeviation"]
(* 1.12284 *)
Sqrt[Total[pm["Residuals"]^2]/Length[pm["Residuals"]]]
(* 1.12284 *)
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract