SlideShare a Scribd company logo
Implementing an experiment in oTree
Olaf Ghanizadeh
What is oTree?
What is oTree?
• Open Source framework to create behavioral economics experiments,
Chen, Schonger, and Wickens (2016).
• Python based, uses Django to create a web application
• Bootstrap 4 for styling
• Object-oriented, extensive use of classes and methods
1
How does oTree work?
Templates
In models.py we execute most of our code:
1 class Subsession(BaseSubsession):
2 """Create the session to be played"""
3 def creating_session(self):
4 """Create variables that holds for all players in this session"""
5 for p in self.get_players():
6 """Each player, p, in the session, self"""
7
8 class Group(BaseGroup):
9 """If we wanted to have players in different groups"""
10 pass
2
models.py
In models.py we execute most of our code:
1 class Player(BasePlayer):
2 """We execute what goes for each player."""
3 name = models.StringField()
We register the fields that will be exposed on the front-end, and the
variables that will be stored in each ’player object’
1 def set_payoffs(self):
A method within the Player Class where we can set the payoff for each
player. We need to call this method for payoffs to be set. In my project it
is called before the user sees the final results page.
3
pages.py
In pages.py we create the pages that will be shown to the user, define the
forms, expose variables for the front end and so on.
1 # Class for the IntroPage. Inherits attributes from Page Class
2 class IntroPage(Page):
3 # Get forms to be displayed on IntroPage
4 form_model = 'player'
5 form_fields = ['name', 'risk']
We register the fields that will be exposed on the front-end, and the
variables that will be stored in each ’player object’
4
pages.py
1 # Class for the DecisionPage. Inherits attributes from Page Class
2 class DecisionPage(Page):
3 form_model = 'player'
4
5 ...
6
7 # Triggers the function that set draws the payoff of the
8 #user before the user is taken to the result page. This
9 # should be changed if we were to make a game with several rounds.
10 def before_next_page(self):
11 self.player.set_payoffs()
We call the self.player.set_payoffs() before the next page is loaded to
set the payoffs for the individual player.
5
Templates
• HTML Templates
• Dynamic through Django template tags and variables
• Extensible with JavaScript.
6
Experiment
Experiment
• A simplified version of the experiment made famous in Holt and
Laury (2002).
• An approach to elicit individual preferences for risk, and how
incentive effects affect choices.
• Assumes that utility theory holds.
7
Our goal
Does the participant choose differently from their indicated risk
preferences?
8
• A risk-neutral user should consider the expected values of the
different outcomes, and maximize it for each choice.
• In our experiment that is the sequence AAAA/BBBB
9
Acknowledgements
Acknowledgements
• Severly simplified version of experiment
• Should record at what point the user decides to switch from A to B
• Code error with > 9 choices.
• Should include several rounds and treatments
• Lacks calculation of Constant Relative Risk Aversion (CRRA)
10
Data Analysis
References
Chen, Daniel L., Martin Schonger, and Chris Wickens (Mar. 2016).
“oTree—An Open-Source Platform for Laboratory, Online, and Field
Experiments”. In: Journal of Behavioral and Experimental Finance 9,
pp. 88–97. issn: 22146350. doi: 10.1016/j.jbef.2015.12.001.
url: https:
//linkinghub.elsevier.com/retrieve/pii/S2214635016000101
(visited on 12/04/2019).
Holt, Charles A and Susan K Laury (Nov. 2002). “Risk Aversion and
Incentive Effects”. In: American Economic Review 92.5,
pp. 1644–1655. issn: 0002-8282. doi:
10.1257/000282802762024700. url:
http://pubs.aeaweb.org/doi/10.1257/000282802762024700
(visited on 12/04/2019).
11
Questions?
11

More Related Content

Similar to Implmenting an Experiment in oTree (20)

PPTX
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
PPTX
How to generate customized java 8 code from your database
Speedment, Inc.
 
PDF
Eight Rules for Making Your First Great Game
Nick Pruehs
 
PDF
Mobile Weekend Budapest presentation
Péter Ádám Wiesner
 
PPTX
Testing Ext JS and Sencha Touch
Mats Bryntse
 
PPTX
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
PDF
Selenium web driver | java
Rajesh Kumar
 
PDF
Fantasy Football Draft Optimization in R - HRUG
egoodwintx
 
PDF
Intro to PHP Testing
Ran Mizrahi
 
PDF
Sustainable software institute Collaboration workshop
Yannick Wurm
 
PDF
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Serdar Basegmez
 
