The FAQs page provides answers to users' questions, along with links to other relevant articles within the User Guide.

**How can I define a variable where the value depends on strategy?**

You can easily define variables with values dependent on strategy using the by_strategy(…) function. When you use this function, you must specify a value for each strategy defined on the Strategies page, even if multiple strategies share the same value. If you don’t, the model will generate an error when you run it.

For example, if your model includes three strategies, ‘New_Rx’, ‘Old_Rx’, and ‘No_Tx’, and you want to assign the values 150, 75, and 75, respectively, to a particular variable, your by_strategy(…) function would look like:

Please remember to use the exact names that you assigned to strategies on the Strategies page. Also, please keep in mind R is case sensitive.

**How can I define a variable where the value depends on group?**

You can easily define variables with values dependent on group using the by_group(…) function. When you use this function, you must specify a value for each group defined on the Groups page, even if multiple groups share the same value. If you don’t, the model will generate an error when you run it.

For example, if your model includes two groups, ‘Children’ and ‘Adults’, and you want to assign the values 0.45 and 0.81, respectively, to a particular variable, your by_group(…) function would look like:

Please remember to use the exact names that you assigned to groups on the Groups page. Also, please keep in mind R is case sensitive.

**How can I reference a value stored in a table in my model? **

You can reference a value stored in a hēRo3 table by using the function, look_up(…). This function works similarly to the function, INDEX(…), in Excel, and uses both a row and column reference to identify and extract a value from a table. The arguments of this function, in order, are: (1) the name of the table; (2) a lookup value to indicate the row of interest and the column in which to look for a value; and (3) the name of the column from which you would like to extract the relevant value.

For example, if you wanted to extract the value, 990.3, which is the estimated cost of the adverse event, nausea, from the ‘Adverse_Events’ table shown below,

you would use the function, look_up(…), with syntax as follows:

Please be sure to spell the name of the table, as well as the names of the columns and values, the same way they are spelled in the table itself. Also, please keep in mind R is case sensitive.

**How can I calculate a patient’s current age in my model? **

You can easily calculate current age during any given cycle in a model using a simple formula that references patients’ starting age and the time that has elapsed since model entry. While you can hard code a numeric value for the former, it is best practice to create a variable, ‘start_age’, to refer to this value in formulas. To calculate current age in a given cycle, add the number of years elapsed since model start, which is represented by the hēRo3 keyword, ‘model_year’, to the age of patients at model entry. Because the first year of a model is assigned the value of 1 (and not 0) in hēRo3, it is important to subtract the hēRo3 keyword, ‘cycle_length_years’, from ‘model_year’ in your formula (if you don’t, patient age will be off by 1 year). The formula you would use would be as follows:

Please note that if you are not using annual cycles in your model, current age will not always be an integer.** **

**I want to calculate general population mortality rates in a model from a life table. Is there an easy way to do this in hēRo3?**

You can use the function, define_surv_lifetable(…) to calculate general population mortality rates from a life table (life tables can be copied from any convenient source and pasted into a table in hēRo3). When you use define_surv_lifetable(…), you need to reference the name of the life table, the starting age, the percentage of males in the population at the start of your model, and the unit of time in which mortality rates should be expressed.

Life tables in hēRo3 have to conform to a specific format. They must have a column labelled ‘age’ that contains patient age in years, a column labelled ‘male’ that contains the probability of death for males at each age, and a column labelled ‘female’ that contains the probability of death for females at these ages, *in that order*.

For example, if you had a life table called 'GP_Life_Table', your variable for starting age is ‘start_age’, and 'pct_male' represents the percentage of males in the cohort at the beginning of the model, your formula for calculating general population mortality rates would be as follows:

The final argument in the formula above, ‘output_unit’, refers to the unit of time in which mortality rates should be expressed. For example, if you want to use monthly mortality rates, set ‘output_unit’ to ‘months’. If you want to use annual mortality rates, set ‘output_units’ to ‘years’. You cannot generate quarterly mortality rates, however, since calendar quarters are not a fixed unit of time (ie, there are 92 days between 1 January and 31 March [except in leap years], but there are 91 days between 1 April and 30 June). If your model has quarterly periodicity, however, you can generate quarterly mortality rates by rescaling monthly mortality rates, by using the hēRo3 function, rescale_prob(…).

