IQ-tree's method for least-squares AU implementation

21 views
Skip to first unread message

Lucas Marques

unread,
Nov 23, 2017, 5:15:07 PM11/23/17
to IQ-TREE
Hi,

I wonder which method IQ-tree uses to minimise the least-squares function for 'c' and 'd' estimation (during AU test p-value calculation).

Does it implement some kind of numeric method or is the function minimised in a more analytical manner? And which is it?

Being an amateur programmer with relatively poor backgrounds in mathematics, I've been struggling to figure out the most efficient way to calculate 'c' and 'd' and would very much appreciate any hint.

Thanks in advance, 
Lucas

Bui Quang Minh

unread,
Nov 24, 2017, 4:12:41 AM11/24/17
to iqt...@googlegroups.com, Lucas Marques
Hi Lucas, There is a closed formula for this, which I implemented in IQ-TREE. Have a look at phylotesting.cpp. For your convenience I paste here the method (copied from the comments in the code):

/*
    Problem: solve the following linear system equation:
    a_1*x + b_1*y = c_1
    a_2*x + b_2*y = c_2
    ....
    a_n*x + b_n*y = c_n

    

becomes minimizing weighted least square:

    sum_k { w_k*[ c_k - (a_k*x + b_k*y) ]^2 }


the solution is:

    x = [(sum_k w_k*b_k*c_k)*(sum_k w_k*a_k*b_k) - (sum_k w_k*a_k*c_k)(sum_k w_k*b_k^2)] / 
        [ (sum_k w_k*a_k*b_k)^2 - (sum_k w_k*a_k^2)*(sum_k w_k*b_k^2) ]

    

    y = [(sum_k w_k*a_k*c_k)*(sum_k w_k*a_k*b_k) - (sum_k w_k*b_k*c_k)(sum_k w_k*a_k^2)] / 
        [ (sum_k w_k*a_k*b_k)^2 - (sum_k w_k*a_k^2)*(sum_k w*k*b_k^2) ]

    

    @param n number of data points
    @param w weight vector of length n
    @param a a value vector of length n
    @param b b value vector of length n
    @param c c value vector of length n
    @param[out] x x-value
    @param[out] y y-value
    @return least square value
*/

Cheers,
Minh

--
You received this message because you are subscribed to the Google Groups "IQ-TREE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iqtree+un...@googlegroups.com.
To post to this group, send email to iqt...@googlegroups.com.
Visit this group at https://groups.google.com/group/iqtree.
For more options, visit https://groups.google.com/d/optout.

--
Bui Quang Minh
Center for Integrative Bioinformatics Vienna (CIBIV)
Campus Vienna Biocenter 5, VBC5, Ebene 1
A-1030 Vienna, Austria
Phone: ++43 1 4277 74326
Email: minh.bui (AT) univie.ac.at

Lucas Marques

unread,
Nov 24, 2017, 5:07:51 PM11/24/17
to IQ-TREE
Thanks for your quick reply, Minh. This will be very helpful. I'll take a close look at the code now. 

Best regards,
Lucas
Reply all
Reply to author
Forward
0 new messages