Hi, Am I right in thinking that the best way to manage a dark-light cycle in Phoenix is to use the sleep option to turn the function on and off? For example lights go on at 6am, go off at 6pm (square wave function) during the light phase the function is fixed to 0 (sleep) during the dark phase the function is set to an estimatable parameter ‘d’ that affects other controls within the system. Does anyone have an example to get me started? Thanks Teresa
Dear Teresa You are right about the concept involved with sequence. When using the integrator, the first line of code will define the initial conditions at the beginning of the integration time (t=0) . For example, suppose you want to use an index that will shift from 1 to 0 depending on if it is dark or not. The index is called lightcycle. Since this index will change only when you stop the program, it must be define using the statement double. Therefore, you have double(lightcycle) Now you write the sequence statement , you open curly brackets at the beginning and close it at the end of the statement sequence { write lot of stuff } Now we start to tell the program about the initial conditions, how much time to run the program sleep statement, what to do after the program stops again and finally defining the cycle (while statement) first statement sets the initial value for lighcycle lightcycle = 1 ; you put ; before you write the next statement We are still at t=0 and we ask the program to run for 6 hours sleep(6); Now we define the cycle by using the while statement. While statement is very intuitive. It tells you in English: as long as the following (you define it) occur, do whatever you want (you decide what to do). We want to tell the program that as long as the time is less than the last observation time (assumed to be known), do the following: suppose that the last observed time is 72 (can be defined as a covariate for each patine tif different from patient to patient). while (t<72) then you open brackets and tell the program what to do as long as the time is less than 72 { stuff to do} now what is stuff to do you open the bracket { we want to shift the index to 0 lightcycle=0; we want then the program to run for 12 hours sleep(12); then we want to change again the index to 1 lightcycle=1; then run the program for 12 hours sleep(12) and then you close the bracket } Now the program finished one cycle and look again at the while condition. If the time is still < than 72, it is doing the same stuff inside the brackets until the condition is not met. The sleep time is relative and not a absolute time, then he will do 6,18,30,42,… the code shows up below for you to review (Thanks to Jason). Best Regards; Serge double(lightcycle) sequence{ #set the beginning of subject cycle value, here I’ll assume that all subject start the study at 12pm lightcycle = 1; sleep(6); while(t< [type in whatever the last observation time in the dataset is] ) { #now we enter the repeating cycles lightcycle=0; sleep(12); lightcycle=1; sleep(12); } } #now us the lightcycle variable in your equations You can also just create a “forward” covariate column and merge it into the dataset. So for each subject there is a record whenever the lightcycle value changes. then use that covariate as a variable. Phoenix can use the “forward” fill to carry the value forward over the ensuing observation and dosing records, if you want to leave the column blank there.