It is best practice to define and work with survival distributions on the Survival Distributions page, and then refer to them on the Transitions page by the variable names that you have given to them. (If you prefer to perform your survival calculations directly on the Transitions page, you may do so.)

**Is there an easy way to make sure my transitions from a given state sum to 1?**

Although there is no foolproof method to ensure that transitions from a given state sum to 1, hēRo3 has a helpful keyword, ‘C’, to simplify this task. The hēRo3 keyword, ‘C’, is a function that evaluates to 1 minus the sum of all other transitions from a given state (ie, the complement). (It is important to remember that hēRo3 is case-sensitive, and you must enter this function as ‘C’ and not ‘c’.) While you may use the hēRo3 keyword, ‘C’, to express the value of any transition, we think it is most helpful to use it for the probability that patients do * not* leave their current state for another one. Please note that the hēRo3 keyword, ‘C’, may only be used for one transition from a given state; if you use it for more than one transition out of a given state, your model will generate an error and will not run.

**I want to make a variable dependent on time; how can I do that in hēRo3?**

Variables can be made dependent on time simply by referencing one of the hēRo3 keywords for model time. The principal hēRo3 keywords for this are ‘model_day’, ‘model_week’, ‘model_month’, and ‘model_year’.

Assume you have a model that uses monthly periodicity, and you would like assign different costs to patients receiving a particular drug based on how long they have been taking it—for example, to assign the cost of induction therapy (‘induction_cst’) to the first 6 months, and thereafter, to assign the cost of maintenance therapy (‘maintenance_cst’) in all subsequent months. You would use the hēRo3 keyword, ‘model_month’, in a formula for drug cost that would look as follows:

This formula evaluates to ‘indcution_cst’ for the first 6 cycles of your model, and evaluates to ‘maintenance_cst’ for all subsequent cycles.

**When I try to run my model, I get an error message and my model will not run. What should I do?**

The User Guide provides a listing of many common error messages and what might be causing them, available here. There is also a slide deck on this topic, called “Tips & Tricks to Use When Debugging Models in hēRo3”, that you might find helpful. If after consulting these resources, you still are unable to get your model to run, you can always reach out to support@heroapps.io for assistance.

**If I want to apply a cost during the first year of my model, but not during any subsequent years, how can I do this?**

You can easily assign patients a cost only during the first year of your model by referencing one of the hēRo3 keywords for model time—specifically, ‘model_day’, ‘model_week’, ‘model_month’, or ‘model_year’.

For example, if your model has monthly periodicity and you would like to assign patients a monitoring cost only during the first year of treatment, you could use the hēRo3 keyword, ‘model_month’, in a formula that looks as follows:

In this example, patients would be assigned a monthly cost of monitoring, ‘cst_monitoring_m’, during the first 12 cycles of your model (ie, one year) and a cost of 0 in all subsequent cycles. You could enter this formula directly on the Values page, or you could create a variable on the Parameters page and reference it on the Values page. Either method is acceptable, so long as you use a consistent approach.

If your model uses annual cycles, rather than monthly cycles, your formula might look as follows:

By multiplying the monthly monitoring cost by the hēRo3 keyword, ‘cycle_length_months’, you are multiplying the monthly cost by the number of months in an annual cycle in this model. This calculates a total cost of monitoring over one year, based on the value specified for ‘cst_monitoring_m’ (ie, the monthly cost of monitoring). If you do not multiply the monthly cost by the hēRo3 keyword, ‘cycle_length_months’, you will apply the monthly cost of monitoring only once during the entire first year of your model.

**How can I calculate a sum product using the values stored in a table?**

There is an easy way to do a sum product in hēRo3, much as you can do so in Excel.

Assume you would like to calculate a total cost of all adverse events for a particular strategy in your model (say, ‘New_Rx’), and your adverse event data is stored in a hēRo3 table that contains, for several different types of adverse events, their probabilities of occurrence and their associated costs; your table might look as follows:

In table above, column A contains the names of all adverse events in your model, columns B, C, and D contain the probabilities of experiencing these events among patients receiving ‘No_Tx’, ‘Old_Rx’, and ‘New_Rx’, respectively, and column E contains the estimated cost of each adverse event.

