On 9/18/07, Nair, Murlidharan T <[EMAIL PROTECTED]> wrote: > > > -----Original Message----- > From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] > Sent: Monday, September 17, 2007 5:10 PM > To: Nair, Murlidharan T > Cc: [EMAIL PROTECTED] > Subject: Re: [R] MAD > > On 9/17/07, Nair, Murlidharan T <[EMAIL PROTECTED]> wrote: > > > > I am calculating the median absolute deviation using mad function, and > > it tends to ignore the parameter constant=1, when I am calculating it > > for x=seq(1:5). Am I missing something here? > > > > x<-seq(1:5) > > mad(x)# gives [1] 1.4826 > > mad(x, constant=1)# gives [1] 1 > > #Here is the long form > > dev.from.median<-abs((x-median(x))) > > dev.from.median # Gives [1] 2 1 0 1 2 > > sum(dev.from.median) # Gives [1] 6 > > sum(dev.from.median)/length(x) # Gives [1] 1.2
I'm pretty sure that adding up a bunch of numbers and dividing the total by the number of numbers qualifies as computing the mean, not the median. > > Did I miss anything here? > > yes; mad := Median (not mean) absolute deviation (from the median, by > default). > > -Deepayan > > Indeed, its median and that what I am calculating in the long form. So, > what is that you found I was doing differently? May be I missed your > point. > Thx../M > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.