PDF
Android application - Tic Tac Toe
Sarthak Srivastava
 
PDF
Computer Tools for Academic Research
Miklos Koren
 
PDF
Build tic tac toe with javascript (3:28)
Thinkful
 
PPTX
SenchaCon 2016: How Sencha Test Helps Automate Functional Testing of Ext JS M...
Sencha
 
PPTX
iOS Development at Scale @Chegg
GalOrlanczyk
 
PPTX
Software Engineer- A unity 3d Game
Isfand yar Khan
 
PDF
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
PPT
Lesson12 other behavioural patterns
OktJona
 
DOCX
Imagine that you are a public health nurse, and you and your colle
LizbethQuinonez813
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
How to generate customized java 8 code from your database
Speedment, Inc.
 
Eight Rules for Making Your First Great Game
Nick Pruehs
 
Mobile Weekend Budapest presentation
Péter Ádám Wiesner
 
Testing Ext JS and Sencha Touch
Mats Bryntse
 
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
Selenium web driver | java
Rajesh Kumar
 
Fantasy Football Draft Optimization in R - HRUG
egoodwintx
 
Intro to PHP Testing
Ran Mizrahi
 
Sustainable software institute Collaboration workshop
Yannick Wurm
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Serdar Basegmez
 
Android application - Tic Tac Toe
Sarthak Srivastava
 
Computer Tools for Academic Research
Miklos Koren
 
Build tic tac toe with javascript (3:28)
Thinkful
 
SenchaCon 2016: How Sencha Test Helps Automate Functional Testing of Ext JS M...
Sencha
 
iOS Development at Scale @Chegg
GalOrlanczyk
 
Software Engineer- A unity 3d Game
Isfand yar Khan
 
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
Lesson12 other behavioural patterns
OktJona
 
Imagine that you are a public health nurse, and you and your colle
LizbethQuinonez813
 

More from eurosigdoc acm (20)

PPTX
Blockchain e o Futuro do Setor Financeiro
eurosigdoc acm
 
PPTX
No code – Caso Prático no App Inventor - BroTrip
eurosigdoc acm
 
PPTX
The oracle problem nos smart contracts
eurosigdoc acm
 
PPTX
Robotic process automation
eurosigdoc acm
 
PPTX
Robotic Process Automation: caso de estudo Delloite
eurosigdoc acm
 
PPT
Projeção do Crowdfunding em Portugal: a plataforma ppl
eurosigdoc acm
 
PPTX
Implementação de uma aplicação em Power Apps – Low Code
eurosigdoc acm
 
PPTX
Proteção de dados e redes sociais
eurosigdoc acm
 
PDF
CLOUD COMPUTING E SUSTENTABILIDADE EMPRESARIAL
eurosigdoc acm
 
PDF
CROWDFUNDING: IMPACTO DA GAMIFICAÇÃO NAS PLATAFORMAS DE CROWDFUNDING
eurosigdoc acm
 
PPTX
Low code: O futuro do desenvolvimento de aplicações
eurosigdoc acm
 
PPTX
Robotic Process Automation
eurosigdoc acm
 
PPTX
Crowdsourcing: DEFINIÇÕES E APLICAÇÕES NA ÁREA DA SAÚDE
eurosigdoc acm
 
PPTX
Business Intelligence e o Desporto
eurosigdoc acm
 
PPTX
Blockchain
eurosigdoc acm
 
PPTX
Blockchain: viável ou em luta com o meio ambiente?
eurosigdoc acm
 
PPTX
Cloud Computing e a sua Implementação na Educação no Contexto de Pandemia COV...
eurosigdoc acm
 
PPTX
Viabilidade das NFT’s a Longo Prazo
eurosigdoc acm
 
PPTX
Outsystems e o Universo do Low-Code
eurosigdoc acm
 
Blockchain e o Futuro do Setor Financeiro
eurosigdoc acm
 
No code – Caso Prático no App Inventor - BroTrip
eurosigdoc acm
 
The oracle problem nos smart contracts
eurosigdoc acm
 
Robotic process automation
eurosigdoc acm
 
Robotic Process Automation: caso de estudo Delloite
eurosigdoc acm
 
Projeção do Crowdfunding em Portugal: a plataforma ppl
eurosigdoc acm
 
Implementação de uma aplicação em Power Apps – Low Code
eurosigdoc acm
 
Proteção de dados e redes sociais
eurosigdoc acm
 