Since there are no adverse events associated with ‘No_Tx’, you do not need to calculate the total cost of adverse events for this strategy. You can calculate a total expected cost of adverse events for ‘Old_Rx’ by multiplying the probability of each adverse event for this strategy (column C) times the corresponding cost of each event (column E), which is the same for all strategies. Your formula would look as follows:

You would have a similar formula for ‘New_Rx’, which would differ from the formula above only in the respect that the probabilities of each event would be drawn from the ‘New_Rx’ column; this formula would therefore look as follows:

Both of these formulas return the sum product of the relevant column containing probabilities for a given strategy and the cost of each adverse event, which does not vary between the strategies. If the unit costs of adverse events differed between strategies (eg, due to differences in severity), your table would contain two columns of costs—one to be used for ‘Old_Rx’, and the other to be used for ‘New_Rx’.

**I’m uncertain what method of half-cycle correction to use in my model; what’s the difference between the three methods on the Settings page?**

The method of half-cycle correction that you choose determines when during model cycles patients will transit between health states―at the beginning of each cycle, at the end of each cycle, or at the midpoint of each cycle. The three methods of half-cycle correction that you may choose from are as follows:

- With the Start method, patients are assumed to transition between health states at the
of every cycle; state membership during any given cycle is calculated__beginning__health-state transitions have occurred.__after__ - With the End method, patients are assumed to transition between health states at the
of every cycle; state membership during any given cycle is calculated__end__health-state transitions have occurred.__before__ - With the Life-Table method, which hēRo3 defaults to unless you select another method, patients are assumed to transit between health states at the
of each cycle, and state membership during any given cycle is calculated as the average of health-state membership before and after transitions have occurred.__midpoint__

If you have a model that has very short cycles (eg, daily or weekly), nominal differences between the three methods are typically small. If you have a model with very long cycles (eg, annual), however, the three methods can produce noticeably different results. It also is important to know that if you use the Start method and your model incorporates mortality, some patients will immediately die at model entry and not contribute any membership time to any state other than ‘dead’.

**I don’t know which method of discounting to choose on the ****Settings ****page in my model; what’s the difference between the three methods?**

The discounting method that you choose determines how outcomes and costs are discounted in your model to reflect the time value of money (as well as health). The three methods of discounting that you may choose from are as follows:

- With the Start method, which hēRo3 defaults to unless you select another method, discount factors for outcomes and costs during each model cycle are based on the value of time at the
of every cycle.__beginning__ - With the End method, discount factors for outcomes and costs during each model cycle are based on the value of time at the
of every cycle.__end__ - With the Midpoint method, discount factors for outcomes and costs are based on the value of time at the
of every cycle.__midpoint__

If you have a model that has very short cycles (eg, daily or weekly), nominal differences between the three methods of discounting are typically small. If you have a model with very long cycles (eg, annual), however, the three methods can produce noticeably different results. Notably, with the End method, the discount factors for outcomes and costs in the first model cycle will be a number less than one. If you select the Start method, the discount factors for outcomes and costs during the first model cycle will be equal to one.

**If I want to apply one-time cost at the beginning of a model, how would I do that?**

You can easily apply a one-time cost at the beginning of a model on the Values page. Because this cost is incurred only when patients enter your model, you would not discount it as you would costs that occur in future periods. To add this one-time cost to your model, after you have defined it on the Values page, use the dropdown menu labeled, ‘Type’, to select ‘Model Start’.

**I am not sure how to use ‘User Override Values’ that I see on ****Results pages****. What is this functionality all about? **

The User Override Menu allows you to pin input parameters to the Results pages of a model. If you pin a parameter to the User Override Menu, you can change the value for this parameter ‘on the fly’ on any Results page of a model (ie, you don’t have to return to the Parameters page to make such changes). This functionality can be very useful when you would like to see how a particular parameter affects findings of a model in ‘real time’.

To pin a parameter to the User Override Menu:

- Click the ‘Manage Override Values’ button in the Configuration Sidebar on any Results screen. In the pop-up menu, check every variable that you would like to be pinned to the User Override Menu.
- Use the drag handles to place the selected variables in the order that you would like them to be displayed in the ‘User Override Menu’.
- If you would like to restrict the possible values that an input parameter can have―for example, a set of integers or a list of category names―in the ‘Options’ column for this parameter, set forth the values that this variable may take on as a comma-separated list.
- When done, click ‘OK’.

Another common use case for the User Override Menu would be when you want to share a model with others who will be allowed access to it with View-Only privileges. While users with View-Only privileges ordinarily can run a model but not change values for model parameters, they are able to change the values of model parameters that you pin to the User Override Menu.

If you would like to change the value of a variable in the User Override Menu, simply click on the input field next to it, enter the desired new value, and hit the ‘Enter’ key or click outside the input field. Base case results will be automatically recalculated when you do this. (Note: sensitivity analyses must be rerun manually, however; this ensures that a model does not automatically recalculate multiple times when you might be planning to change the values of several parameters in the User Override Menu.)

**I want to apply a hazard ratio to a survival distribution defined on the Survival Distributions page of a model. Is there an easy way to do this?**

Yes―if you want to apply a hazard ratio to a survival distribution that has already been defined on the Survival Distributions page of a model, there is a hēRo3 function, apply_hr(…), that allows you to do so easily.

For example, if you used an exponential curve to depict progression-free survival (PFS) in patients who are receiving standard of care (SOC), you might have a survival distribution defined on your Survival Distributions page called ‘SOC_PFS_exp’, with a formula that looks something like this:

Now, imagine that a new therapy was expected to extend PFS by 15% compared with SOC. If you created a variable, ‘NEW_pfs_hr’, and set its value to 0.85, you can specify the PFS distribution for the new treatment using the apply_hr(…) function in a formula as follows:

(Note: If you want to add hazards to survival distributions, you should not use the function, apply_hr(…). Hazards can be added to survival distributions using the hēRo3 function, add_hazards(…).)

**I have a series of annual probabilities that I want to convert into monthly probabilities. Is there an easy way to do this in hēRo3?**

Yes―there is a hēRo3 function, rescale_prob(…), that allows you to easily convert probabilities from one measure of time to another.

