BookmarkSubscribeRSS Feed
Cecillia_Mao
Obsidian | Level 7

Hi everyone, does anyone know how to calculate mean error(ME) in SAS. I checked the proc means, its statistical list does not contain ME. So I'm wondering are there any procedures that can calculate ME directly? Thanks for any hints.

 

Cecillia_Mao_0-1606921855724.png

 

9 REPLIES 9
PaigeMiller
Diamond | Level 26

In a data step, compute the value of y minus y-hat. Then in PROC MEANS or PROC SUMMARY, compute the mean of this difference.

 

If that's not what you are looking for, then a few more details would help. What is meant in the formula by y-hat? Does it have to do with predicting (the word "prediction" appears) from a model? If so, what type of model (and what SAS PROC) creates this model? What are the variable names in your SAS data set? 

--
Paige Miller
Cecillia_Mao
Obsidian | Level 7
Thanks a lot! I really appreciate it! Sometimes, if there is no available options, we do need to calculated step by steps.
ballardw
Super User

If y sub i is an individual value and the y hat is the predicted then you are looking at residuals and that looks like the mean of residuals. If so, then you run a regression and get the residuals in the output. Then take the mean of the residual.

 

 

PaigeMiller
Diamond | Level 26

@ballardw wrote:

If y sub i is an individual value and the y hat is the predicted then you are looking at residuals and that looks like the mean of residuals. If so, then you run a regression and get the residuals in the output. Then take the mean of the residual.


Which is zero for many types of models. No need to compute it (if this comes from one of those types of models)

--
Paige Miller
ballardw
Super User

@PaigeMiller wrote:

@ballardw wrote:

If y sub i is an individual value and the y hat is the predicted then you are looking at residuals and that looks like the mean of residuals. If so, then you run a regression and get the residuals in the output. Then take the mean of the residual.


Which is zero for many types of models. No need to compute it (if this comes from one of those types of models)


Yep. Which is partially why I was asking what the y values in the formula represent.

Cecillia_Mao
Obsidian | Level 7
Thank you Ballardw, I'm sorry for the late reply. I was confused with the following two staitistics: "mean error" and "mean deviation" mean deviation,which is sum(X-X̄)/n. Thanks for clarification.
Reeza
Super User

For the Mean error you need an observed/recorded value minus the predicted value, which comes from a model. 

 

If you only have a single value, the typical estimate ends up being the mean, so then your formula changes to 

 

1/n*sum(observed - mean(x))

 

which has a value of 0 always. I'll leave the algebra as an exercise for you, or for you to google at least 😉

 

Unless you have a modeled value, this is a 'trick' question. This is why the mean squared error or the mean absolute error measures are used instead.

 


@Cecillia_Mao wrote:

Hi everyone, does anyone know how to calculate mean error(ME) in SAS. I checked the proc means, its statistical list does not contain ME. So I'm wondering are there any procedures that can calculate ME directly? Thanks for any hints.

 

Cecillia_Mao_0-1606921855724.png

 


 

Cecillia_Mao
Obsidian | Level 7
Thank you so much Reeza. That totally make sense why mean squared error or the mean absolute error measures are used more often. I was supposed to ask how to calculate mean deviation. Unlike to standard deviation, I believe meand deviation can't be calculated using proc means options directly.
Ksharp
Super User
If you have two columns Y and Y_Hat:

proc sql;
select mean(Y-Y_Hat) from have;
quit;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 2003 views
  • 8 likes
  • 5 in conversation