(* Mathematica Models

Home -- Symptoms -- Cycles -- Mathematica Program Used For Statistical Analysis


How to use this file with Mathematica:
(1) Download the source of this file (mathcode.htm) onto your hard drive.
(2) Open mathcode.htm with Mathematica. You will generate one notebook (cell).
(3) You have generated a Mathematica input file. Execute it.
(4) After running, Mathematica will generate several more plots than the sample pictures you see right now in this browser window.
(5) For convenience: At every horizontal ruler, you may break this one cell up into several subcells.

I hope newer versions of Mathematica will work with this file as does my Mathematica version 2.2.


Contents

  1. Program Used For Statistical Analysis
  2. Mathematica Code Representing Compartment Model

1. Mathematica Program Used For Statistical Analysis

*)
(**)
(*

Notation

*) (* daymax .......................number of days covered in symptom log. delta[[i]] .................... length of ith menstruation cycle. dist[s, ds, df] .............list containing the distp[s, i, ds, df] for all i. distp[s,i, ds, df] ....... list of expressions {s, distance(i)} where distance(i) is the time difference between the ith element of symp[s, ds, df] and any of the elements to the right of it. Example: distp[s,1, ds, df] ....... {{s, c - ds}, {s, d - ds}, ....., {s, df - ds}}, distp[s,2, ds, df] ....... {{s, d - c}, {s, e - c}, ....., {s, df - c}}. df ................................ last day of symptom log to be considered in statistical evaluation. ds ................................first day of symptom log to be considered in statistical evaluation. dmensis ......................vector composed of days 1 of all menstruation cycles. eall[s] ........................ {{s, 1}, {s, 2}, ..., {s, daymax}}. freq[s, ds, df, i] ........ tells us how often the time distance i between occurences of symptom s is found in the symptom log between days ds and df. freqv[s, ds, df].......... is the vector specifying the frequency spectrum of symptom s. It is composed of expressions {freq[s, ds, df, i], i}. m ............................... id of menstruation cycle. r ............................... = {0, fmax} specifies the range of frequencies that will be plotted. mend .......................... = {{30, start of bleeding (day)}, {30, start of bleeding (day)}, ... }. menses ....................... {{30, length of cycle 1}, {30, length of cycle 2}, .........}. mendI[i] .................... part i of menses. mplot[s, ds] .............. Plot of days of occurrence of symptom s. Days are grouped by menstruation cycles. pluteal ........................ Plot of location of luteal phase in menstrual cycle. s ................................. symptom id. Sfreqv[sv, ds, df] .......is the frequency spectrum of the symptom spectrum sv. Sfreqv is identical to freqv when sv = {s} specifies only one symptom, Spstat[sv, ds, df, r] .... procedure that plots the frequency plot for any array of symptoms Spstatv[sv, ds, df, r]... procedure that plots the frequency plot for any array of symptoms, using thick lines in the plot. sv ................................ vector composed of symptom id's. sv = {i, j, ...., n}, where i, j, ...., n represent the symtom log entries symt[i], symt[j], ...., symt[n]. That part of the symptom log is evaluated that starts with day ds and ends with day df. symp[s, ds, df] .......... subset of symt[s], i.e. symp[s, ds, df] = {{s, c}, {s, d}, ...., {s, y}} with ds ¾ c < d ....< y ¾ df. symM[m, s] ............... subset of symt[s] within one menstrual cycles, i.e. symM[m, s] = {{s, c-dmensis[[m]]}, {s, d-dmensis[[m]]}, ...., {s, y-dmensis[[m]]}} with dmensis[[m]] ¾ c < d ....< y < dmensis[[m + 1]]. symt[s] ...................... {{s, a}, {s, b}, ....., {s, ds}, {s, c}, {s, d}, {s, e}, {s, f}, ...., {s, df}, ....{s, z}}, where s is symptom id and a, b, ..., z are the days on which symptom s occurred. Day 1 is August 18. symtc[s] ..................... Complement of symt[s]: gives the elements in eall[s] that are not in symt[s]. symtc[s]= {{s, d1}, {s, d2}, ..., {s, dn}}, where d1, d2, ..., dn are all symptom free days. *) (*
*) (*
*) (*

Data

Symptom Log

*) daymax = 612; (*
*) (*Headache
*) symt[1] = {{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 11}, {1, 12}, {1, 13}, {1, 14}, {1, 72}, {1, 81}, {1, 82}, {1, 88}, {1, 91}, {1, 92}, {1, 99}, {1, 108}, {1, 115}, {1, 116}, {1, 126}, {1, 154}, {1, 166}, {1, 217}, {1, 243}, {1, 284}, {1, 289}, {1, 293}, {1, 331}, {1, 335}, {1, 336}, {1, 341}, {1, 343}, {1, 384} , {1, 405}, {1, 454}, {1, 463}, {1, 523}, {1, 549}, {1, 557}, {1, 558}, {1, 576} , {1, 588}, {1, 593}, {1, 600}}; (*Physical exhaustion
*) symt[2] = {{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 99}, {2, 150}, {2, 174}, {2, 176}, {2, 326} , {2, 327}, {2, 328}, {2, 329}, {2, 333}, {2, 453}}; (*Sinus symptoms
*) symt[3] = {{3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8}, {3, 9}, {3, 10}}; (*Eye pain
*) symt[4] = {{4, 1}, {4, 70}, {4, 89}, {4, 331}, {4, 332}, {4, 333}, {4, 335}, {4, 336}, {4, 344}, {4, 349}, {4, 374}, {4, 494}, {4, 451}, {4, 452}, {4, 459}, {4, 467}, {4, 480} , {4, 481}, {4, 486}, {4, 490}, {4, 509}, {4, 539}, {4, 540}, {4, 543}, {4, 551}, {4, 554} , {4, 555}, {4, 596}, {4, 597}, {4, 599}, {4, 600}, {4, 602}, {4, 610}}; (*Eyes: Pain when moving right eyeball
*) symt[5] = {{5, 2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {5, 7}, {5, 8}, {5, 9}, {5, 10}, {5, 75}, {5, 76}, {5, 77}, {5, 78}, {5, 79}, {5, 80}, {5, 81}}; (*Eyes: Reduced vision, left eye
*) symt[6] = {{6, 6}, {6, 7}, {6, 8}, {6, 9}, {6, 10}, {6, 11}}; (*Light-sensititivity
*) symt[7] = {{7, 1}, {7, 2}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {7, 7}, {7, 8}, {7, 9} , {7, 10}, {7, 11}, {7, 12}, {7, 13}, {7, 14}, {7, 23}, {7, 24}, {7, 25} , {7, 26}, {7, 27}, {7, 28}, {7, 29}, {7, 48}, {7, 49}, {7, 50}, {7, 51} , {7, 52}, {7, 53}, {7, 54}, {7, 55}, {7, 56}, {7, 65}, {7, 67}, {7, 73} , {7, 74}, {7, 75}, {7, 76}, {7, 77}, {7, 78}, {7, 79}, {7, 80}, {7, 81} , {7, 82}, {7, 83}, {7, 84}, {7, 102}, {7, 103}, {7, 104}, {7, 105} , {7, 110}, {7, 114}, {7, 115}, {7, 116}, {7, 117} , {7, 121}, {7, 122}, {7, 125}, {7, 130}, {7, 131}, {7, 133}, {7, 137} , {7, 138}, {7, 140}, {7, 144}, {7, 145}, {7, 146}, {7, 147}, {7, 148} , {7, 149}, {7, 151}, {7, 153}, {7, 155}, {7, 160}, {7, 161}, {7, 162} , {7, 163}, {7, 165}, {7, 167}, {7, 172}, {7, 175}, {7, 176}, {7, 177} , {7, 180}, {7, 184}, {7, 185}, {7, 187}, {7, 188}, {7, 191}, {7, 193} , {7, 195}, {7, 196}, {7, 198}, {7, 199}, {7, 204}, {7, 205}, {7, 210} , {7, 214}, {7, 216}, {7, 217}, {7, 219}, {7, 220}, {7, 223}, {7, 227} , {7, 228}, {7, 230}, {7, 232}, {7, 234}, {7, 236}, {7, 238}, {7, 241} , {7, 243}, {7, 244}, {7, 246}, {7, 248}, {7, 250}, {7, 255}, {7, 259} , {7, 263}, {7, 264}, {7, 268}, {7, 272}, {7, 277}, {7, 282}, {7, 284} , {7, 289}, {7, 297}, {7, 299}, {7, 304}, {7, 305}, {7, 306} , {7, 309}, {7, 319}, {7, 321}, {7, 323}, {7, 326}, {7, 328}, {7, 331} , {7, 332}, {7, 333}, {7, 335}, {7, 336}, {7, 343}, {7, 348}, {7, 352} , {7, 355}, {7, 357}, {7, 358}, {7, 360}, {7, 361}, {7, 363}, {7, 364} , {7, 376}, {7, 380}, {7, 383}, {7, 385}, {7, 388}, {7, 390}, {7, 396} , {7, 397}, {7, 400}, {7, 402}, {7, 403}, {7, 405}, {7, 408}, {7, 410} , {7, 412}, {7, 414}, {7, 426}, {7, 452}, {7, 486}, {7, 502}, {7, 599} , {7, 600}, {7, 601}, {7, 602}, {7, 603}, {7, 605}, {7, 607}}; (*Eyes: tingling, because 8 became indistinguishable from 7 after day 250 it is continued as symptom 7 then
*) symt[8] = {{8, 10}, {8, 11}, {8, 12}, {8, 13}, {8, 14}, {8, 53}, {8, 54}, {8, 55}, {8, 56}, {8, 65}, {8, 67}, {8, 73}, {8, 74}, {8, 75}, {8, 76}, {8, 77}, {8, 78}, {8, 79}, {8, 80}, {8, 81}, {8, 82}, {8, 83}, {8, 84}, {8, 103}, {8, 105}, {8, 110}, {8, 115}, {8, 116}, {8, 117}, {8, 122}, {8, 125}, {8, 130}, {8, 131}, {8, 133}, {8, 140}, {8, 145}, {8, 146}, {8, 147}, {8, 148}, {8, 149}, {8, 151}, {8, 153}, {8, 163}, {8, 172}, {8, 175}, {8, 176}, {8, 181}, {8, 187}, {8, 188}, {8, 193}, {8, 204}, {8, 205}, {8, 210}, {8, 219}, {8, 230}, {8, 238}, {8, 250}}; (*Eyes: asynchronous
*) symt[9] = {{9, 19}, {9, 20}, {9, 21}, {9, 22}, {9, 23}, {9, 24}, {9, 25}, {9, 26}, {9, 27}, {9, 28}, {9, 29}, {9, 30}, {9, 160}, {9, 232}, {9, 233}, {9, 244}, {9, 264}, {9, 274}, {9, 275}, {9, 278}}; (*Twitching muscles -face, eyelid, after day 239 continued in 11
*) symt[10] = {{10, 31}, {10, 75}, {10, 76}, {10, 115}, {10, 152}, {10, 171}, {10, 184}, {10, 185}, {10, 220}, {10, 221}, {10, 226}, {10, 228}, {10, 229}, {10, 234}, {10, 239}}; (*Twitching muscles - small leg muscles
*) symt[11] = {{11, 30}, {11, 31}, {11, 75}, {11, 76}, {11, 115}, {11, 116} , {11, 138}, {11, 139}, {11, 140}, {11, 141}, {11, 143}, {11, 144}, {11, 149} , {11, 152}, {11, 162}, {11, 163}, {11, 164}, {11, 165}, {11, 166}, {11, 168} , {11, 170}, {11, 171}, {11, 172}, {11, 173}, {11, 175}, {11, 177}, {11, 183} , {11, 184}, {11, 185}, {11, 187}, {11, 199}, {11, 201}, {11, 205}, {11, 206} , {11, 207}, {11, 220}, {11, 221}, {11, 226}, {11, 228}, {11, 229}, {11, 234} , {11, 239}, {11, 241}, {11, 275}, {11, 276} , {11, 286}, {11, 287}, {11, 289}, {11, 291}, {11, 292}, {11, 293}, {11, 294} , {11, 297}, {11, 298}, {11, 300}, {11, 301}, {11, 306}, {11, 307}, {11, 310} , {11, 315}, {11, 320}, {11, 325}, {11, 327}, {11, 331}, {11, 332}, {11, 333} , {11, 334}, {11, 337}, {11, 338}, {11, 342}, {11, 343}, {11, 345}, {11, 346} , {11, 349}, {11, 350}, {11, 351}, {11, 360}, {11, 361}, {11, 362}, {11, 363} , {11, 366}, {11, 367}, {11, 372}, {11, 380}, {11, 381}, {11, 384}, {11, 386} , {11, 387}, {11, 389}, {11, 390}, {11, 391}, {11, 392}, {11, 393}, {11, 394} , {11, 398}, {11, 399}, {11, 401}, {11, 402}, {11, 403}, {11, 404}, {11, 408} , {11, 411}, {11, 412}, {11, 414}, {11, 415}, {11, 419}, {11, 420}, {11, 422} , {11, 423}, {11, 424}, {11, 426}, {11, 427}, {11, 428}, {11, 429}, {11, 430} , {11, 431}, {11, 432}, {11, 433}, {11, 434}, {11, 435}, {11, 436}, {11, 437} , {11, 438}, {11, 439}, {11, 440}, {11, 441}, {11, 442}, {11, 443}, {11, 444} , {11, 445}, {11, 446}, {11, 452}, {11, 454}, {11, 455}, {11, 456}, {11, 457} , {11, 458}, {11, 459}, {11, 460}, {11, 461}, {11, 462}, {11, 463}, {11, 464} , {11, 465}, {11, 466}, {11, 467}, {11, 468}, {11, 469}, {11, 471}, {11, 472} , {11, 473}, {11, 474}, {11, 475}, {11, 476}, {11, 477}, {11, 478}, {11, 479} , {11, 480}, {11, 481}, {11, 482}, {11, 484}, {11, 485}, {11, 486}, {11, 487} , {11, 488}, {11, 489}, {11, 490}, {11, 493}, {11, 494}, {11, 495}, {11, 497} , {11, 498}, {11, 502}, {11, 503}, {11, 504}, {11, 505}, {11, 506}, {11, 507} , {11, 508}, {11, 509}, {11, 510}, {11, 511}, {11, 513}, {11, 517}, {11, 519} , {11, 522}, {11, 526}, {11, 529}, {11, 530}, {11, 531}, {11, 532}, {11, 534} , {11, 535}, {11, 536}, {11, 537}, {11, 538}, {11, 540}, {11, 541}, {11, 542} , {11, 543}, {11, 547}, {11, 550}, {11, 566}, {11, 567}, {11, 568}, {11, 569} , {11, 570}, {11, 573}, {11, 587}, {11, 588}, {11, 589}, {11, 598}, {11, 600} , {11, 601}, {11, 605}, {11, 606}, {11, 607}, {11, 608}}; (*Brain: foggy, slow
*) symt[12] = {{12, 30}, {12, 31}, {12, 34}, {12, 35}, {12, 36}, {12, 37}, {12, 38}, {12, 39}, {12, 40}, {12, 41}, {12, 42}, {12, 43}, {12, 44}, {12, 60}, {12, 61}, {12, 62}, {12, 63}, {12, 64}, {12, 65}, {12, 66}, {12, 67}, {12, 68}, {12, 69}, {12, 70}, {12, 71}, {12, 72}, {12, 73}, {12, 74}, {12, 75}, {12, 76}, {12, 77}, {12, 78}, {12, 79}, {12, 80}, {12, 81}, {12, 85}, {12, 89}, {12, 90}, {12, 91}, {12, 92}, {12, 95}, {12, 96}, {12, 97}, {12, 98}, {12, 99}, {12, 108}, {12, 125}, {12, 126}, {12, 127}, {12, 132}, {12, 274}, {12, 275}, {12, 278}, {12, 285}, {12, 331}, {12, 378} , {12, 414}, {12, 415}, {12, 423}}; (*Lightheadedness
*) symt[13] = {{13, 34}, {13, 35}, {13, 36}, {13, 37}, {13, 38}, {13, 39}, {13, 40} , {13, 41}, {13, 42}, {13, 43}, {13, 44}, {13, 61}, {13, 62}, {13, 63}, {13, 64} , {13, 65}, {13, 91}, {13, 92}, {13, 95}, {13, 96}, {13, 97}, {13, 98}, {13, 100} , {13, 102}, {13, 104}, {13, 107}, {13, 108}, {13, 110}, {13, 111}, {13, 115} , {13, 120}, {13, 122}, {13, 134}, {13, 150}, {13, 167}, {13, 183}, {13, 187} , {13, 188}, {13, 189}, {13, 190}, {13, 192}, {13, 193}, {13, 234}, {13, 235} , {13, 255}, {13, 259}, {13, 260}, {13, 261}, {13, 262}, {13, 263}, {13, 264} , {13, 266}, {13, 272}, {13, 273}, {13, 274}, {13, 275}, {13, 277}, {13, 278} , {13, 279}, {13, 280}, {13, 281}, {13, 282}, {13, 283}, {13, 284}, {13, 285} , {13, 286}, {13, 287}, {13, 288}, {13, 289}, {13, 290}, {13, 291}, {13, 294} , {13, 295}, {13, 296}, {13, 297}, {13, 298}, {13, 299}, {13, 356}, {13, 375} , {13, 376}, {13, 453}, {13, 463}, {13, 464}, {13, 468}, {13, 471}, {13, 472} , {13, 486}, {13, 502}, {13, 503}, {13, 504}, {13, 506}, {13, 518}, {13, 529} , {13, 532}, {13, 551}, {13, 552}, {13, 553}, {13, 554}, {13, 556}, {13, 557} , {13, 560}, {13, 561}, {13, 566}}; (*Neck: Stiffness
*) symt[14] = {{14, 30}, {14, 31}, {14, 32}, {14, 33}, {14, 80}, {14, 81}, {14, 96}, {14, 108}, {14, 282}}; (*Body, legs, feet , hand, or face: tingling, see also #28
*) symt[15] = {{15, 37}, {15, 38}, {15, 43}, {15, 54}, {15, 70}, {15, 76}, {15, 77} , {15, 78}, {15, 88}, {15, 89}, {15, 92}, {15, 96}, {15, 98}, {15, 106}, {15, 107} , {15, 115}, {15, 118}, {15, 125}, {15, 129}, {15, 136}, {15, 141}, {15, 142} , {15, 143}, {15, 144}, {15, 151}, {15, 152}, {15, 172}, {15, 177}, {15, 179} , {15, 188}, {15, 191}, {15, 192}, {15, 193}, {15, 197}, {15, 203}, {15, 207} , {15, 208}, {15, 213}, {15, 215}, {15, 226}, {15, 227}, {15, 229}, {15, 232} , {15, 233}, {15, 239}, {15, 241}, {15, 257}, {15, 258}, {15, 260}, {15, 262} , {15, 282}, {15, 283}, {15, 287}, {15, 288}, {15, 290}, {15, 295}, {15, 296} , {15, 303}, {15, 305}, {15, 320}, {15, 331}, {15, 333}, {15, 334}, {15, 339} , {15, 341}, {15, 343}, {15, 344}, {15, 345}, {15, 350}, {15, 351}, {15, 352} , {15, 354}, {15, 355}, {15, 357}, {15, 367}, {15, 369}, {15, 376}, {15, 377} , {15, 378}, {15, 385}, {15, 386}, {15, 388}, {15, 389}, {15, 404}, {15, 410} , {15, 411}, {15, 412}, {15, 413}, {15, 415}, {15, 425}, {15, 433}, {15, 434} , {15, 436}, {15, 441}, {15, 442}, {15, 453}, {15, 458}, {15, 461}, {15, 494} , {15, 495}, {15, 502}, {15, 505}, {15, 507}, {15, 508}, {15, 512}, {15, 513} , {15, 514}, {15, 515}, {15, 519}, {15, 530}, {15, 532}, {15, 537}, {15, 542} , {15, 551}, {15, 555}, {15, 565}, {15, 596}, {15, 612}}; (*Ears: pain or buzz
*) symt[16] = {{16, 48}, {16, 49}, {16, 82}, {16, 83}, {16, 95}, {16, 108}, {16, 118}, {16, 127}, {16, 165}, {16, 171}, {16, 178}, {16, 269}, {16, 270}, {16, 271} , {16, 273}, {16, 277}, {16, 278}, {16, 279}, {16, 280}, {16, 281}, {16, 282}, {16, 283}, {16, 285}, {16, 288} , {16, 289}, {16, 292}, {16, 297}, {16, 298}, {16, 300}, {16, 302}, {16, 305}, {16, 306}, {16, 307}, {16, 314}, {16, 331}, {16, 333}, {16, 352}, {16, 354} , {16, 355}, {16, 358}, {16, 361}, {16, 363}, {16, 364}, {16, 373}, {16, 374}, {16, 376} , {16, 389}, {16, 396}, {16, 398}, {16, 400}, {16, 405}, {16, 415}, {16, 419} , {16, 423}, {16, 463}, {16, 502}}; (*Head:stabbing pain in back of head
*) symt[17] = {{17, 71}, {17, 72}, {17, 83}, {17, 87}, {17, 89}, {17, 90}, {17, 91} , {17, 92}, {17, 93}, {17, 94}, {17, 99}, {17, 100}, {17, 104}, {17, 109} , {17, 112}, {17, 115}, {17, 116}, {17, 120}, {17, 127}, {17, 132}, {17, 133} , {17, 135}, {17, 152}, {17, 170}, {17, 171}, {17, 177}, {17, 179}, {17, 181} , {17, 183}, {17, 188}, {17, 189}, {17, 190}, {17, 192}, {17, 208}, {17, 226} , {17, 229}, {17, 231}, {17, 232}, {17, 234}, {17, 239}, {17, 243}, {17, 245} , {17, 250}, {17, 251}, {17, 252}, {17, 254}, {17, 255}, {17, 259}, {17, 260} , {17, 263}, {17, 264}, {17, 265}, {17, 266}, {17, 269}, {17, 271}, {17, 273} , {17, 274}, {17, 275}, {17, 276}, {17, 277}, {17, 278}, {17, 280}, {17, 282} , {17, 283}, {17, 284}, {17, 285}, {17, 286}, {17, 287}, {17, 289}, {17, 291} , {17, 292}, {17, 298}, {17, 306}, {17, 307}, {17, 319}, {17, 321}, {17, 322} , {17, 324}, {17, 326}, {17, 338}, {17, 339}, {17, 344}, {17, 350}, {17, 351} , {17, 352}, {17, 353}, {17, 355}, {17, 357}, {17, 365}, {17, 368}, {17, 370} , {17, 371}, {17, 374}, {17, 375}, {17, 376}, {17, 377}, {17, 387} , {17, 395}, {17, 401}, {17, 404}, {17, 412}, {17, 413}, {17, 414}, {17, 415} , {17, 416}, {17, 417}, {17, 418}, {17, 421}, {17, 425}, {17, 429}, {17, 431} , {17, 463}, {17, 481}, {17, 488}, {17, 502}, {17, 504}, {17, 506}, {17, 507} , {17, 512}, {17, 513}, {17, 515}, {17, 516}, {17, 517}, {17, 518}}; (*Head: pain in back of head
*) symt[18] = {{18, 94}, {18, 101}, {18, 108}, {18, 118}, {18, 119}, {18, 124}, {18, 125} , {18, 133}, {18, 150}, {18, 154}, {18, 159}, {18, 163}, {18, 164}, {18, 167} , {18, 168}, {18, 169}, {18, 170}, {18, 174}, {18, 179}, {18, 184}, {18, 188} , {18, 190}, {18, 195}, {18, 197}, {18, 203}, {18, 207}, {18, 208}, {18, 211} , {18, 213}, {18, 215}, {18, 217}, {18, 221}, {18, 227}, {18, 228}, {18, 229} , {18, 230}, {18, 242}, {18, 244}, {18, 246}, {18, 247}, {18, 248}, {18, 250} , {18, 251}, {18, 253}, {18, 255}, {18, 257}, {18, 258}, {18, 259}, {18, 261} , {18, 263}, {18, 264}, {18, 265}, {18, 266}, {18, 267}, {18, 268}, {18, 269} , {18, 270}, {18, 274}, {18, 275}, {18, 277}, {18, 278}, {18, 279}, {18, 280} , {18, 282}, {18, 283}, {18, 284}, {18, 285}, {18, 286}, {18, 287}, {18, 288} , {18, 289}, {18, 291}, {18, 292}, {18, 294}, {18, 295}, {18, 296}, {18, 298} , {18, 300}, {18, 301}, {18, 304}, {18, 305}, {18, 306}, {18, 308}, {18, 309} , {18, 310}, {18, 311}, {18, 312}, {18, 314}, {18, 316}, {18, 317}, {18, 318} , {18, 319}, {18, 324}, {18, 328}, {18, 329}, {18, 331}, {18, 333}, {18, 334} , {18, 336}, {18, 337}, {18, 338}, {18, 339}, {18, 341}, {18, 343}, {18, 345} , {18, 346}, {18, 347}, {18, 348}, {18, 350}, {18, 352}, {18, 354}, {18, 355} , {18, 356}, {18, 357}, {18, 358}, {18, 359}, {18, 360}, {18, 362}, {18, 363} , {18, 367}, {18, 368}, {18, 369}, {18, 370}, {18, 371}, {18, 372}, {18, 375} , {18, 376}, {18, 378}, {18, 380}, {18, 381}, {18, 383}, {18, 387}, {18, 388} , {18, 389}, {18, 390}, {18, 393}, {18, 398}, {18, 402}, {18, 403}, {18, 404} , {18, 405}, {18, 407}, {18, 408}, {18, 410}, {18, 411}, {18, 415}, {18, 420} , {18, 423}, {18, 424}, {18, 427}, {18, 429}, {18, 431}, {18, 433}, {18, 435} , {18, 436}, {18, 437}, {18, 438}, {18, 439}, {18, 440}, {18, 441}, {18, 443} , {18, 445}, {18, 447}, {18, 448}, {18, 449}, {18, 450}, {18, 453}, {18, 456} , {18, 457}, {18, 458}, {18, 463}, {18, 464}, {18, 467}, {18, 468}, {18, 469} , {18, 475}, {18, 479}, {18, 482}, {18, 483}, {18, 484}, {18, 487}, {18, 497} , {18, 498}, {18, 499}, {18, 502}, {18, 504}, {18, 505}, {18, 506}, {18, 507} , {18, 508}, {18, 509}, {18, 512}, {18, 513}, {18, 515}, {18, 516}, {18, 517} , {18, 518}, {18, 519}, {18, 520}, {18, 521}, {18, 522}, {18, 524}, {18, 526} , {18, 527}, {18, 529}, {18, 530}, {18, 531}, {18, 534}, {18, 537}, {18, 538} , {18, 539}, {18, 541}, {18, 543}, {18, 544}, {18, 545}, {18, 548}, {18, 549} , {18, 551}, {18, 552}, {18, 553}, {18, 554}, {18, 555}, {18, 557}, {18, 559} , {18, 560}, {18, 561}, {18, 563}, {18, 565}, {18, 566}, {18, 567}, {18, 569} , {18, 570}, {18, 571}, {18, 572}, {18, 573}, {18, 574}, {18, 576}, {18, 580} , {18, 582}, {18, 583}, {18, 584}, {18, 586}, {18, 588}, {18, 589}, {18, 590} , {18, 592}, {18, 593}, {18, 594}, {18, 599}, {18, 600}, {18, 601}, {18, 602} , {18, 603}, {18, 604}, {18, 605}, {18, 606}, {18, 607}, {18, 608}, {18, 609} , {18, 610}, {18, 612}}; (*Tension, anxiety
*) symt[19] = {{19, 31}, {19, 32}, {19, 33}, {19, 34}, {19, 35}, {19, 36}, {19, 37}, {19, 38}, {19, 39}, {19, 40}, {19, 41}, {19, 42}, {19, 43}, {19, 44}, {19, 45}, {19, 46}, {19, 47}, {19, 48}, {19, 49}, {19, 50}, {19, 51}, {19, 52}, {19, 53}, {19, 54}, {19, 55}, {19, 56}, {19, 57}, {19, 58}, {19, 59}, {19, 60}, {19, 61}, {19, 62}, {19, 63}, {19, 67}, {19, 68}, {19, 69}, {19, 76}, {19, 77}, {19, 78}, {19, 79}, {19, 80}, {19, 81}, {19, 106}, {19, 113}, {19, 114}, {19, 115}, {19, 116}}; (*Chest: Difficulty taking deep breath
*) symt[20] = {{20, 31}, {20, 32}, {20, 33}, {20, 34}, {20, 35}, {20, 36}, {20, 37}, {20, 38}, {20, 39}, {20, 40}, {20, 41}, {20, 42}, {20, 43}, {20, 44}, {20, 45}, {20, 46}, {20, 47}, {20, 48}, {20, 49}, {20, 50}, {20, 51}, {20, 52}, {20, 53}, {20, 54}, {20, 55}, {20, 56}, {20, 57}, {20, 58}, {20, 59}, {20, 60}, {20, 61}, {20, 62}, {20, 63}, {20, 76}, {20, 77}, {20, 78}, {20, 79}, {20, 80}, {20, 81}, {20, 82}, {20, 83}, {20, 84}, {20, 85}, {20, 86}, {20, 87}, {20, 88}, {20, 89}, {20, 90}, {20, 166}, {20, 167}, {20, 179}, {20, 183}, {20, 193}, {20, 199}, {20, 203}, {20, 213}, {20, 232}, {20, 246}, {20, 247}, {20, 257}, {20, 278}, {20, 280}, {20, 281} , {20, 466}, {20, 517}, {20, 518}}; (*Sore throat
*) symt[21] = {{21, 43}, {21, 44}, {21, 45}, {21, 46}, {21, 47}, {21, 48}, {21, 56}, {21, 57}, {21, 58}, {21, 59}, {21, 60}, {21, 61}, {21, 62}, {21, 63}, {21, 64}, {21, 65}, {21, 85}, {21, 88}, {21, 109}, {21, 110}, {21, 111}, {21, 112}, {21, 114}, {21, 115}, {21, 159}, {21, 187}}; (*Persisten cough
*) symt[22] = {{22, 84}, {22, 85}, {22, 86}, {22, 87}, {22, 88}, {22, 89}, {22, 90}, {22, 91}, {22, 92}, {22, 93}, {22, 94}, {22, 95}, {22, 96}, {22, 97}, {22, 98}, {22, 99}, {22, 100}, {22, 101}, {22, 102}, {22, 103}}; (*Swollen glands
*) symt[23] = {{23, 85}, {23, 86}, {23, 109}, {23, 110}, {23, 113}, {23, 114}, {23, 115}, {23, 116}, {23, 117}}; (*Body: stabbing pain
*) symt[24] = {{24, 86}, {24, 90}, {24, 91}, {24, 92}, {24, 99}, {24, 200}, {24, 282}, {24, 283}, {24, 287}, {24, 293}, {24, 296}, {24, 331}, {24, 333}, {24, 362}}; (*Fever, chills
*) symt[25] = {{25, 108}, {25, 111}, {25, 112}, {25, 113}, {25, 114}}; (*Rash: very strong - entire body
*) symt[26] = {{26, 113}, {26, 114}, {26, 115}}; (*swollen joints
*) symt[27] = {{27, 114}, {27, 115}, {27, 116}}; (*Upper leg - Tingling when moving
*) symt[28] = {{28, 190}, {28, 191}, {28, 192}, {28, 193}, {28, 194}, {28, 195}, {28, 196}, {28, 197}, {28, 198}, {28, 199}, {28, 200}, {28, 201}, {28, 202}, {28, 203}, {28, 204}, {28, 205}, {28, 206}, {28, 208}, {28, 209}, {28, 218}, {28, 219}, {28, 235}, {28, 246}, {28, 248}}; (*Muscles - weak
*) symt[29] = {{29, 158}, {29, 159}, {29, 160}, {29, 171}, {29, 174}, {29, 175} , {29, 177}, {29, 179}, {29, 196}, {29, 197}, {29, 229}, {29, 230}, {29, 231} , {29, 232}, {29, 238}, {29, 251}, {29, 252}, {29, 257}, {29, 258}, {29, 262} , {29, 267}, {29, 270}, {29, 271}, {29, 272}, {29, 274}, {29, 276}, {29, 278} , {29, 281}, {29, 289}, {29, 292}, {29, 296}, {29, 298}, {29, 302}, {29, 306} , {29, 307}, {29, 311}, {29, 318}, {29, 319}, {29, 323}, {29, 330}, {29, 344} , {29, 346}, {29, 348}, {29, 351}, {29, 354}, {29, 355}, {29, 367}, {29, 376} , {29, 393}, {29, 395}, {29, 400}, {29, 401}, {29, 403}, {29, 406}, {29, 409} , {29, 441}, {29, 442}, {29, 446}, {29, 491}, {29, 502}, {29, 504}, {29, 506}}; (*Menses
*) symt[30] = {{30, 92}, {30, 114}, {30, 139}, {30, 162}, {30, 234}, {30, 258}, {30, 283}, {30, 308}, {30, 331}, {30, 356}, {30, 377}, {30, 401}, {30, 424} , {30, 448}, {30, 470}, {30, 495}, {30, 519}, {30, 550}, {30, 574}, {30, 593}, {30, daymax}}; (*
*) (*

Menstruation Cycles

*) mend = {{30, -2}, {30, 92- (2 24 + 23)}, {30, 92 - (24 + 23)}, {30, 92- 24}, {30, 92}, {30, 114}, {30, 139}, {30, 162}, {30, 186}, {30, 210}, {30, 234}, {30, 258}, {30, 283}, {30, 308}, {30, 331}, {30, 356}, {30, 377}, {30, 401}, {30, 424}, {30, 448}, {30, 470}, {30, 495}, {30, 519}, {30, 550}, {30, 574}, {30, 593}, {30, daymax}}; menp = Show[Table[Graphics[Text["M", mend[[i]]]], {i, Count[mend, {_, _}]}]]; (*
*) (*

Defintions

*) (*
*) (*

Menstruation Cycles

*) (*
*) (*

Group occurrence of each symptom with its corresponding menstruation cycle

*) dmensis = Table[mend[[i, 2]], {i, Length[mend] }]; Clear[mendI]; mendI[i_] := {30, mend[[i+1, 2]] - mend[[i, 2]]}; menses = Table[mendI[i], {i, Length[mend] - 1}]; delta = Table[menses[[i, 2]], {i, Length[mend] - 1}];(*vector of menstr. cycle lengths*) Clear[symM]; symM[m_, s_] := ( kk = 0; iis = 0; For[i = 1, i<= Length[symt[s]], i++, If[symt[s][[i, 2]] >= dmensis[[m]], If[symt[s][[i, 2]] < dmensis[[m+1]], kk = i, Break[] ], iis = i] ]; symM[m, s] = Table[{m, symt[s][[i, 2]] - dmensis[[m]]}, {i, iis+1, kk}] ); (*
*) (*

Plot Luteal Phase

*) pluteal = Show[ ListPlot[delta, PlotRange->{{0, Count[mend, {_,_}] }, {0, Max[delta] + 1}}, PlotJoined->True, Frame->True], ListPlot[delta - 16, PlotRange->{{0, Count[mend, {_,_}] }, {0, Max[delta] + 1}}, PlotJoined->True, Frame->True], ListPlot[delta - 12, PlotRange->{{0, Count[mend, {_,_}] }, {0, Max[delta] + 1}}, PlotJoined->True, Frame->True]]; (*
*) (*Sample Calculation: Log of Symptoms divided into 26 Menstrual Cycles*) (*For figure caption see Fig. VIII.3.2 in Lyme Disease: Statistical Evaluation ...*) (*

Subset of symt[s] Within Period ds ... df

*) Clear[symp]; symp[s_, ds_, df_] := ( k = 0; is = 0; For[i = 1, i<= Count[symt[s],{_, _}], i++, If[symt[s][[i, 2]] >= ds, If[symt[s][[i, 2]] <= df, k = i, Break[] ], is = i ] ]; symp[s, ds, df] = Table[symt[s][[i]], {i, is+ 1, k}] ); (*
*) (*

Distances Between Days With Symptom Occurrence

*) Clear[dist,distp]; distp[s_, i_, ds_, df_] := distp[s, i, ds, df] = Table[{s, symp[s, ds, df][[i+j,2]] - symp[s, ds, df][[i,2]]},{j, Count[symp[s, ds, df], {_, _}]-i}]; dist[s_, ds_, df_] := dist[s, ds, df] = Table[distp[s,k, ds, df],{k, Count[symp[s, ds, df],{_, _}]-1}]; (*
*) (*

Frequency Distribution of Distances

*) Clear[freq, freqv, Vfreqv, Sfreq, pstat, Spstat]; freq[s_, ds_, df_, i_] := freq[s, ds, df, i] = Count[Flatten[dist[s, ds, df],1],{_,i}]; freqv[s_, ds_, df_] := Table[freq[s, ds,df, i], {i, df-ds}]; Vfreqv[sv_, ds_, df_] := Table[freqv[sv[[i]], ds, df], {i, Length[sv]}]; Sfreq[sv_, ds_, df_] := Sum[Vfreqv[sv, ds, df][[j]], {j, Length[sv]}]; (*
*) (*

Plot of Frequency Distributions

*) Clear[pstat, Spstat, Spstatv]; pstat[s_, ds_, df_, r_] := ( nmax = Ceiling[(df - ds)/28]; (*dmax = Max[Table[Count[Flatten[dist[s, ds, df], 1], {_, i}], {i, df - ds}]];*) lpd[r] = ListPlot[Table[{i, freq[s, ds, df, i]},{i, df - ds}], PlotJoined->True, PlotRange->{{0, df - ds}, r}, GridLines->{Table[n 28 + 1, {n, 0, nmax}], None}, Frame->True, PlotLabel->FontForm[{"Symp.", s, "Days ->", ds, df}, {"Helvetica-Bold", 14}]] ); Spstat[sv_, ds_, df_, r_] := ( nmax = Ceiling[(df - ds)/28]; (*dmax = Max[Table[Count[Flatten[dist[s, ds, df], 1], {_, i}], {i, df - ds}]];*) Slpd[r] = ListPlot[Sfreq[sv, ds, df], PlotJoined->True, PlotRange->{{0, df - ds}, r}, GridLines->{Table[n 28 + 1, {n, 0, nmax}], None}, Frame->True, PlotLabel->FontForm[{(*"Sym", *)sv(*, "Days", ds, df*)}, {"Helvetica", 10}]]; ); Spstatv[sv_, ds_, df_, r_] := ( nmax = Ceiling[(df - ds)/28]; (*dmax = Max[Table[Count[Flatten[dist[s, ds, df], 1], {_, i}], {i, df - ds}]];*) Slpd[r] = ListPlot[Sfreq[sv, ds, df], (*PlotJoined->True,*) PlotRange->{{0, df - ds}, r}, GridLines->{Table[n 28 + 1, {n, 0, nmax}], None}, PlotStyle->Thickness[0.01], PlotJoined->True, Frame->True, PlotLabel->FontForm[{(*"Sym", *)sv(*, "Days", ds, df*)}, {"Helvetica", 10}]]; ); (*
*) (*

Plot Menses & Antibiotics Intake

*) pall = Plot[{(*9, 18,*) 99, 128 , 129, 159, 168, (*176, 182, 193, 203, 204, 211, 234, 248*)266, 373, 410, 414, 441, 451, 550}, {x, 0, 29}, PlotStyle->Dashing[{0.06, 0.01}], PlotRange->{{0, 30}, {0, daymax}}, GridLines->{None, Table[n 28, {n, Ceiling[daymax/28.]}]}, Frame->True]; pallM = Show[Table[Plot[dmensis[[i]], {x, 0, 30}, PlotRange->{{0, 30}, {0, daymax}}, Frame->True], {i, Count[mend, {_,_}]}], menp]; (*
*) (**) (*

2. Sample Calculation

*) (*

Symptom Log

*) Show[Table[ListPlot[symt[i]], {i, 30}], pall(*, pallM*), menp, PlotRange->{{0, 30}, {0, daymax+ 10}}, GridLines->{None, Table[n 28, {n, Ceiling[daymax/28.]}]}, Frame->True]; (*Sample Calculation: Symptom Log*) (*For figure caption see Fig. 1 in Lyme Disease: Statistical Evaluation ... *) (*
*) Spstat[{7}, 1, 98, {0, 30}] (*Sample Calculation: Frequency Distribution of Symptom #7*) (*For figure caption see Fig. 2 in Lyme Disease: Statistical Evaluation ...*) (**) (*
*) (*

2. Mathematica Code Representing
Immune System Compartment Model

*)
(**)
(*

Notation

eq .............................. set of equations describing 1-compartment system. eq[tb1,ta1,tb2,ta2] set of equations describing 2-compartment system. imp[tb, ta, t] ........... square pulse ending at tb + ta, starting at tb: imp[tb_, ta_, t_] := UnitStep[t - tb](1-UnitStep[t - tb+ta]). kBb[TBb, t] ............. Log[2]/TBb. kI[tb, ta, TI, t] ........ sqp[tb, ta, t] Log[2]/TI. r[t] ......................... source term in compartment system. sqp[tb, ta, t]...............succession of 4 square pulses imp[tb, ta, t], called f in figures. ta (ta1) ................... length of square pulse (number behind symbol specifies corresponding compartment in 2-compartment system: ta = 0: no oscillatory immune system). tb (tb1) ................... time of beginning of square pulse (number behind symbol specifies corresponding compartment in 2-compartment system: ta = 0: no oscillatory immune system). TBb .......................... Bb generation length (cell cycle length). TI ............................. removal half life of immune system. *) (*
*) (*
*) Needs["Calculus`DiracDelta`"]; (*
*) (*

Definitions

*) (**) (*

Definitions: Square pulse, kI, kBb and syml

*) Clear[imp, kBb, kI, sqp, syml]; imp[tb_, ta_, t_] := UnitStep[t - tb](1-UnitStep[t - (ta+tb)]); kI[tb_, ta_, TI_, t_] := sqp[tb, ta, t] Log[2]/TI; kBb[TBb_, t_] := Log[2]/TBb; sqp[tb_, ta_, t_] := imp[tb, ta, t] + imp[tb, ta, t - (ta+tb)] + imp[tb, ta, t - 2 (ta+tb)] + imp[tb, ta, t - 3 (ta+tb)] + imp[tb, ta, t - 4 (ta+tb)] + imp[tb, ta, t - 5 (ta+tb)] ; syml[s_, ds_, df_, to_, so_] := ( Map[Reverse, symp[s, ds, df]] + Table[{to, so}, {i, Count[symp[s, ds, df], {_, _}]}]); (*
*) (**) (*

Definitions: One-Compartment System

*) Clear[eq1]; eq1 = {C'[t] == (kBb[TBb, t] - kI[tb, ta, TI, t]) C[t], C[0] == 2}; (*
*) (*

Definitions: Two-Compartment System: System With Antibiotics

*) (**) Clear[eq2]; eq2[tb1_, ta1_, tb2_, ta2_] := { C1'[t] == r[t] - (kBb[TBb, t] + kI[tb1, ta1, TBbI, t]) C1[t], C2'[t] == kBb[TBb, t] C1[t] - kI[tb2, ta2, TFI, t] C2[t], C1[0] == 0, C2[0] == 0 }; (*
*) (**) (*

Sample Computations: One-Compartment System

*) TBb = 7; TI = 0.1 TBb; tb = 20; ta = 3; nsol1 = NDSolve[eq1, C, {t, 0, 4 (tb+ta)}]; Plot[ Log[10, Evaluate[C[t]] /.nsol1], {t, 0, 4 (tb+ta)}, PlotRange->{{0, 4 (tb+ta)}, {-1, 2}}, AxesOrigin->{0,0}, Frame->True, PlotStyle->Thickness[0.008] ]; (*Bb concentration (y-axis) vs. time (x-axis)*) (*
*) (**) (*

Sample Computations: Two-Compartment System

*) TBb = 5; TBbI = 0.1 TBb; TFI = 2 TBbI; Clear[r]; r[t_] := -2/100 t + 2; tb1 = 2.5 TBb; ta1 = 0.52 TBb; tb2 = 3 TBb; ta2 = 2 TBb; SetOptions[NDSolve, MaxSteps->2000]; nsol2 = NDSolve[eq2[tb1, ta1, tb2, ta2], {C1, C2}, {t, 10^-1, 100}] Show[ Plot[Log[10, C1[t]]/.nsol2, {t, 10^-4, 100}, PlotStyle->Dashing[{0.02, 0.01}]], Plot[Log[10, C2[t]]/.nsol2, {t, 10^-4, 100}, PlotStyle->Thickness[0.01]], PlotRange->{{0, 5(tb2+ta2)}, {-1, 2}}, Frame->True] (*Bb and fragment concentrations (y-axis) vs. time (x-axis)*) (*


version: March 15, 2005
Address of this page is http://www.lymenet.de/symptoms/cycles/mathcode.htm
Home of this Site is http://www.lymenet.de For comments and questions: Joachim Gruber
*)