the median absolute deviance (mad) of a vector x=(x1,x2....xn) is defined as the median of the absolute differences between each observation and the median of vector x, i.e

mad(

im going to write a function called compute.mad to calculate the mad, but i know how to code the absolute value.

i also have another question which is how to reprent each entry of matrix

im not allowed to use the build-in function

compute.mad <- function(x) {

mad <- median(x-median(x)) #dont know what to write here#

mad

}

anybody can help me ? cheers.

mad(

**x**)= median{ | x1-median(**x**) | ,..., | xn-median(**x**) | }im going to write a function called compute.mad to calculate the mad, but i know how to code the absolute value.

i also have another question which is how to reprent each entry of matrix

**x**such as x1,x2....im not allowed to use the build-in function

*mad*.compute.mad <- function(x) {

mad <- median(x-median(x)) #dont know what to write here#

mad

}

anybody can help me ? cheers.

Last edited: