# Dolo.jl in JuliaBox

Hi everyone,

I am a first year undergrad with little to no programming experience so I apologise for asking such naive questions. Yesterday I discovered Dolo.jl and I very much want to play around with it. However, I am having some difficulties setting it up. What I have done so far:

Since I am using JuliaBox I added Dolo using the package builder and after a while the bar turned green. I then found an example model here. But when I try to run the code I get the error

syntax: line break in “:” expression

Stacktrace:

I started with `using Dolo` and then pasted one of the example codes.

I am quite embarrassed to be asking this question seeing as this forum consists of highly advanced economists but hopefully someone can point me in the right direction.

Hi @Gensys,

No worries. The purpose of the forum is exactly to help answer questions like this!

• I tried to use Dolo.jl on juliabox the other day and it didn’t work for me. I have been able to get it to work on an old version of JuliaBox now running at https://v1.juliabox.com
• If you post the code you tried to run we would be better able to help. `include_string` is what IJulia uses to run any code, so you would see that as the first entry of any stacktrace in a jupyter notebook.

Thanks for the reply and the encouraging words @spencer.lyon Here is the code I ran:

``````using Dolo
using PlotlyJS
using AxisArrays

symbols:
states: [k, tau_c, tau_k]
controls: [c]
exogenous: [g, exog_tau_c, exog_tau_k]
parameters: [beta, gamma, delta, alpha, A]

definitions:
# Equations from 11.6.8
eta: alpha*A*k^(alpha-1)
w: A*k^alpha - k*eta
Rb: (1+tau_c)/(1+tau_c(1))*((1-tau_k(1)) * (alpha*A*k(1)^(alpha-1) - delta) + 1.)

equations:

arbitrage:
# Equation 11.6.3
- 1 = beta*(c(+1)/c)^(-gamma)*(1+tau_c)/(1+tau_c(1))*((1-tau_k(1))*(eta(1)-delta) + 1) | 0 <= c <= inf

transition:
# Equation 11.6.1
- k = A*k(-1)^alpha+(1-delta)*k(-1)-c(-1)-g
# We have the states tau_c and tau_k just follow exactly the sequence
# of shocks that we supply.
- tau_c = exog_tau_c
- tau_k = exog_tau_k

calibration:
# parameters
beta: 0.95
gamma: 2.0
delta: 0.2
alpha: 0.33
A: 1.
tau_c: 0.0
tau_k: 0.0
exog_tau_c: 0.0
exog_tau_k: 0.0
tau_c: exog_tau_c
tau_k: exog_tau_k
g: 0.2

k: ((1/beta - 1 + delta)/alpha)^(1/(alpha-1))
c: k^alpha - delta*k - g
eta: alpha * A * k ^ (alpha - 1)
w: A * k ^ alpha - k * eta
Rb: (1-tau_k) * (alpha*A*k^(alpha-1) - delta) + 1.0

domain:
k: [0.5*k, 1.5*k]
tau_c: [0.5*tau_c, 1.5*tau_c]
tau_k: [0.5*tau_k, 1.5*tau_k]

exogenous: !VAR1
rho: 0.9
Sigma: [[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]]
N: 3

options:
grid: !Cartesian
orders: [40, 10, 10]
``````

I just wanted to try an example piece of code to see if I could get Dolo to work. I have not tried to understand what we are trying to model here. I will try using the older version of JuliaBox and see if I can get it to work.

Thanks once again for your help.

Ahh so the problem here is that you have tried to copy and paste the model definition directly in to your Julia session.

Starting from `symbols:` everything in your snippet needs to to be in a separate file.

Notice how in the `rmt3_ch11.ipynb` file here we say `model = yaml_import("../models/rmt3_ch11.yaml")`, meaning load the file in `rmt3_ch11.yaml` found one directory (folder) up and then in the models folder.

You can also, however, load models directly from a url. You can change your example code to

``````
using Dolo
using PlotlyJS
using AxisArrays

url = string(
"https://raw.githubusercontent.com/EconForge/Dolo.jl/",
"1203a43cf1c46cb14fc78dcecde320673f3a7311/examples/models/rmt3_ch11.yaml"
)
model = yaml_import(url)
``````

Thank you once again @spencer.lyon, I really appreciate the help. I think I understand how to loadmodels from the url. However, as I want to use Dolo for models I have constructed myself, I just want to make sure I understand how save things properly.

So I create a folder which contains each section (i.e `symbols`, `definitions`, `equations` etc) in a separate file (each of them saved as .ipynb). In the example you provided this folder is named `models`. In the same folder I create a new notebook named `rmt3_ch11.yaml`. And this is where I can do experiments (such as create IRF’s) with the model. Am I on the right track now?

Nope, not quite. I recommend reading through the Dolo.jl documentation

I’ll summarize key points here:

• To write a model yourself you need to have a single yaml file containing the model. For example, I could create `my_model.yaml`
• In this file you need to specify the following sections: `symbols`, `equations`, `calibration`, `exogenous`, and `domain`. Other sections noted in the docs (or in the example models here are optional)
• Then call `model = yaml_import("my_model.yaml")` where “my_model.yaml” is replaced by the path to the yaml file you created in the first step. The reason for the `../models/rmt3_ch11.yaml` in th example above is that the file `rmt3_ch11.yaml` was not in the same folder as the notebook that was trying to load the model in that file.

If you want to load the model and solve/explore it in a jupyter notebook (`.ipynb` extension), then you create a single `.ipynb` file that loads Dolo and has the `yaml_import` line from the last step above.

1 Like

Ahh, I see! I’ll try to follow your steps and hopefully I can get it working by tonight. Also, I tried loading the model using the URL and it worked perfectly Juliabox should now be up and running with Dolo. Give it a shot!

Thanks for the heads up @jlperla. I have been working on the .yaml file but unfortunately I can’t get it to work perfectly (this is most likely due to mistakes I have made in the `definitions` block).

I will work on it some more but if I can’t figure it out, would you mind taking a look at it?

I wouldn’t be able to (and don’t actually know any details on Dolo). But if you post up your questions, I suspect other people might be able to help.

1 Like

can i ask questions as well? i’m new here so not sure. or i should privately ask? anyway, i’m having some about JuliaBox. thanks!

@Wive1982 Please go ahead – although if it’s unrelated to dolo then it might be best to start a new thread.