[ADMB Users] calculating a median

JC Quiroz juancarlos.quiroz at ifop.cl
Fri Nov 30 07:51:10 PST 2012


very useful post. Thanks a lot Philipp 


JC 



----- Original Message ----- 
From: "Philipp Doebler" <philipp.doebler at googlemail.com> 
To: users at admb-project.org 
Sent: Friday, 30 November, 2012 03:00:33 (GMT-0400) Auto-Detected 
Subject: Re: [ADMB Users] calculating a median 

I think what JC is hinting at is, that the median optimizes an L1 loss function. So a variant of the code can work. For example: 

http://stats.stackexchange.com/questions/34613/l1-regression-estimates-median-whereas-l2-regression-estimates-mean 


That means by optimising the sum of the absolute values of the observations minus a parameter which estimate is going to be the median you can obtain the median. This is is many situations computationally less intensive than sorting. 

Best, Philipp 



On Fri, Nov 30, 2012 at 4:21 AM, JC Quiroz < juancarlos.quiroz at ifop.cl > wrote: 




Maybe this will help 


# ******** dat file 

# n 
10 
# y 
1.4 4.7 5.1 8.3 9.0 14.5 14.0 13.4 19.2 18 




// ******** tpl file 

// Likelihood (short) 
DATA_SECTION 
init_int n 
init_vector y(1,n) 


PARAMETER_SECTION 
init_number mu 
init_number logSigma 
objective_function_value f 


PROCEDURE_SECTION 
f=n*logSigma+sum(square(y-mu))/(2.0*square(exp(logSigma))); 




cheers 
JC 

><((((°> ><((((°> ><((((°> ><((((°> ><((((°> 
JC Quiroz 
División de Investigación Pesquera 
Instituto de Fomento Pesquero (IFOP) 
Blanco 839, Valparaíso 
Chile 
tel: 56-32-2151418 
fax: 56-32-2151645 
email: juancarlos.quiroz at ifop.cl 
web: http://codemorecode.wordpress.com/ 





----- Original Message ----- 
From: "Melissa T Drake (DNR)" < melissa.drake at state.mn.us > 
To: users at admb-project.org 
Sent: Thursday, 29 November, 2012 19:03:29 (GMT-0400) Auto-Detected 
Subject: [ADMB Users] calculating a median 




Is there an easy way calculate the median value of a vector? 



Melissa T. Drake 

Fisheries Research Supervisor 

Minnesota Department of Natural Resources 

500 Lafayette Road 

St. Paul, MN 55155 

651-259-5245 

Melissa.drake at state.mn.us 



_______________________________________________ Users mailing list Users at admb-project.org http://lists.admb-project.org/mailman/listinfo/users 
_______________________________________________ 
Users mailing list 
Users at admb-project.org 
http://lists.admb-project.org/mailman/listinfo/users 



_______________________________________________ Users mailing list Users at admb-project.org http://lists.admb-project.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20121130/2b16fe30/attachment.html>


More information about the Users mailing list