Message Boards Message Boards

SinglePredictionErrors vs. SinglePredictionBands/2

Hi, all!

I cannot understand meanings of some LinearModelFit outputs.

POSTED BY: Vladimir Ivanov
6 Replies

OK. Not perfectly clear, but I've collected some material to think about. Thank you.

POSTED BY: Vladimir Ivanov
Posted 2 years ago

Sorry, not true. What I was showing was that you could get the standard error for any value of x using fit["SinglePredictionBands"]. (You take the difference in the upper and lower values and divide by twice the t cut-off value.)

fit["SinglePredictionErrors"] only gets you the standard errors associated with the x values in your data. In other words, fit["SinglePredictionErrors"][[3]] gets you the standard error associated with the third element in your data. That just also happens to be x=3 for your data. But in general that certainly won't be the case.

POSTED BY: Jim Baldwin

It seems that you've made a misprint. In your example

fit["SinglePredictionErrors"][[3]]
(* 0.596900473 *)

and

Differences[fit["SinglePredictionBands"] /. x -> x0][[1]]/(2 t)
(* 0.596900473 *)

provide the same value. I guess in the last line must be

Differences[fit["SinglePredictionBands"] /. x -> x0][[1]]/2
(* 0.636611319 *)

If that is true, then I get the idea.

POSTED BY: Vladimir Ivanov

Thank you for your answer, Jim.

But, frankly, I'm not a guru in statistic. I want to understand a simple thing: what value to use for estimate of the standard error of a prediction. Can I state it as follows: I need to use the halfwidth of the confidence interval, rather than the estimate of the standard error, since the former takes into account the finite size of my series, and the latter doesn't?

POSTED BY: Vladimir Ivanov
Posted 2 years ago

The standard error of prediction is not the same as the halfwidth of the 68.2689% confidence interval when the t-distribution is involved. One is $s$ and the other is $t \times s$. In your case the $t$-value is close to 1 so for large enough sample sizes, the values are similar.

If you had a huge sample size (i.e., you're dealing with a normal distribution rather than a t-distribution), then those two values are essentially the same.

If you just want the standard errors for the observed data points, then

fit["SinglePredictionErrors"]

will get that for you. If you want an estimate of the standard error for a value of the predictor being x0, then the following will get that for you:

CLOneSigma = CDF[NormalDistribution[0, 1], 1] - CDF[NormalDistribution[0, 1], -1] // N;
fit = LinearModelFit[data, {1, x}, x, ConfidenceLevel -> CLOneSigma];
t = InverseCDF[StudentTDistribution[8], 1 - (1 - CLOneSigma)/2];
x0 = 3;
Differences[fit["SinglePredictionBands"] /. x -> x0][[1]]/(2 t)
POSTED BY: Jim Baldwin
Posted 2 years ago

That's because SinglePredictionErrors gives you the estimates of the standard error and the halfwidth of the confidence interval gives you the t-value times the estimate of the standard error.

fit["SinglePredictionBands"] /. x -> # & /@ data[[All, 1]]
(* {{0.455359, 1.81737}, {1.45006, 2.76207}, {2.43915, 3.71237}, {3.42211, 4.6688}, {4.39854, 5.63176}, 
{5.36824, 6.60146}, {6.3312, 7.57789}, {7.28763, 8.56085}, {8.23793, 9.54994}, {9.18263, 10.5446}}*)

fit["SinglePredictionConfidenceIntervals"]
(* {{0.455359, 1.81737}, {1.45006, 2.76207}, {2.43915, 3.71237}, {3.42211, 4.6688}, {4.39854, 5.63176}, 
{5.36824, 6.60146}, {6.3312, 7.57789}, {7.28763, 8.56085}, {8.23793, 9.54994}, {9.18263, 10.5446}}*)

t = InverseCDF[StudentTDistribution[8], 1 - (1 - CLOneSigma)/2];
fit["PredictedResponse"] + (# {-1, 1} & /@ (t*fit["SinglePredictionErrors"]))
(* {{0.455359, 1.81737}, {1.45006, 2.76207}, {2.43915, 3.71237}, {3.42211, 4.6688}, {4.39854, 5.63176}, 
{5.36824, 6.60146}, {6.3312, 7.57789}, {7.28763, 8.56085}, {8.23793, 9.54994}, {9.18263, 10.5446}}*)

or equivalently

spe1 = fit["SinglePredictionErrors"];
t = InverseCDF[StudentTDistribution[8], 1 - (1 - CLOneSigma)/2];
spe2 = Table[((#[[2]] - #[[1]])/(2 t)) &[fit["SinglePredictionBands"] /. x -> data[[i, 1]]], {i, Length[data]}];
spe2/spe1
(* {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.} *)
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