Hey y'all

In class we learned that

48, 52, 76, 88, 92, 92, 100

AD=15.43

but then in R i tried and i get

new <- c(48, 52, 76, 88, 92, 92, 100)

mad(new)

17.7912

Any thoughts?

For some reason I don't understand, they use a constant value (1.4826) to ensure consistency. I think you can change that parameter (constant=?) to get the class MAD.

MAD is the **median** absolute deviation from the **median**. Your formula from class is for the **mean** absolute deviation from the **median**. The simple median value is 12, which when multiplied by the default constant of 1.4826 for asymptotically normal consistency gives the reported value of 17.7912.

Some general advice: when something appears to be wrong, check the R help documentation.

Thank you sir! Is there a command or an option to change R settings (in a specific syntax if needed) so it calculates the mean instead of the median?

mean(abs(new-median(new)))

mean(), abs() and median() are all functions in the stats package

thanks. also helped me with finding

mean((new-mean(new))^2) #mean diff

Hi @RYann, a lot of statistical functions are already there in R. To calculate variance, you can use `var`

. You don't need to calculate manually.

However, I should add, most of these will calculate sample versions (which will be unbiased estimators of population versions) only, so for `var`

, `n-1`

will be used as the denominator instead of `n`

. If you specifically need population version, then your solution is correct way.

Hope this helps.

Cheers man, I appreciate any tips! I'm only starting in this world. So any help is much appreciated.

I use var like you say,

Var(sample(X,10000, replace = T, prob=Px)

Our prof. showed us the basic principle that the bigger the sample, the closer var gets to its "pure var". Also using table(X)/length(X)...

Happy new year

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.