Meta tags:
Headings (most frequently used words):
model, 2026, character, multi, july, discrete, dependent, ou, phytools, for, regime, in, about, blog, joint, under, the, using, on, phylogenetic, tools, comparative, biology, pages, sunday, august, wednesday, 29, tuesday, 14, monday, 13, saturday, 11, this, me, links, archive, small, experiment, but, strong, case, estimation, of, continuous, trait, evolution, stochastic, mapping, threshold, fitthresh, comparing, to, ouwie, visualizing, process, tree, more, optimum, null, ornstein, uhlenbeck,
Text of the page (most frequently used words):
the (244), model (132), this (93), our (92), #discrete (91), theta (83), character (82), alpha (70), for (65), that (65), and (61), with (55), low (54), high (53), phytools (49), tree (48), phy (47), trait (46), log (45), set (45), letters (42), sigsq (41), using (39), history (38), let (37), multi (37), levels (36), ouwie (34), fit (33), setnames (32), but (31), fitmultiou (31), continuous (31), true (30), sim_tree (30), likelihood (29), 100 (29), regime (29), fitted (28), data (28), threshold (27), 200 (26), now (25), object (24), fitmk (24), root (23), simulate (23), plot (23), matrix (22), colors (22), smp (22), stochastic (21), july (20), going (20), just (20), may (19), some (19), can (19), share (18), mk_fit (18), parameters (18), tips (18), lwd (18), not (18), 267 (18), phylogenetic (17), parameter (17), estimates (17), generating (17), hcl (17), includes (17), process (17), june (16), joint (16), levs (16), values (16), done (16), null (16), same (16), which (16), value (16), head (16), from (16), will (16), cols (16), december (15), january (15), march (15), august (15), september (15), fit_null (15), sig2 (15), has (15), solution (15), t49 (15), off (15), nodes (15), tip (15), dependent (15), init (15), april (14), november (14), more (14), class (14), ncores (14), sigma (14), simmap (14), october (13), should (13), estimated (13), prior (13), optimization (13), fitcontinuous (13), state (13), under (13), each (13), would (13), have (13), very (13), all (13), see (13), february (12), new (12), pretty (12), these (12), thinks (12), warning (12), geiger (12), multiou (12), simulation (12), use (12), ftype (12), internal (12), follows (12), max (12), merged (12), zero (12), t38 (12), rates (11), based (11), found (11), mle (11), get (11), states (11), upwards (11), col (11), labels (11), rooted (11), branch (11), length (11), because (11), fit_mou (11), fitthresh (11), t16 (11), t21 (11), t123 (11), t124 (11), loglik (10), compare (10), ou_fit (10), though (10), t19 (10), need (10), next (10), two (10), direction (10), also (10), transition (10), library (10), out (10), mean (10), map (10), results (10), ouwie_results (10), smps (10), revell (9), package (9), posted (9), here (9), optimizing (9), was (9), summary (9), iterations (9), function (9), start (9), t53 (9), pull (9), getstates (9), different (9), are (9), make (9), fixed (9), rstate (9), sum (9), probabilities (9), slightly (9), setting (9), other (9), liam (8), about (8), email (8), cool (8), null_logl (8), again (8), list (8), iter (8), parallel (8), trace (8), then (8), method (8), only (8), rep (8), par (8), legend (8), bottomleft (8), bty (8), mapped (8), load (8), nodeheights (8), across (8), maps (8), rate (8), models (8), case (7), 2026 (7), blog (7), expect (7), attr (7), even (7), closely (7), discretization (7), post (7), used (7), aic (7), number (7), might (7), sim (7), approximation (7), 283 (7), optimum (7), between (7), regimes (7), numeric (7), ms_thresh (7), liability (7), foreach (7), pinterest (6), facebook (6), blogthis (6), comments (6), 300 (6), comparative (6), best (6), factor (6), step (6), conditions (6), since (6), cex (6), lengths (6), anc (6), dimnames (6), pbtree (6), scale (6), time (6), how (6), close (6), 2094242 (6), 500 (6), 255589 (6), what (6), 2554668 (6), when (6), generate (6), changes (6), quite (6), genus_species (6), reg (6), t35 (6), frame (6), diag (6), t28 (6), t31 (6), t32 (6), t23 (6), t24 (6), mergemappedstates (6), liabilities (6), following (6), 472 (6), ouwie_data (6), small (5), posts (5), similar (5), 1883095 (5), well (5), equal (5), due (5), treating (5), nlminb (5), aicc (5), search (5), add (5), lend (5), estimation (5), trees (5), been (5), evolution (5), single (5), one (5), diffusion (5), print (5), 287 (5), seems (5), 400 (5), maxit (5), 2000 (5), run (5), first (5), already (5), false (5), course (5), fitting (5), t89 (5), t90 (5), vary (5), mapping (5), thresh_fit (5), sapply (5), 350 (5), histories (5), 2016 (4), you (4), before (4), version (4), both (4), likelihoods (4), increase (4), far (4), finally (4), once (4), opt (4), comparison (4), match (4), those (4), null_model (4), while (4), 188436 (4), free (4), t10 (4), t54 (4), simulated (4), specify (4), good (4), nrow (4), probably (4), note (4), them (4), few (4), pre (4), there (4), 7812 (4), better (4), than (4), 0693 (4), 600 (4), var (4), bit (4), starting (4), t44 (4), t57 (4), t136 (4), t177 (4), analysis (4), into (4), loading (4), thought (4), hidden (4), characters (4), original (4), infrequently (4), oum (4), finished (4), station (4), 02713072 (4), 142 (4), long (4), 028064 (4), 02921177 (4), they (4), finite (4), space (4), mkn (4), fitzjohn (4), nsim (4), mk_model (4), mkm (4), fun (4), bias (4), 7823842 (4), options (4), scipen (4), 355 (4), foo (4), ouwie_fits (4), type (4), 458785 (4), 250 (4), 03312624 (4), 241 (4), 036172 (4), 2013 (3), 2014 (3), experiment (3), page (3), tools (3), analyses (3), recommend (3), cran (3), home (3), 5433 (3), converge (3), obj (3), don (3), ready (3), takes (3), earlier (3), flat (3), convergence (3), diagnostics (3), failed (3), frequency (3), lik (3), bnd (3), bounds (3), res (3), iteration (3), maximum (3), still (3), root_state (3), code (3), actually (3), ahead (3), decided (3), reasonable (3), obtain (3), estimate (3), another (3), ornstein (3), uhlenbeck (3), boucher (3), démery (3), interested (3), biorxiv (3), weight (3), 0493 (3), know (3), much (3), 7939 (3), 0513 (3), 0689 (3), 4188483 (3), 700 (3), 06931472 (3), sensible (3), 284 (3), obtained (3), 511178 (3), 333333 (3), confirm (3), 0829 (3), 5109335 (3), 199 (3), want (3), work (3), recent (3), recently (3), readers (3), line (3), stat_theta (3), seq (3), min (3), packages (3), usually (3), way (3), begin (3), known (3), indeed (3), 8523 (3), 3246 (3), 4163 (3), 0271 (3), matches (3), ou1 (3), result (3), names (3), goes (3), great (3), rowsums (3), jointly (3), along (3), something (3), methods (3), biased (3), 0253 (3), 1673 (3), 352 (3), 354 (3), likely (3), 249 (3), 9258 (3), 159 (2), 2017 (2), 2025 (2), strong (2), lab (2), webpage (2), latest (2), similarity (2), 58921 (2), ignore (2), unlist (2), colnames (2), quick (2), too (2), 5912 (2), 5499 (2), 1496 (2), 430 (2), 8024 (2), evolutionary (2), traits (2), however (2), including (2), who (2), simulating (2), isn (2), demo (2), practice (2), packageversion (2), check (2), corresponding (2), trying (2), dependence (2), hope (2), separately (2), identifiable (2), without (2), ago (2), details (2), general (2), compared (2), anova (2), naturally (2), whether (2), were (2), 1335 (2), 1852 (2), 0707 (2), 2202 (2), 800 (2), 2003 (2), 900 (2), 2156 (2), 7829 (2), 2094 (2), converged (2), try (2), 1910 (2), 0528 (2), 2053 (2), 0527 (2), 9134 (2), fact (2), caution (2), 185 (2), 5743 (2), 0141 (2), unknown (2), taxa (2), none (2), hand (2), required (2), consider (2), future (2), morning (2), layout (2), mar (2), xlim (2), mtext (2), adj (2), transparent (2), predicted (2), distribution (2), stat (2), norm (2), singleton (2), later (2), illustration (2), look (2), fairly (2), keeping (2), mind (2), lnl (2), bic (2), ntax (2), 3007500 (2), 1198701 (2), optima (2), half (2), life (2), reporting (2), 304729 (2), arrived (2), reliable (2), fitoum (2), initializing (2), thorough (2), summarizing (2), algorithm (2), specified (2), defaulting (2), computing (2), determinant (2), inversion (2), vcv (2), 4519 (2), 1141 (2), 4520 (2), matter (2), got (2), fitou (2), give (2), simply (2), 3416784 (2), 6347880 (2), 3128115 (2), 5001694 (2), 7747887 (2), 5183583 (2), special (2), format (2), higher (2), fix (2), 6338 (2), 1838 (2), 175 (2), towards (2), infty (2), squared (2), sample (2), over (2), thesis (2), interesting (2), uses (2), review (2), comparing (2), thresholds (2), does (2), lowermost (2), through (2), complicated (2), many (2), back (2), makes (2), sense (2), standard (2), clearly (2), side (2), big (2), discretized (2), totally (2), times (2), t25 (2), t26 (2), t27 (2), t33 (2), thresh (2), underlying (2), functions (2), making (2), mvmorph (2), lot (2), days (2), away (2), seem (2), traditional (2), perhaps (2), difference (2), underestimate (2), 4625 (2), 4682 (2), 2082 (2), 473 (2), colmeans (2), average (2), 360 (2), 356 (2), 358 (2), printing (2), round (2), digits (2), rownames (2), makecluster (2), psock (2), registerdoparallel (2), optimize (2), dopar (2), stopcluster (2), parallelize (2), 142639 (2), 634035 (2), 209871 (2), 537554 (2), 871243 (2), 072081 (2), specific (2), mfrow (2), nulo (2), nuisance (2), differ (2), mathbf (2), ylim (2), 1009 (2), 9043 (2), 2719 (2), 0331 (2), 227 (2), 193 (2), cluster (2), doparallel (2), 6548297 (2), 7918578 (2), 1488759 (2), 4502061 (2), 3959087 (2), 2302126 (2), sunday (2), workflow (2), biology (2), powered, blogger, 2010, 162, 2011, 2012, 123, 2015, 132, 154, 2018, 2019, 2020, 2021, 2022, 2023, 2024, archive, umass, boston, faculty, phylogenetics, links, view, complete, profile, web, chronicles, development, install, attempting, replicate, any, site, beta, release, subscribe, atom, older, soon, come, micro, experimentation, confirms, limit, 5498946, 5498956, 1521741, 1495582, 5928578, 5912444, 1884358, cbind, throw, 0991, 0802, 0040, 0662, 5097, 6013, 3368, 0960, 1504, 6002, 5436, 1250, 2330, 1476, 5919, 5487, 1494, 1888, 5434, 331, 1883, having, effect, mode, had, realized, matched, ran, 29465, 549895, 152174, 592858, 294564, 589128, 017699, quickly, 5425203, 2690402, 4526387, 2366645, 1525741, 9399830, people, like, adapt, necessary, anyway, visualize, could, take, larger, started, colleague, prototype, consequently, write, today, demonstrating, illustrate, extent, numerical, precision, update, inadvertently, x_0, geq, github, weeks, technical, approach, saturday, preliminary, tells, basically, evidence, falls, 582, 0985, 166496e, 547, 5624, 000000e, explains, independent, easy, remarkably, remember, definitely, 2324, 6486, 9372, 0436, 2556, 315, 4681, 5480, 6211, 3112, 1711, 0816, 1765, 270, 5138, 9475, 9025, 0608, 1907, 0725, 2221, 268, 0952, 8971, 7990, 0222, 1960, 2176, 9648, 8941, 8285, 0684, 1935, 0701, 9573, 8831, 8318, 0694, 1936, 2166, 9496, 8828, 8724, 0711, 1903, 0708, 2171, 9394, 8728, 8737, 0625, 1894, 0710, 2152, 9342, 8513, 8355, 9719, 0724, 2116, 9037, 8589, 8295, 9641, 0720, 2139, 9002, 1000, 8613, 8330, 9623, 0719, 2149, 8995, 1100, 8608, 8220, 9628, 0713, 2154, 8972, 1200, 8600, 8276, 9672, 2008, 0712, 8957, 1300, 8269, 0429, 0894, 1860, 0700, 2134, 8096, 1400, 8193, 0484, 1319, 1836, 0691, 2161, 7998, 1500, 8143, 0503, 1171, 1844, 0696, 2132, 7953, 1600, 7951, 0509, 1326, 1842, 0690, 2107, 1700, 1340, 1851, 2095, 1723, 23239962, 64856597, 93721136, 04357107, 25558924, difficult, suspicious, 3575, 3680, 8215, 2403, 0115, 2066, 309, 6850, 3023, 0148, 6594, 2779, 0615, 1947, 8126, 2191, 1288, 9057, 2837, 0611, 1861, 2140, 1372, 9328, 2794, 0554, 1914, 0423, 2355, 1808, 9946, 2713, 0499, 1976, 9893, 2229, 1901, 0192, 2716, 0514, 2043, 9538, 2210, 9799, 2748, 0519, 2054, 9183, 2172, 2083, 9723, 2747, 2056, 9137, 2164, 2088, 9738, 2751, 9135, 9724, 2753, 2052, 913, 2157, 2097, 9725, 2752, farther, apart, comfortable, undoubtedly, substantially, 285, 5048, 195, 760975, 012919, 081833, 655514, 743851, 487702, 610151, hard, 0601, 2682, 0177, 409, 2704, 4702, 0182, 0846, 2622, 2005, 5735, 0150, 2569, 0941, 279, 2555, awesome, vector, 9418267, 5788125, 2039455, 7955580, 6064443, 9103976, nearly, allows, multiple, assumes, constant, continous, empirical, shall, aside, move, forward, readily, ape, writing, versions, checking, utmost, nonetheless, works, simpler, alternative, covered, monday, comment, nothing, heights, margins, second, subplot, phenogram, axis, las, equilibrium, dnorm, sqrt, polygon, border, unbranching, era, limits, 1001, chunk, objects, become, useful, contrast, three, phytools_liam, pic, twitter, com, jrmalmqpbh, https, lplhskjoo6, tweet, included, derived, visualizing, tuesday, folks, hold, whenever, unambiguous, diminish, increases, implements, 47594, 95187, 37292, 107, 3726, 75307314, 5184579, 09854245, 1132707, forget, almost, never, genuinely, knew, always, 2784, 6184, 1283, 0281, 1417, 4558, 8575, 3260, 1157, 0268, 4242, 8537, 3254, 1143, 0267, 4172, 4531, 8535, 3252, 1145, 0269, 4170, 1142, 404, 27841916, 61842864, 12828760, 02806402, identify, blogging, remind, reader, hypothesizing, hopefully, 25048, 501, 751, 150, 3165, 524044e, 510672e, 6250224, 3348563, 45480781, why, compile, put, bring, picture, updated, closer, currently, implemented, really, 18378, 41855, compute, assure, ourselves, converging, 168076, 000000, 085106, 625022, 250476, 500953, 750953, 086, 9456, 0721, 1329, 0914, 6004, 6244, 0116, 0897, 3007, 6123, 0053, 0892, 0283, 2222, 271, 0004, 0860, 0292, degree, exactly, assumptions, twice, completeness, point, generator, according, dependentn, hypothesis, explore, integrates, uncertainty, highly, implement, popular, brian, meara, jeremy, beaulieu, described, wow, beautiful, repeat, estimable, otherwise, non, normally, centers, whole, instead, unitless, scaleless, doesn, relative, positions, annoying, interpret, lower, 7568, 341537, 847661, sequence, threshstate, reuse, things, little, instance, crossing, involves, switches, forth, perfect, capturing, form, seeing, looks, running, turn, merge, contains, finely, effectively, typically, accomplished, modifying, iterating, subsequent, steps, message, elements, safely, believe, element, feel, undertake, implicit, within, 04421, 08842, 1050167, 90152, 80305, 8949833, symmetric, distinguishable, 901524, proceed, t37, t79, t80, t29, t30, t46, t47, else, 9810162, 1667724, 9394853, 5019343, 2609373, 1475927, 4670823, 2442964, 7697432, 0546414, fastbm, simplest, example, call, yet, software, straightforward, automated, show, inasmuch, crossed, fractal, moves, didn, trust, technically, enable, sorts, actual, weird, question, regarding, your, bins, test, multivariate, shape, reconstructing, ancestral, reconstruction, sort, convert, full, transitions, recommendation, play, nice, etc, answer, right, worries, couldn, sus, own, mvbm, unfortunately, responsive, inquiries, sorry, yesterday, user, contacted, subject, text, getting, style, wednesday, imo, admittedly, fine, generally, affirms, ought, cited, becomes, tends, affect, measurement, underestimated, overestimated, astonishing, convincing, 9220, 2096, 1930, 4588, 622, 5731, 1219, 2495, 4753, 6045, 5548, 490, 4077, 6367, 8417, 4181, 2777, 6418, 6047, 4362, 4288, 2951, 6848, 2549, 5098, 0866, 4541, 1942, 7713, 2389, 4734, 0244, 4641, 2102, 7708, 1732, 4698, 0304, 4678, 2093, 7854, 1688, 4622, 4686, 2081, 732, 7824, particular, downwards, 0776599, 7045410, 2024869, 7556554, 7203710, 349, 353, 342, 359, 341, summarize, error, estimating, consequence, evident, think, arisen, widely, did, 499556, 500444, 945824, expected, change, gave, accurate, particularly, regard, 632, 1410, 4069, 5262, 0369, 378, 6136, 3327, 7524, 3626, 0282, 258, 4337, 0864, 8329, 5574, 2065, 0202, 247, 0498, 1137, 9956, 5351, 2351, 0203, 245, 0731, 0581, 8858, 6185, 2743, 0387, 242, 3865, 0999, 9000, 6364, 2739, 0330, 9284, 1005, 9045, 6323, 2720, 666, 6320, 14104895, 40690078, 52619893, 03687111, predict, 06588211, 91247554, 49325269, 40862951, 208, 88237689, shows, 182, 194, 224, 206, 209, 216, 214, 192, 186, 232, 178, 213, 180, 228, 210, 239, 207, 196, created, easier, pattern, socket, host, localhost, detectcores, speed, notice, immediately, resemble, 32705, 67295, 278772, imagine, unobserved, terrific, assume, where, comes, theta_a, theta_b, conditioning, depends, total, depth, intend, engineer, simple, circumstances, words, uncertain, among, magnitude, typical, huelsenbeck, pointed, heterogeneous, tend, knowledge, studied, explicitly, talking, documented, couple, entry, princeton, pages,
Text of the page (random words):
the ml solution finally we can fit our fixed regime model using the ouwie package here don t forget that though i will be using the true discrete character history this is almost never known in practice indeed if we genuinely knew the discrete character history i would always recommend fitting a fixed regime model not a joint model fit multi regime ou model using ouwie fitoum smp ouwie sim_tree ouwie data model oum simmap tree true root station false warning an algorithm was not specified defaulting to computing the determinant and inversion of the vcv initializing finished begin thorough search finished summarizing results fitoum smp fit lnl aic aicc bic model ntax 44 47594 96 95187 97 37292 107 3726 oum 100 rates b a alpha 0 3007500 0 3007500 sigma sq 0 1198701 0 1198701 optima b a estimate 1 75307314 0 5184579 se 0 09854245 0 1132707 half life another way of reporting alpha b a 2 304729 2 304729 arrived at a reliable solution cool now if we look closely at our results we should see that our parameter estimates do in fact match up fairly well keeping in mind of course that these are not the same models the ouwie model is based on fixed regimes while our fitmultiou function implements a joint discrete trait continuous character evolutionary model i would expect this similarity to hold whenever our discrete character history is pretty unambiguous usually because the character changes quite infrequently on the tree but to diminish as the rate or number of changes of our discrete trait increases that s all folks posted by liam revell at 10 55 am 3 comments email this blogthis share to x share to facebook share to pinterest tuesday july 14 2026 visualizing a multi regime ou process on the tree using phytools in a recent tweet about phytools new discrete character dependent multi optimum ou model i included an illustration of this process that was not derived from the original blog post more on a discrete character dependent multi optimum ou model in phytools https t co lplhskjoo6 pic twitter com jrmalmqpbh liam revell phytools_liam july 13 2026 just in case it might become useful later i decided to post the code for that cool illustration here in contrast to my prior use here i decided to set different values for alpha sigma 2 as well as for theta between the three regimes load packages library phytools in this first chunk i m going to generate the data and objects i need for the plot simulate a tree tree pbtree n 100 scale 10 add singleton unbranching nodes tt map to singleton make era map tree limits seq 0 10 length out 1001 set the transition matrix for the discrete trait q 0 2 q matrix c 2 q q q q 2 q q q q 2 q 3 3 dimnames list letters 1 3 letters 1 3 generate a character history of the discrete trait s tt sim history tt q anc a done simulation s set the parameters of the multi regime ou process theta setnames c 0 5 0 9 2 2 letters 1 3 sigsq setnames c 0 12 0 05 0 08 letters 1 3 alpha setnames c 0 7 0 4 0 8 letters 1 3 generate data for tips and nodes under the multi regime ou process x multiou s tt alpha alpha sig2 sigsq theta theta a0 theta a internal true now for our plot set colors cols setnames hcl colors n 3 letters 1 3 set plot layout layout matrix c 1 2 2 1 heights c 0 4 0 6 plot discrete character history on the tree plot s tt cols ftype off mar c 1 1 4 1 2 1 2 1 xlim c 0 11 mtext a adj 0 line 0 set margins for second subplot par mar c 5 1 4 1 2 1 2 1 plot continuous character history phenogram s tt x ftype off colors make transparent cols 0 5 xlim c 0 11 cex axis 0 8 las 1 mtext b adj 0 line 1 5 add the predicted equilibrium distribution at the tips for i in 1 length theta stat_theta dnorm seq min x max x length out 200 mean theta i sd sqrt sigsq i 2 alpha i stat norm stat_theta max stat_theta polygon x c 0 stat norm 0 10 y c min x seq min x max x length out 200 max x border false col make transparent cols i 0 5 nothing to it posted by liam revell at 12 11 pm 1 comment email this blogthis share to x share to facebook share to pinterest monday july 13 2026 more on a discrete character dependent multi optimum ou model in phytools good morning blog readers recently i ve posted about a new discrete character dependent multi theta i e multi optimum ou model in phytools e g 1 2 3 since this is very new it should only be used with the utmost caution nonetheless i thought i d post up a quick demo of how it works and how to do a model comparison to a simpler model of joint discrete continuous trait evolution but without dependence we also might consider an alternative null model with hidden characters but this will have to be covered in a future post this will only work on recent at the time of writing versions of phytools so we can start by loading the package checking which version we have library phytools loading required package ape loading required package maps packageversion phytools 1 2 6 3 to fit this model i m going to need some data with none readily at hand i m going to use phytools to simulate some we can start with a tree n 200 number of taxa phy pbtree n n scale 10 phy phylogenetic tree with 200 tips and 199 internal nodes tip labels t6 t7 t44 t57 t136 t177 rooted includes branch length s next we want a generating discrete character history for our multi regime ou process note that though we use this regime history for simulation in an empirical case it would ve been unknown so shall naturally be set aside when we move forward to estimation set the transition matrix of our discrete trait q 0 2 q matrix c 2 q q q q 2 q q q q 2 q 3 3 dimnames list letters 1 3 letters 1 3 q a b c a 0 4 0 2 0 2 b 0 2 0 4 0 2 c 0 2 0 2 0 4 k nrow q trait levels k 1 3 sim_tree sim history phy q anc a done simulation s sim_tree phylogenetic tree with 200 tips and 199 internal nodes tip labels t6 t7 t44 t57 t136 t177 the tree includes a mapped 3 state discrete character with states a b c rooted includes branch lengths let s plot our generating tree as follows cols setnames hcl colors n 3 letters 1 k plot sim_tree cols ftype off lwd 1 direction upwards par lend 1 legend bottomleft letters 1 3 lwd 3 col hcl colors n k cex 0 8 bty n next we can set the generating conditions for our continous trait simulation our model allows for multiple theta by discrete character state but assumes constant alpha and sigma 2 across the k levels of our discrete trait so let s simulate that alpha setnames rep 0 3 k letters 1 k alpha a b c 0 3 0 3 0 3 sig2 setnames rep 0 1 k letters 1 k sig2 a b c 0 1 0 1 0 1 theta setnames c 0 5 1 2 letters 1 k theta a b c 0 5 1 0 2 0 now we re nearly ready to simulate our continuous trait to do that i ll use phytools multiou as i have in prior posts x multiou sim_tree alpha sig2 theta a0 0 head x t6 t7 t44 t57 t136 t177 1 9418267 0 5788125 1 2039455 0 7955580 0 6064443 0 9103976 though we ve simulated our discrete character history already for our analysis we ll use just the tip states so let s pull those into a factor vector using phytools getstates y as factor getstates sim_tree tips head y t6 t7 t44 t57 t136 t177 a b c a c c levels a b c awesome now let s first fit our null model using fitmultiou fit_null fitmultiou phy x y model er levs 100 parallel true ncores 10 root mle trace 1 null_model true iter theta alpha sigsq q 1 log l 0 1 0601 0 2025 0 2682 0 0177 409 2704 100 0 4702 0 0182 0 0846 0 2622 287 2005 200 0 5735 0 0150 0 0829 0 2569 287 0941 279 0 5743 0 0141 0 0829 0 2555 287 0493 done optimizing fit_null object of class fitmultiou based on a discretization with k 100 levels fitted multi theta ou model parameters levels a b c theta 0 5743 alpha 0 0141 sigsq 0 0829 estimated q matrix a b c a 0 5109335 0 2554668 0 2554668 b 0 2554668 0 5109335 0 2554668 c 0 2554668 0 2554668 0 5109335 log likelihood 287 0493 r thinks it has found the ml solution let s confirm that our parameter estimates and log likelihood match what we would ve obtained using a geiger fitcontinuous and phytools fitmk this isn t hard ou_fit geiger fitcontinuous phy x model ou ou_fit geiger fitted comparative model of continuous data fitted ou model parameters alpha 0 012919 sigsq 0 081833 z0 0 655514 model summary log likelihood 89 743851 aic 185 487702 aicc 185 610151 free parameters 3 convergence diagnostics optimization iterations 100 failed iterations 0 number of iterations with same best fit 50 frequency of best fit 0 500 object summary lik likelihood function bnd bounds for likelihood search res optimization iteration summary opt maximum likelihood parameter estimates mk_fit fitmk phy y model er pi equal mk_fit object of class fitmk fitted or set value of q a b c a 0 511178 0 255589 0 255589 b 0 255589 0 511178 0 255589 c 0 255589 0 255589 0 511178 fitted or set value of pi a b c 0 333333 0 333333 0 333333 due to treating the root prior as a flat log likelihood 195 760975 optimization method used was nlminb r thinks it has found the ml solution null_logl loglik ou_fit loglik mk_fit null_logl 1 285 5048 attr df 1 3 this should be very close to the values we obtained in fit_null in fact the two values are a bit farther apart than i m comfortable with but would undoubtedly converge if we were to increase levs we should do this with some caution though because it very substantially is going to increase our run time finally we can fit our discrete character dependent multi theta ou model fit_mou fitmultiou phy x y model er levs 20 parallel true ncores 10 root mle trace 1 maxit 2000 iter the a the b the c alpha sigsq q 1 log l 0 0 3575 0 3680 1 8215 0 2403 0 0115 0 2066 309 6850 100 0 3023 1 0148 1 6594 0 2779 0 0615 0 1947 284 8126 200 0 2191 1 1288 1 9057 0 2837 0 0611 0 1861 284 1910 300 0 2140 1 1372 1 9328 0 2794 0 0554 0 1914 284 0423 400 0 2355 1 1808 1 9946 0 2713 0 0499 0 1976 283 9893 500 0 2229 1 1901 2 0192 0 2716 0 0514 0 2043 283 9538 600 0 2202 1 2210 1 9799 0 2748 0 0519 0 2054 283 9183 700 0 2172 1 2083 1 9723 0 2747 0 0528 0 2056 283 9137 800 0 2164 1 2088 1 9738 0 2751 0 0528 0 2053 283 9135 900 0 2156 1 2094 1 9724 0 2753 0 0527 0 2052 283 9134 913 0 2157 1 2097 1 9725 0 2752 0 0527 0 2053 283 9134 done optimizing just because i know that optimization of this model is difficult i m a bit suspicious we may not have converged on the true mle let s try again but with sensible starting values for all our different model parameters init setnames c mean x y levels y 1 mean x y levels y 2 mean x y levels y 3 log 2 max nodeheights phy var x max nodeheights phy fitmk phy y model er rates c theta a theta b theta c alpha sigsq q 1 init theta a theta b theta c alpha sigsq q 1 0 23239962 0 64856597 0 93721136 0 06931472 0 04357107 0 25558924 fit_mou fitmultiou phy x y model er levs 100 parallel true ncores 10 root mle trace 1 maxit 2000 init init iter the a the b the c alpha sigsq q 1 log l 0 0 2324 0 6486 0 9372 0 0693 0 0436 0 2556 315 4681 100 0 5480 0 6211 2 3112 0 1711 0 0816 0 1765 270 5138 200 0 9475 0 9025 2 0608 0 1907 0 0725 0 2221 268 0952 300 0 8971 0 7990 2 0222 0 1960 0 0707 0 2176 267 9648 400 0 8941 0 8285 2 0684 0 1935 0 0701 0 2202 267 9573 500 0 8831 0 8318 2 0694 0 1936 0 0707 0 2166 267 9496 600 0 8828 0 8724 2 0711 0 1903 0 0708 0 2171 267 9394 700 0 8728 0 8737 2 0625 0 1894 0 0710 0 2152 267 9342 800 0 8513 0 8355 1 9719 0 2003 0 0724 0 2116 267 9037 900 0 8589 0 8295 1 9641 0 2014 0 0720 0 2139 267 9002 1000 0 8613 0 8330 1 9623 0 2014 0 0719 0 2149 267 8995 1100 0 8608 0 8220 1 9628 0 2017 0 0713 0 2154 267 8972 1200 0 8600 0 8276 1 9672 0 2008 0 0712 0 2156 267 8957 1300 0 8269 1 0429 2 0894 0 1860 0 0700 0 2134 267 8096 1400 0 8193 1 0484 2 1319 0 1836 0 0691 0 2161 267 7998 1500 0 8143 1 0503 2 1171 0 1844 0 0696 0 2132 267 7953 1600 0 7951 1 0509 2 1326 0 1842 0 0690 0 2107 267 7829 1700 0 7939 1 0513 2 1340 0 1851 0 0689 0 2095 267 7812 1723 0 7939 1 0513 2 1335 0 1852 0 0689 0 2094 267 7812 done optimizing fit_mou object of class fitmultiou based on a discretization with k 100 levels fitted multi theta ou model parameters levels a b c theta 0 7939 1 0513 2 1335 alpha 0 1852 sigsq 0 0689 estimated q matrix a b c a 0 4188483 0 2094242 0 2094242 b 0 2094242 0 4188483 0 2094242 c 0 2094242 0 2094242 0 4188483 log likelihood 267 7812 r thinks it has found the ml solution here it seems that we ve definitely done much better remember the generating values of theta were as follows theta a b c 0 5 1 0 2 0 our estimates are remarkably close to the generating conditions of our simulation naturally we might be interested to know whether our discrete character dependent model better explains our continuous trait data than the independent null model this comparison is very easy anova fit_null fit_mou log l d f aic weight fit_null 287 0493 4 582 0985 3 166496e 08 fit_mou 267 7812 6 547 5624 1 000000e 00 this tells us that basically all of the weight of evidence falls on our discrete character dependent multi regime ou model compared to the null model that s all there is to it preliminary but very cool posted by liam revell at 12 37 pm no comments email this blogthis share to x share to facebook share to pinterest saturday july 11 2026 null model for discrete character dependent multi θ ornstein uhlenbeck model in phytools a few weeks ago i posted about a discrete character dependent multi theta ornstein uhlenbeck model using the discrete diffusion approximation of boucher démery 2016 and our biorxiv pre print as in my prior post i recommend that those interested in the technical details of this general approach check out our pre print since that time i ve been corresponding with a colleague who has been trying to use the prototype fitmultiou function consequently i decided to write today s post demonstrating how we fit the null model of joint continuous trait ou discrete character m k evolution but without discrete character dependence using phytools i m going to illustrate i hope that we get the same to a reasonable extent of numerical precision parameter estimates likelihood as we would obtain from geiger fitcontinuous under a single theta ou model and phytools fitmk note that in a prior github update of phytools i was inadvertently trying to separately estimate theta and x_0 the root state but these are not identifiable under a single regime ou model so i have set them equal to one another in phytools geq 2 6 3 ok let s get started load phytools check package version library phytools should be phytools 2 6 3 packageversion phytools 1 2 6 3 for this demo i m going to simulate a pretty small tree this is because i m going to set levs 200 for estimation and this will take a while in practice we probably need larger trees to fit a multi regime ou model simulate tree n 60 phy pbtree n n scale 10 phy phylogenetic tree with 60 tips and 59 internal nodes tip labels t9 t10 t53 t54 t19 t49 rooted includes branch length s next let s specify a generating transition matrix of our discrete trait q set generating q matrix for discrete character q 0 2 q matrix c q q q q 2 2 dimnames list letters 1 2 letters 1 2 q a b ...
|