CLOUD COMPUTING E SUSTENTABILIDADE EMPRESARIAL
eurosigdoc acm
 
CROWDFUNDING: IMPACTO DA GAMIFICAÇÃO NAS PLATAFORMAS DE CROWDFUNDING
eurosigdoc acm
 
Low code: O futuro do desenvolvimento de aplicações
eurosigdoc acm
 
Robotic Process Automation
eurosigdoc acm
 
Crowdsourcing: DEFINIÇÕES E APLICAÇÕES NA ÁREA DA SAÚDE
eurosigdoc acm
 
Business Intelligence e o Desporto
eurosigdoc acm
 
Blockchain
eurosigdoc acm
 
Blockchain: viável ou em luta com o meio ambiente?
eurosigdoc acm
 
Cloud Computing e a sua Implementação na Educação no Contexto de Pandemia COV...
eurosigdoc acm
 
Viabilidade das NFT’s a Longo Prazo
eurosigdoc acm
 
Outsystems e o Universo do Low-Code
eurosigdoc acm
 
Ad

Recently uploaded (20)

PDF
U1L2 - Famous Entrepreneurs Project Instructions.pdf
imran7abdul
 
PPTX
REVISITING SHARPES SINGLE INDEX AND OPTIMAL PORTFOLIO
tazeenmahat
 
PDF
Ho Lee model and Girsanov theorem, ratio of deflated Zeros
luc faucheux
 
PDF
econ210 erdfjdhsfhsdfsdfsdfsdfsdfsdfsdfsdf
UlkerProgrammer
 
PPTX
Latest guidelines Pay_Fixation_26th_June.pptx
andupandu139
 
PDF
Magerman_ECOOM_deglobalization_reorganization
glennmagerman2
 
PDF
Celebrating Shivsrushti’s Growing Visitor Numbers and Cultural Impact
Raj Kumble
 
PPTX
macro lecture 2.pptx....................
raniamoawad1
 
PPTX
super team v super team super team .pptx
COMMERCEES
 
PDF
Tran Quoc Bao of Prima Saigon ranked 6 amongst Asia’s Powerhouse Hospital CEO...
Gorman Bain Capital
 
PDF
NEP SYLLABUS 24-25 BCOM.pdf for Bangalore
meera691805
 
PPTX
Achieving Operational Excellence and Customer Intimacy: enterprise applications
cabdiraxmanaxmadwars
 
PPTX
PERFORMANCE MEASUREMENT PRESENTATION FOR MANAGERIAL ACCOUNTING
sttsegah89
 
PDF
Asia’s Private Equity Push: Dr. Tran Quoc Bao Puts Vietnam on the Medical Inv...
Gorman Bain Capital
 
PPTX
CHAPTER 05; THE INTERNATIONAL LEGAL ENVIRONMENT.pptx
Atoshe Elmi
 
PDF
Understanding Gap Funds Bridging the Innovation Valley of Death.pdf
Innovosource
 
PPTX
How Contetra Helped KNAV Save 20 Manhours a Month.pptx
jayjani123
 
PDF
Teaching Thursday_ Understanding On-Chain Metrics
CIFDAQ Blockchain
 
PPTX
Impacts of brexit and its brief description
ssuserdbd8e9
 
PDF
PM presentation_1 July to PensionsPlayPen.pdf
Henry Tapper
 
U1L2 - Famous Entrepreneurs Project Instructions.pdf
imran7abdul
 
REVISITING SHARPES SINGLE INDEX AND OPTIMAL PORTFOLIO
tazeenmahat
 
Ho Lee model and Girsanov theorem, ratio of deflated Zeros
luc faucheux
 
econ210 erdfjdhsfhsdfsdfsdfsdfsdfsdfsdfsdf
UlkerProgrammer
 
Latest guidelines Pay_Fixation_26th_June.pptx
andupandu139
 
Magerman_ECOOM_deglobalization_reorganization
glennmagerman2
 
Celebrating Shivsrushti’s Growing Visitor Numbers and Cultural Impact
Raj Kumble
 
macro lecture 2.pptx....................
raniamoawad1
 
super team v super team super team .pptx
COMMERCEES
 
Tran Quoc Bao of Prima Saigon ranked 6 amongst Asia’s Powerhouse Hospital CEO...
Gorman Bain Capital
 
NEP SYLLABUS 24-25 BCOM.pdf for Bangalore
meera691805
 
Achieving Operational Excellence and Customer Intimacy: enterprise applications
cabdiraxmanaxmadwars
 
