bruno
YaBB Newbies
Offline
I love YaBB 1G - SP1!
Posts: 13
|
Dear Sergei,
Great, it did the trick, now both the optimize and the sum of site likelihoods returns the same value. Now i think it is more or less finished, but i have what i hope to be the last questions on this analysis (and thanks again for all your help). below is the part of the code implementing the Jackknife protocol:
----------------------------------------------------------------------- pv_significant = 0; AIC_significant = 0; AICcc_significant = 0; AICcl_significant = 0; /* Starts looping over JackKnife replicates */ for (JackIterate = 0; JackIterate < Njackknife; JackIterate = JackIterate + 1) { fprintf (stdout, "Calculating JackKnife replicate ", JackIterate, "\n"); Loglik_best = 0; Loglik_worst = 0; /* Calculates the likelihood by resampling (with replacement) a specified number of sites the resulting likelihood is assumed to be the sum of individual sites' likelihood */ for (JackSite = 0; JackSite < JackLength; JackSite = JackSite+1){ aNumber = Random (0, filteredData.sites-1); anIntegerRandomNumber = aNumber$1;
Loglik_best = Loglik_best + bySiteLogLBest[anIntegerRandomNumber]; Loglik_worst = Loglik_worst + bySiteLogLStar[anIntegerRandomNumber]; } fprintf (stdout, "\n\n Loglikelihood of star ", Loglik_worst, " Loglik of best ", Loglik_best, "\n"); /* Now the LRT and AIC tests */ LRTtest = calculateLRT (Loglik_best, Loglik_worst, DFdifference); fprintf (stdout, "LRT significance: ", LRTtest, "\n"); if (LRTtest < 0.05){ pv_significant = pv_significant+1; } AICtest_star = calculateAIC (Loglik_worst, DF_star); AICtest_es = calculateAIC (Loglik_best, DF_es); fprintf (stdout, "AICstar and AIC best tree: ", AICtest_star, " ", AICtest_es, "\n"); if (AICtest_star > AICtest_es){ AIC_significant = AIC_significant+1; } AICcctest_star = calculateAICc (Loglik_worst, DF_star, JackLength); AICcctest_es = calculateAICc (Loglik_best, DF_es, JackLength); fprintf (stdout, "AICcc star and AICcc best tree: ", AICcctest_star, " ", AICcctest_es, "\n");
if (AICcctest_star > AICcctest_es){ AICcc_significant = AICcc_significant+1; } AICcltest_star = calculateAICc (Loglik_worst, DF_star, JackLength*cladesDefined); AICcltest_es = calculateAICc (Loglik_best, DF_es, JackLength*cladesDefined); fprintf (stdout, "AICcl star and AICcl best tree: ", AICcltest_star, " ", AICcltest_es, "\n");
if (AICcltest_star > AICcltest_es){ AICcl_significant = AICcl_significant+1; } } RESULTS_LRT[iterate] = pv_significant; RESULTS_AIC[iterate] = AIC_significant; RESULTS_AICcc[iterate] = AICcc_significant; RESULTS_AICcl[iterate] = AICcl_significant; } ------------------ end of code ------------------------
I think it is working fine, but im not sure. specially the line aNumber = Random (0, filteredData.sites-1); does this sample from the entire alignment? Or the -1 should not be there?
Then i also have some questions regarding the AIC calculation (the LRT i used your formula so it should be ok). I am not quite sure of what value to use in the formula
AIC = 2k - 2*lik
Does lik in this formula correspond to LogLik or to LnLik? I add the following 2 functions for AIC and AICc:
function calculateAIC (lik, DegreesFreedom){ AIC = 2*DegreesFreedom-2*lik; return AIC; } /* Now the AICc - this can be calculated either with the nulber of sites (conservative estimate) or with the number of sites*number of sequences (liberal estimate) just feed it the correct number of observations in the 3rd parameter */ function calculateAICc (lik, DegreesFreedom, Nobs){ AICc = 2*DegreesFreedom - 2*lik + 2*DegreesFreedom*(DegreesFreedom+1)/(Nobs-DegreesFreedom-1); return AICc; }
--------------------------------------------------------
And for each case i supplied the LogLikelihood as calculated by the sum of LogLik of each site. Should this be correct?
And finally, is there any way i can test this script? Just to make sure that there is nothing wrong with it before actually using the results of the analysis.
Thank you very much, Cheers, Bruno
|