For example, if you have an annual probability ('event_prob’) that you would like to convert to a monthly probability, you can do so with the following formula:

**Can I build a Markov model in hēRo3 with multiple lines of therapy?**

Yes. However, because there are countless possible modeling frameworks that incorporate multiple lines of therapy, there is no single best approach for setting up a Markov model of this nature. In general, one can characterize three alternative approaches for building models in hēRo3 with multiple lines of therapy, as follows: (1) depicting each line of therapy as its own separate health state (this approach is generally best for models that are relatively simple); (2) depicting each line of therapy with a set of health states that employ the __same structure for each line__; and (3) depicting each line of therapy as a set of health states using a __distinct structure for each line__.

To illustrate the first approach (ie, in which each line of therapy is depicted using a single health state), imagine that you wanted to consider two alternative strategies for using Drug A, Drug B, and Drug C as first-line therapy (L1), second-line therapy (L2), and third-line therapy (L3). One strategy involves the use of Drug A as L1, Drug B as L2, and Drug C as L3, and the alternative strategy involves the use of Drug B as L1, Drug C as L2, and Drug A as L3.

You could set up this model by creating three health states, ‘L1’, ‘L2’, and ‘L3’, and two strategies, ‘S1’and ‘S2’ (in this simple model, we will assume that patients can switch therapy, but never stop receiving treatment). You undoubtedly want to include a health state, ‘Dead’, for patients who die. Because this model depicts two strategies that use the same drugs, albeit in a different order, you may want to specify model parameters that are specific to each line of therapy and strategy (ie, one parameter value for each unique combination of line of therapy and strategy), rather than by drug, as the same drug may have different parameter values (eg, efficacy) in different lines of therapy (eg, expectations of clinical response may be greater when a drug is used as L1 than as L2, and correspondingly, greater when it is used as L2 than as L3).

In the above circumstance, you could create a table containing efficacy values (or any other parameter, for that matter) for Drug A, Drug B, and Drug C in strategies S1 and S2, respectively, and then use the hēRo3 function, look_up(…), to pull the appropriate values from this table into your model. The table that you would create—for example, named ‘Tx_Efficacy’—should include a row for each line of therapy (ie, L1, L2, and L3), and a column for each strategy (ie, S1, S2). Your table might look as follows:

And the value for the efficacy of Drug A in S1 (ie, as L1) would be obtained using the hēRo3 function, look_up(…), with the following arguments:

Now, let’s consider a slightly different decision problem in which patients are initially treated medically, and if they fail medical therapy, might be referred for surgery. Let’s further assume that two drugs—Drug A and Drug B—are the two medications used for medical therapy, and that you want to compare one strategy that involves use of Drug A on a first-line basis (again, L1), followed by Drug B as second-line therapy (L2), with patients failing both therapies being referred for surgery, while the other strategy involves use of Drug B as L1 and Drug A as L2, with surgery again being used in patients who fail both of these treatments. This model will likely need to employ a distinct set of health states to depict surgical intervention, but it can depict first- and second-line therapy similarly.

To set up this model, you could create two strategies (eg, ‘S1’ and ‘S2’) and depict them using the following health states: ‘L1’, ‘L2’, ‘Surgery_Success’, ‘Surgery_Fail’, and ‘Dead’. In this model, you would likely want to establish model parameters specific to line of therapy, strategy, and, where appropriate, surgical outcome. Much like the approach described above, you could create a table for each type of variable (eg, ‘Tx_Efficacy’), which you would then populate with a column for each strategy (ie, S1, S2) and a row for each health state (ie, L1, L2, Surgery_Success, Surgery_Failure). You could then reference this table to populate model parameters for treatment efficacy. An approach with multiple health states per line of therapy is more flexible, as it allows each line of therapy to employ a distinct set of health states, as needed; however, this approach also can make a model more difficult to quality check, as it can add complexity to the set-up.

For models that entail multiple—but identical—health states for each line of therapy, there is a middle ground between the two modeling approaches described above. Imagine that, as in the first example, you wanted to consider two different strategies for using Drug A, Drug B, and Drug C as first-line (L1), second-line (L2), and third-line (L3) treatment. One strategy would involve the use of Drug A as L1, Drug B as L2, and Drug C as L3, while the comparison strategy would involve the use of Drug B as L1, Drug C as L2, and Drug A as L3. This time, though, let’s assume that some patients may discontinue treatment and not progress immediately to the next line of therapy. We might create a series of health states, as follows: ‘L1_ON’ for those actively receiving L1, ‘L1_OFF’ for those who have discontinued L1 but have not yet progressed to L2, ‘L2_ON’ for those actively receiving L2, ‘L2_OFF’ for those who have discontinued L2 but have not yet progressed to L3, ‘L3_ON’ for those actively receiving L3, ‘L3_OFF’ for those who have discontinued L3 and have exhausted their treatment options (you also would want to include a state, ‘Dead’, in your model assuming patients can die). Once again, you can set up tables for each variable (eg, ‘Tx_Efficacy’) and use the function, look_up(…), to pull the appropriate values into your model for the two strategies you want to compare.

The above-described approach can be quite useful when the same structure can be used to depict health states in each line of therapy. Using parallel health-state frameworks for each line of therapy, with common formulas and nomenclature, where appropriate, will enable you to check your model more rapidly for errors.

Please be aware that if you use any of the hēRo3 keywords for state time (ie, ‘state_day’, ‘state_week’, ‘state_month’, ‘state_year’, and ‘state_time’), they will evaluate based on the time spent in each health state and not time spent in each line of therapy.

We also recommend that you take a look at the template, ‘Webinar Model – Advanced Markov’, in the Model Templates section of your hēRo3 Workspace to see an example of a Markov model that incorporates multiple lines of therapy.

**When I run my model, I get an ‘out of memory’ error message; what should I do to fix this problem?**

hēRo3 performs all calculations using advanced and powerful AWS compute servers. If you get this error message, it means that your model is so large that it hit a memory limit during computations. There are several things you might want to try to resolve an ‘out of memory’ error message, including:

- Reducing the number of groups included in a model if you have a number of them.
- Reducing the number of strategies included in a model if you have several.
- Reducing the time horizon of your analyses.
- Increasing the cycle length of your model if it is currently short (eg, changing it from daily to weekly, or weekly to monthly, etc). Please be aware that if you change the cycle length of a model, you also may need to make other changes to it to ensure that your calculations are being done correctly.
- If you are running a Markov Cohort Model that employs time dependency (ie, uses any of the hēRo3 keywords for state time), try capping the number of tunnel states in the MTS column on the States page. If you have already specified a value for MTS on the States page, try using a smaller value.
- If you are running a DSA, try reducing the number of variables that are included in these analyses.
- If you are running scenario analyses, try reducing the number of scenarios you are examining.
- If you are running a PSA, try reducing the number of simulations.

**If I am building a Partitioned Survival Model (PSM) in hēRo3, how can I define a survival distribution on the Survival Distributions page using Kaplan-Meier data stored in a hēRo3 table?**

You can easily define a survival distribution on the Survival Distributions page using Kaplan-Meier (KM) data stored in a table, using the hēRo3 function, define_surv_table(…). To use this function, you must have a table that contains two columns: one labelled ‘time’ that contains various time points for which you have survival probabilities; and another labelled ‘survival’ that contains the survival probability at each point in time.

Let’s assume you have defined a table, called ‘surv_probs_mos’, in your hēRo3 model that contains the probability of survival at various points in time (in this instance, months), which looks like the following:

If you wanted to create a distribution for overall survival using the KM data stored in the above table, you can do so by creating a new variable, ‘OS_KM’, and defining the formula for this variable using the hēRo3 function, define_surv_table(…), as follows:

For PSMs in hēRo3, you can estimate the proportion patients alive by referencing the survival distribution, ‘OS_KM’, directly in the formula bar on the Transitions page. The unit of time that is specified under the column ‘Time Unit’ on the Transitions page should correspond to the unit of time that you use in the table containing your KM data to describe how survival changes over time. In the above example, since survival was expressed in your KM data in terms of months, you would specify ‘months’ here.

For information on how to use KM data in a Markov Cohort Model, please see the FAQ ‘If I am building a Markov Cohort Model in hēRo3, how can I define a survival distribution on the Survival Distributions page using Kaplan-Meier data stored in a hēRo3 table?’.

**If I am building a Markov Cohort Model in hēRo3, how can I define a survival distribution on the Survival Distributions page using Kaplan-****Meier data stored in a hēRo3 table?**

You can easily define a survival distribution on the Survival Distributions page using Kaplan-Meier (KM) data stored in a table, using the hēRo3 function, define_surv_table(…). To use this function, your table must contain two columns: one labelled ‘time’, which contains various time points for which you have survival probabilities; and another labelled ‘survival’, which contains the survival probability at each point in time.

Let’s assume you have defined a table, called ‘surv_probs_mos’, in your hēRo3 model that contains the probability of survival at various points in time (in this instance, months), which looks like the following:

If you wanted to create a distribution for survival using the KM data stored in the above table, you can do so by creating a new variable, ‘Surv_KM’, and defining the formula for this variable using the hēRo3 function, define_surv_table(…), as follows:

Now, let’s assume your Markov cohort model has two health states, ‘Sick’ and ‘Dead’, and you want to use the survival distribution, ‘Surv_KM’, to estimate the probability of transitioning from the ‘Sick’ state to the ‘Dead’ state. You can do so using the hēRo3 function, event_prob(…), in a formula on the Transitions page as follows:

The arguments of the hēRo3 function, event_prob(…), are as follows: (1) a survival distribution; (2) the start time of an interval (eg, a month); and (3) the end time of an interval. The unit of time (ie, days, weeks, months, years) used in the second and third arguments of the event_prob(…) function should correspond to the unit of time that you use in the table containing your KM data.

Please note that model time in hēRo3 begins with 1, and not 0, and thus it is necessary to subtract one cycle length (eg, ‘cycle_length_months’) from ‘model_month’ to correctly designate the start time as the beginning of a given cycle. Because time in hēRo3 begins with 1, and not 0, you do not have to adjust the model time at the end of a cycle. This is because the entire duration of the last model cycle will already be counted using one of the hēRo3 keywords for model time (eg, ‘model_month’).

For information on how to use KM data in a Partitioned Survival Model, please see the FAQ ‘If I am building a Partitioned Survival Model (PSM) in hēRo3, how can I define a survival distribution on the Survival Distributions page using Kaplan-Meier data stored in a hēRo3 table?’.