PERFORMANCE MEASUREMENT PRESENTATION FOR MANAGERIAL ACCOUNTING
sttsegah89
 
Asia’s Private Equity Push: Dr. Tran Quoc Bao Puts Vietnam on the Medical Inv...
Gorman Bain Capital
 
CHAPTER 05; THE INTERNATIONAL LEGAL ENVIRONMENT.pptx
Atoshe Elmi
 
Understanding Gap Funds Bridging the Innovation Valley of Death.pdf
Innovosource
 
How Contetra Helped KNAV Save 20 Manhours a Month.pptx
jayjani123
 
Teaching Thursday_ Understanding On-Chain Metrics
CIFDAQ Blockchain
 
Impacts of brexit and its brief description
ssuserdbd8e9
 
PM presentation_1 July to PensionsPlayPen.pdf
Henry Tapper
 
Ad

Implmenting an Experiment in oTree

  • 1. Implementing an experiment in oTree Olaf Ghanizadeh
  • 3. What is oTree? • Open Source framework to create behavioral economics experiments, Chen, Schonger, and Wickens (2016). • Python based, uses Django to create a web application • Bootstrap 4 for styling • Object-oriented, extensive use of classes and methods 1
  • 5. Templates In models.py we execute most of our code: 1 class Subsession(BaseSubsession): 2 """Create the session to be played""" 3 def creating_session(self): 4 """Create variables that holds for all players in this session""" 5 for p in self.get_players(): 6 """Each player, p, in the session, self""" 7 8 class Group(BaseGroup): 9 """If we wanted to have players in different groups""" 10 pass 2
  • 6. models.py In models.py we execute most of our code: 1 class Player(BasePlayer): 2 """We execute what goes for each player.""" 3 name = models.StringField() We register the fields that will be exposed on the front-end, and the variables that will be stored in each ’player object’ 1 def set_payoffs(self): A method within the Player Class where we can set the payoff for each player. We need to call this method for payoffs to be set. In my project it is called before the user sees the final results page. 3
  • 7. pages.py In pages.py we create the pages that will be shown to the user, define the forms, expose variables for the front end and so on. 1 # Class for the IntroPage. Inherits attributes from Page Class 2 class IntroPage(Page): 3 # Get forms to be displayed on IntroPage 4 form_model = 'player' 5 form_fields = ['name', 'risk'] We register the fields that will be exposed on the front-end, and the variables that will be stored in each ’player object’ 4
  • 8. pages.py 1 # Class for the DecisionPage. Inherits attributes from Page Class 2 class DecisionPage(Page): 3 form_model = 'player' 4 5 ... 6 7 # Triggers the function that set draws the payoff of the 8 #user before the user is taken to the result page. This 9 # should be changed if we were to make a game with several rounds. 10 def before_next_page(self): 11 self.player.set_payoffs() We call the self.player.set_payoffs() before the next page is loaded to set the payoffs for the individual player. 5
  • 9. Templates • HTML Templates • Dynamic through Django template tags and variables • Extensible with JavaScript. 6
  • 11. Experiment • A simplified version of the experiment made famous in Holt and Laury (2002). • An approach to elicit individual preferences for risk, and how incentive effects affect choices. • Assumes that utility theory holds. 7
  • 12. Our goal Does the participant choose differently from their indicated risk preferences? 8
  • 13. • A risk-neutral user should consider the expected values of the different outcomes, and maximize it for each choice. • In our experiment that is the sequence AAAA/BBBB 9
  • 15. Acknowledgements • Severly simplified version of experiment • Should record at what point the user decides to switch from A to B • Code error with > 9 choices. • Should include several rounds and treatments • Lacks calculation of Constant Relative Risk Aversion (CRRA) 10
  • 17. References Chen, Daniel L., Martin Schonger, and Chris Wickens (Mar. 2016). “oTree—An Open-Source Platform for Laboratory, Online, and Field Experiments”. In: Journal of Behavioral and Experimental Finance 9, pp. 88–97. issn: 22146350. doi: 10.1016/j.jbef.2015.12.001. url: https: //linkinghub.elsevier.com/retrieve/pii/S2214635016000101 (visited on 12/04/2019). Holt, Charles A and Susan K Laury (Nov. 2002). “Risk Aversion and Incentive Effects”. In: American Economic Review 92.5, pp. 1644–1655. issn: 0002-8282. doi: 10.1257/000282802762024700. url: http://pubs.aeaweb.org/doi/10.1257/000282802762024700 (visited on 12/04/2019). 11