Sunteți pe pagina 1din 184

AACPI, 2020

Analiza Deciziei Întreprinderii

(folosind elemente de Economie Comportamentală)

Anamaria Aldea

Levida Beșir, Alexandru Coșer,

Contacte: anamaria.aldea@csie.ase.ro;

Cursul se desfășoară folosind:

• outline-uri pentru fiecare temă în parte,


• exemple concrete și un studiu experimental se fac direct la ore, după
cartea Thinking fast and slow, D Khaneman (2011),
• articole care însoțesc partea de seminar
Pe parcursul cursului se vor indica articole de referință în domeniu ce
trebuie citite de la o săptămână la alta. Acestea se vor discuta la curs
şi se vor testa cunoștințele asimilate.

Seminariile se desfășoară în R Studio. Este necesară completarea unui


mini-chestionar în timpul semestrului. Acesta are ca scop un experiment de
urmărire a evoluției deciziilor respondenților.

Seminariile intenționează să acopere elemente de tidyverse, dplyr,


Performance Analytics, text mining și sentiment analysis.

Punctaj:

60% examen (scurte întrebări din teorie – înţelegerea conceptelor;


identificarea conceptelor noi în cazuri concerte, întrebări din partea de
seminar, inclusiv din teme, interpretări de outputuri din R, etc.)

40% seminar (activitate seminar şi/sau curs; intervenții, răspunsuri,


soluții, etc evaluarea şi prezentarea temelor de la seminar)

Studentul va trebui să răspundă la câteva întrebări scurte legate de


tema respectivă, modalitatea de lucru şi rezultatele obţinute; rulează
din propriul script.

1
AACPI, 2020
Analiza Deciziei Întreprinderii

(folosind elemente de Economie Comportamentală)

Daniel Kahneman:

https://scholar.princeton.edu/kahneman

Richard Thaler:

http://faculty.chicagobooth.edu/Richard.Thaler/index.html

Deciziile în ziua de azi:

https://www.economist.com/prospero/2012/02/05/can-we-ever-trust-instinct

https://www.vanityfair.com/news/2011/12/michael-lewis-201112#

Sugestii:

https://resources.rstudio.com/rstudio-conf-2019

Bibliografie

[1] Bebczuk R. (2003), Asymmetric information in financial markets: introduction


and applications, Cambridge University Press;
[2] Camerer, Colin F., George Loewenstein, and Matthew Rabin, eds., (2003),
Advances in Behavioral Economics. Princeton University Press;
[3] Jehle, G.A, Renh, P. J. (2001), Advanced Microeconomic Theory, Addison
Wesley;
[4] Kahneman, Daniel, and Amos Tversky, eds. (2000), Choices, Values and
Frames, Cambridge University Press;
[5] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux;
[6] Shleifer, Andrei (2000), Inefficient Capital Markets: An Introduction to
Behavioral Finance. Oxford University Press.

2
AACPI, 2020
Analiza Deciziei Întreprinderii

(folosind elemente de Economie Comportamentală)

Referinţe seminar:

R http://www.r-project.org/ folosit la seminar;

RStudio: https://www.rstudio.com/

R by example - http://www.mayin.org/ajayshah/KB/R/index.html;

Programming in R -
http://manuals.bioinformatics.ucr.edu/home/programming-in-r.

http://www.mayin.org/ajayshah/KB/R/index.html

http://www.gardenersown.co.uk/education/lectures/r/index.htm
Using R for Statistical Analysis

3
Analiza Deciziei Întreprinderii
(Folosind elemente de Economie Comportamentală)

Curs 1

Testarea comportamentelor agenţilor economici pe diferite pieţe, în condiţii


de informaţie perfectă sau imperfectă, a asimetriei infomaţionale
dintre participanţii la diferite tranzacţii economice ridică probleme noi în ceea
ce priveşte abordarea clasică, bazată pe modelare matematică şi/sau cea
care ţine cont de implicarea elementelor de psihologie în Economie.

Ambele abordări vor fi luate în considerare pe parcursul cursului.

1. Noţiuni introductive

Economia Comportamentală (Behavioural Economics) studiază


efectele factorilor

 Sociali =>
 Cognitivi =>
 Emoţionali =>

asupra deciziilor economice ale agenţilor economici (indivizi sau instituţii),


dar şi consecinţele acestor alegeri asupra preţurilor pieţei, rentabilităţilor
investiţiilor şi alocării resurselor.

Economia Comportamentală, dar şi Finanţele Comportamentale – scop


principal: explicarea şi înţelegerea restricţiilor (ipotezelor) de
raţionalitate ale agenţilor economici.

Astfel, modelele comportamentale vor ţine cont de modalitatea de integrare


a psihologiei în teoria economică neoclasică.

Se urmăreşte îmbunătăţirea teoriilor economice clasice prin:

 Crearea de noi abordări teoretice;


 Obţinerea de predicţii mai bune;
 Recomandarea unor politici economice mai bune.

Anamaria Aldea, AACPI, Curs 1 Page 1


Economia Comportamentală NU presupune respingerea abordărilor
economice tradiționale, cum ar fi:
 maximizarea utilităţii aşteptate,
 teoria echilibrului general,
 eficienţa pieţelor.

Teoria economică neoclasică necesită ca preferinţele indivizilor să fie


complete şi tranzitive.

? Relațiile de preferință. Tipuri. Proprietăți.

Economia Comportamentală este o extensie a acestor ipoteze, asemenea


altor domenii:
 Dacă se relaxează condiţia de competiţie perfectă - apare Organizarea
Industrială (Industrial Organisation);
 Dacă se relaxează condiţia de informaţie perfectă – apare Economia
Informaţiei (Information Economics);
 Dacă se relaxează condiţia de raţionalitate perfectă – apare Economia
Comportamentală (Behavioural Economics).

George Stigler (Economic Theory of Regulation, Nobel-1982) afirma că


teoriile economice trebuie să fie analizate prin prisma a trei criterii:
1) Legătura cu ceea ce se întâmplă în realitate;
2) Capacitatea de generalizare;
3) Maleabilitatea.

Economia Comportamentală îmbunătăţeşte criteriul (1), în detrimentul


criteriului (3).

Contrar părerii conform căreia încorporând în analiză comportamentul


iraţional al unui individ se poate întâmpla “orice”, Economia
Comportamentală permite obţinerea de predicţii chiar mai bune decât în
cazul teoriilor economice clasice.

Anamaria Aldea, AACPI, Curs 1 Page 2


Exemplu: Comparaţie Standard Economics – Behavioural Economics:

Standard Economics:

What a piece of work is a man!


How noble in reason! How infinite in faculty!
In form and moving, how express and admirable!
In action how like an angel!
In apprehension how like a god!
William Shakespeare (Hamlet, Act II, scene 2)

Behavioural Economics:

What a piece of work is a man!


How noble in reason! How infinite in faculty!
In form and moving, how express and admirable!
In action how like an angel!
In apprehension how like a god!

William Shakespeare (Hamlet, Act II, Scene 2)

“I call it theory-induced blindness: once you have accepted a theory and


used it as a tool in your thinking, it is extraordinarily difficult to notice its
flaws. If you come upon an observation that does not seem to fit the model,
you assume that there must be a perfectly good explanation that you are
somehow missing.”
― Daniel Kahneman, Thinking, Fast and Slow

“The first misconception is that it is possible to avoid influencing people’s


choices.”
― Richard H. Thaler, Nudge: Improving Decisions About Health, Wealth,
and Happiness

Anamaria Aldea, AACPI, Curs 1 Page 3


“As cognitive scientists have emphasized in recent years, cognition is
embodied; you think with your body, not only with your brain.”
― Daniel Kahneman, Thinking, Fast and Slow

2. Riscul, incertitudinea şi preferinţele în procesul de luarea a


deciziei

2.1. Istoric şi concepte de bază

Punctul de plecare al Teoriei Economice Neoclasice: 1783 - Daniel


Bernoulli - noţiunile de utilitatea aşteptată şi de utilitate marginală.

Noţiunea de utilitate aşteptată presupunea descompunerea evaluării făcute situaţiei


riscante în sumă de utilităţi ale rezultatelor, ponderate cu probabilităţile de obţinere a acestor
rezultate. Iniţial această teorie nu a fost acceptată deoarece:
 Se considera că agenţii economici raţionali nu ar trebui să-şi maximizeze neapărat
utilitatea aşteptată;
 De asemenea, se considera că o Utilitate marginală descrescătoare ar duce la o
creştere mai mică a utilităţii în caz de câştig decât la o scădere a acesteia în caz de
pierdere.

Recapitulare:
Modelul economic al comportamentului consumatorului presupune că toţi cumpărătorii
vor alege să cumpere combinaţia de bunuri şi servicii care le permite acestora să obţină cea mai
bună satisfacţie posibilă dintre toate combinaţiile pe care aceştia şi le permit!
Utilitatea este satisfacţia pe care oamenii o obţin în urma consumului de bunuri şi/sau
servicii.

Daniel Bernoulli a revoluţionat ştiinţa economică prin două mari idei:


 Mai întâi, a considerat că utilitatea pe care oamenii o obţin din bogăţie, u (w) , nu
este liniară în raport cu bogăţia (w) ci este crescătoare, cu o rată de creştere
descrescătoare - idee ce a primit numele de ”utilitate marginală descrescătoare”:
U ' (w)  0, U "(w)  0 .
 Apoi, el a apreciat că o persoană nu evaluează o situaţie riscantă prin
rezultatul aşteptat al unei situaţii ci prin utilitatea aşteptată din acea situaţie.

Conceptele de risc şi incertitudine au o istorie destul de recentă în


teoria economică.

Anamaria Aldea, AACPI, Curs 1 Page 4


În 1921, Frank H. Knight a fost primul care a făcut distincţia dintre
„risc” şi „incertitudine”, în lucrarea “Risk, Uncertainty and Profit”.
Acesta a fost cel care a prezentat pentru prima dată rolul acestor
concepte în economie, subliniind dependenţa profitului de risc şi
incertitudine.

Apoi, aceşti termeni au fost folosiţi în teoria economică de către John


von Neumann şi Oskar Morgenstern în 1944, atunci când şi-au publicat
lucrarea “Theory of Games and Economic Behavior”, şi au pus bazele teoriei
adoptării deciziilor în condiţii de risc şi incertitudine, conform utilităţii
aşteptate.

John Hicks sau John Keynes - au folosit noţiunile de risc şi


incertitudine pentru a explica:
profitul, flexibilitatea producţiei,
decizia de investiţii, cererea de lichidităţi, etc.
mărimea şi structura firmelor,

După teoria utilităţii aşteptate, cu probabilităţi obiective a lui von Neumann şi


Morgenstern (1944), teorie care se referă la “risc”, a apărut şi abordarea bazată pe stările
naturii preferate a lui Arrow (1953) şi Debreu (1959), în care nu se folosesc deloc probabilităţi
şi care se încadrează în “incertitudine”.

Teoria intermediară, cea a lui Savage (1954), care conduce la o utilitate aşteptată cu
probabilităţi subiective, nu se poate încadra într-o categorie sau alta deoarece alegerea de
probabilităţi, chiar şi subiective, ar arăta că ea se încadrează în categoria “risc”, pe când aceste
probabilităţi sunt doar expresii ale unor idei pe care şi le-a făcut decidentul, intrând astfel în
categoria de “incertitudine”.

2.2. Noţiuni introductive

Incertitudinea: acea situaţie în care fiecare rezultat posibil are asociată o


probabilitate de apariţie a unui eveniment, probabilitate care nu se cunoaşte,
dar care poate fi estimată pe baza cunoştinţelor anterioare, testelor, etc.

Riscul: acea situaţie în care fiecare rezultat posibil este cunoscut cu o


probabilitate care se poate calcula. Nici un rezultat nu se poate să apară cu
certitudine.
 Fiecărui rezultat îi este asociată o probabilitate;
 Legătura dintre probabilitatea de apariţie şi evenimentul respectiv este
dată de distribuţia de probabilitate (Întrebare: ce distribuţii de
probabilitate cunoașteți?)
 Rezultatele pot fi exprimate sub forma unei variabile aleatoare.

Anamaria Aldea, AACPI, Curs 1 Page 5


Pentru estimarea atitudinilor agenţilor faţă de risc, se propune fiecărei
persoane alegerea între mai multe loterii (exp: portofolii pe piaţa de capital),
urmând ca aceştia să le ierarhizeze conform propriilor dorinţe.

2.3. Loterii

Loteriile au stat la baza teoriei utilităţii aşteptate.

Definiţia 1.
Fie x un rezultat posibil şi X - mulţimea acestor rezultate posibile. Fie apoi, p
probabilitatea asociată mulţimii X, astfel încât p   p( x1 ), p( x2 ),..., p( xn ) , unde
p( xi ) este probabilitatea ca rezultatul xi  X să aibă loc, deci p( xi )  0 pentru
n
i=1,…,n şi  p( x )  1 .
i 1
i

Se defineşte (X ) ca fiind mulţimea probabilităţilor asociate


rezultatelor din X. O loterie oarecare p este un punct din (X ) .

O loterie simplă poate fi reprezentată sub forma unei variabile aleatoare:


 x1 x2 ,.........., xn 
L 
 p( x1 ), p( x2 ),..., p( xn ) 
Pentru fiecare loterie simplă se calculează valoarea aşteptată a loteriei:
n
E ( L)   p( xi )  xi , care reprezintă rezultatul aşteptat din investiţia în
i 1

respectiva loterie.

Exemplu: În momentul în care investeşte pe bursă, un investitor ce are la dispoziţie 2000 euro
alege 4 acţiuni (SIF1, TLV, BRD, Petrom). Cum aţi investi aceşti bani în cele 4 acţiuni? În ce
proporţie? În ce ordine? Comparaţi apoi cu rentabilitatea zilnică a fiecărui titlu.

Se pune problema modului în care un agent economic evaluează o


loterie compusă, aceasta fiind o loterie care, în locul unui rezultat, dă drept
de acces la o altă loterie.
O modalitate de evaluare a unei astfel de loterii este de a o reduce la
loterii simple prin combinarea probabilităţilor acestora astfel încât să se
obţină o unică distribuţie a rezultatelor.

Anamaria Aldea, AACPI, Curs 1 Page 6


Definiţia 2. În general, o loterie compusă este o mulţime de K loterii simple,
K
pk kK1 , cărora le corespund probablităţile  k kK1 , unde  k  1 , astfel încât se
k 1

poate spune că se va obţine loteria p k , cu probabilitatea  k . Astfel, o loterie


compusă va avea forma q  1 p1   2 p2  ...   k pk .

Sau Definiţia 2.
O loterie compusă este formată din k loterii simple L1, ... Lk şi fiecare
loterie se poate obţine cu o probabilitate  j  0
 L1 L2 ..........Lk 
Lcomp   
 1  2 ........... k 
k
Valoarea aşteptată a loteriei compuse este: E ( Lcomp )    j  L j .
j 1

Notând cu pi  0 - probabilitatea ca o loterie Lj să se obţină rezultatul i,


j

loteria compusă se poate reduce la una simplă, în care probabilitatea ca


k
rezultatul i să apară este dată de 
j 1
j  pij .

References:

[1] Bebczuk R. (2003), Asymmetric information in financial markets: introduction and applications,
Cambridge University Press;

[2] Jehle, G.A, Renh, P. J. (2001), Advanced Microeconomic Theory, Addison Wesley;

[3] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University
Press.

Anamaria Aldea, AACPI, Curs 1 Page 7


Curs 3-4, cu exemple la curs

Analiza Deciziei Întreprinderii

(Folosind elemente de Economie Comportamentală)

Obs: cursul este însoțit de exemple.

Puși în situația de a lua decizii de orice fel, omul, atât în plan personal, cât și în calitate de agent economic
va fi definit de multitudinea stărilor și experiențelor sale ce trebuie luate în considerare atunci când
urmărim o analiză corectă a deciziilor luate și (sau) a efectelor acestora.

Astfel, o multitudine de elemente ce provin din psihologie trebuie definite și introduse în modelarea
comportamentului decidentului.

Obiectul acestui curs este dat de introducerea în limbajul curent, economic, a mai multor noțiuni specifice
Behavioral Economics pentru a defini și explica tocmai elementele de bază ale comportamentului uman în
momentul în care decidentul alege o cale de urmat.

(1) Noţiunea de euristică intuitivă: puşi în faţa unei întrebări dificile, răspunsul oferit este, cel mai
des, cel pe care îl dăm unei întrebări simple, fără a observa înlocuirea.

Exemplul 1: Ford [prezentare curs]

Anamaria Aldea, AACPI, octombrie 2020 Page 1


Curs 3-4, cu exemple la curs

1. Concepte de bază ale Teoriei Prospectelor (Prospect Theory)

Tversky şi Kahneman (1973) au introdus conceptul de disponibilitate euristică (2) referitor la


faptul că oamenii au tendința de a estima frecvența sau probabilitatea unui eveniment după ușurința cu
care îşi aduc aminte de el.

Exemplul 2:

Cu cât te bazezi mai mult pe disponibilitatea euristică, cu atât mai multe abateri sistematice (3)
(engl. systematic biases) vor apărea în procesul de decizie.

Exemplu 2’:

Există trei noțiuni folosite în formularea judecăţilor în contextul unui mediu incert şi care reprezintă
concepte de bază ale teoriilor comportamentale aplicate în Economie: [Tversky şi Kahneman (1974)]

✓ puterea de reprezentare (reprezentativitatea) (4) – (engl. representativeness) –


apare atunci când oamenilor li se cere să determine probabilitatea ca un obiect sau un eveniment A
să aparţină unei clase sau unui proces B, iar probabilităţile sunt evaluate prin gradul în care obiectul
A se aseamănă cu mulţimea obiectelor aparţinând clasei sau procesului B.

Anamaria Aldea, AACPI, octombrie 2020 Page 2


Curs 3-4, cu exemple la curs

Puterea de reprezentare este o noţiune întâlnită în studiile psihologice, ea generând stereotipie


deoarece face ca lumea înconjurătoare să pară mai organizată decât este în realitate.
Exemplul 3: Thinking fast and slow, 2011

✓ disponibilitatea (engl. availability) (5) apare atunci când oamenilor li se cere să


determine probabilitatea de apariţie a unui eveniment. Aceştia fac apel la memorie pentru a-şi
aminti dacă şi când s-au mai confruntat cu acel eveniment.

Astfel, dacă un eveniment asemănător cu cel pentru care trebuie să determine o probabilitate de apariţie a
avut loc recent, ei vor stabili o probabilitate de apariţie mai mare decât în cazul în unui eveniment
asemănător care a avut loc cu mai mult timp în urmă. Deci, probabilitatea de apariţie a unui eveniment
este aproximată în funcţie de gradul de uşurinţă cu care subiecţii îşi aduc aminte de un eveniment similar
apărut în trecut.
Exemplul 4: Thinking fast and slow, 2011

Anamaria Aldea, AACPI, octombrie 2020 Page 3


Curs 3-4, cu exemple la curs

✓ ancorare şi ajustare (engl. anchoring and adjustment) (6) – apare în previziunea


numerică atunci când oamenii dispun de o valoare relevantă valabilă (o ancoră).
În această situaţie, persoanele respective fac estimări pornind de la o valoare iniţială pe care ei o
consideră drept ancoră şi pe care o ajustează pentru a obţine rezultatul final. De cele mai multe ori, însă,
ajustările sunt insuficiente.

Kahneman şi Tversky (1979) au dezvoltat teoria prospectului/ prospectelor (prospect theory)


pornind de la ideea că teoria utilităţii aşteptate este una care nu a fost contestată timp de 250 ani, deşi
ridică numeroase puncte de întrebare atunci când vine vorba de momentul de timp în care se face
alegerea!

Exemplul 5: Thinking fast and slow, 2011

Utilitatea depinde ŞI de istoricul evoluţiei bogăţiei (averii) unei persoane, nu doar de valoarea ei actuală.
[Kahneman, 2011 – Thinking, fast and slow]

Anamaria Aldea, AACPI, octombrie 2020 Page 4


Curs 3-4, cu exemple la curs

2. Framings (7) (cadre, tipologii)

Se presupune că o persoană a câştigat 1000$ în urma participării la un concurs. În plus faţă de


aceste câştiguri, acestei persoane i se propune să aleagă între:
A: a câștiga 1000$ cu o probabilitate de 50%;
B: a câştiga 500$ cu certitudine
Se presupune că persoana respectivă a câştigat 2000$ în urma participării la un concurs. În plus
faţă de aceste câştiguri, acestei persoane i se propune să aleagă între:
C: să piardă 1000$ cu o probabilitate de 50%;
D: să piardă 500$ cu certitudine.
Întrebare: care este diferenţa dintre cele două situaţii în cazul teoriei utilității așteptate?

Aceste două loterii sunt identice din punct de vedere al stărilor averii finale şi al probabilităţilor
asociate acestora, dar există o probabilitate mai mare ca decidenţii să aleagă situația cu aversiune la risc,
B şi situaţia cu înclinaţie spre risc, C.

Se observă că oamenii iau decizii ca urmare a schimbărilor în avere şi nu ca urmare a nivelurilor finale ale
averii!
Exemplul 6: Kahneman, 1979, Reflection effect

Anamaria Aldea, AACPI, octombrie 2020 Page 5


Curs 3-4, cu exemple la curs

3. Includerea pierderilor în analiză

How about losses? [Kahneman, 2011 – Thinking, fast and slow]

Exemplul 7: Anthony și Betty [prezentare și discuție la curs]

✓ Conform acestei teorii, ideea de valoare (8) este asociată, de decident, atât pentru pierderi cât şi
pentru câştiguri, şi mai puţin cu valoarea finală a averii acestuia, iar probabilităţile sunt înlocuite cu
ponderi/probabilități decizionale (9) (engl. decision weights).

✓ Punctul de referință (10) reprezintă starea anterioară faţă de care câştigurile şi pierderile sunt
evaluate.

Comparație: Conform teoriei utilității aşteptate este nevoie să cunoaştem doar starea prezentă a averii
pentru a determina utilitatea acesteia, dar, în teoria prospectelor, trebuie să cunoaştem şi punctul de
referinţă.

Anamaria Aldea, AACPI, octombrie 2020 Page 6


Curs 3-4, cu exemple la curs

Pe scurt!
Funcţia valoare este definită pe baza abaterilor faţă de un punct de
referinţă şi este concavă pentru câştiguri (implicând aversiune la risc),
convexă pentru pierderi (căutarea riscului) şi este mai abruptă, în
general, pentru pierderi decât pentru câştiguri (aversiunea faţă de
pierdere). Probabilităţile deciziilor sunt, în general, mai mici decât
probabilităţile corespondente, cu excepţia intervalului de probabilităţi
mici.

Observăm următoarele aspecte importante:

1) se analizează o situaţie care, până acum nu exista în teoria economică clasică: deosebirea dintre
atitudinea faţă de CÂŞTIGURI şi atitudinea faţă de PIERDERI!
2) aceste atitudini variază în funcţie de un punct de referinţă diferit de la un individ la altul, dar si diferit
în timp pentru acelaşi individ.

Exemplul 8:

Anamaria Aldea, AACPI, octombrie 2020 Page 7


Curs 3-4, cu exemple la curs

Cele 3 principii de bază ale teoriei prospectelor sunt [Kahneman, 2011 – Thinking, fast and slow]:

Principiul 1. Evaluarea se face faţă de un punct de referinţă neutru.

Exemplu P1: apa în 3 vase, [Kahneman, 2012 – Thinking, fast and slow] [prezentare şi discuţie la
curs]

În această situaţie, rezultatele care sunt mai bune faţă de punctul de referinţă reprezintă câştiguri,
iar cele care se află sub acest punct de referinţă reprezintă pierderi.

Principiul 2. Un principiu al senzitivităţii se aplică atât pentru evaluarea modificărilor averii unei
persoane, cât şi pentru dimensiunile senzoriale: modificări succesive ale incrementului au un impact
marginal din ce în ce mai mic.

Exemplu P2: lumina într-o cameră întunecată sau luminoasă

Principiul 3. Al treilea principiu este dat de aversiunea faţă de pierdere (11) (loss aversion).

În experimentul pregătit de Kahneman şi Tversky pentru a testa ipotezele referitoare la atitudinea


diferită pe care oamenii o au faţă de pierdere şi faţă de câştig, subiecţii (de obicei, studenți) au fost puşi
să rezolve o serie de probleme de alegere (de decizie). A rezultat faptul că aceştia au deviat frecvent în
alegerile lor de la maximizarea utilităţii aşteptate.

Anamaria Aldea, AACPI, octombrie 2020 Page 8


Curs 3-4, cu exemple la curs

Rezultatul 1: De exemplu, subiecţii au evaluat pierderile şi câştigurile într-o manieră asimetrică,


adică în situaţii de câștig au fost adverși față de risc, iar în situaţii de pierdere au fost predispuşi la risc.
Rezultatul 2: De asemenea, experimentele au arătat că indivizii sunt mai sensibili faţă de pierderi
comparativ cu atitudinea lor faţă de câştiguri, iar aversiunea faţă de pierdere poate explica iluzia banilor.
De exemplu, o scădere a salariului nominal în condiţii de inflaţie zero este mai uşor acceptată decât
exact aceeaşi scădere a salariului real în condiţii de inflaţie. De fapt, pierderea are un impact psihologic de
două ori mai mare faţă de cel corespunzător obţinerii unui câştig.

Concluzie: Mai mult, experimentele au arătat că atitudinea faţă de risc a indivizilor are mai multe
dimensiuni:
1) Astfel, atitudinea faţă de risc a unei persoane depinde de evenimentele recente.

2) După o experienţă soldată cu o pierdere financiară, oamenii devin mai puţin dispuşi să-şi

asume riscuri.

3) După câteva perioade succesive de câştig, aversiunea faţă de risc scade.

Anamaria Aldea, AACPI, octombrie 2020 Page 9


Curs 3-4, cu exemple la curs

4. Funcţia valoare

O funcţie valoare simplă poate fi descrisă conform teoriei prospectului, astfel:

v( x) = x a , x  0;
v( x) = − (− x)b , x  0.
unde v (sau u) este valoarea psihologică pe care individul o atribuie situaţiei x. Din cercetările
experimentale se pare că valoarea lui  este de aproximativ 2.25, iar a şi b sunt ambele de 0.88
(Tversky şi Kahneman, 1992).
Grafic 1. Reprezentarea grafică a funcţiei valoare

Sursa: Prast, H., Investor Psychology: A Behavioural Explanation of Six Finance Puzzle, Research Series Supervision, no. 64, February 2004.

Anamaria Aldea, AACPI, octombrie 2020 Page 10


Curs 3-4, cu exemple la curs

Observaţie: Articolul original, în care s-a definit funcţia valoare


http://ideas.repec.org/a/ecm/emetrp/v47y1979i2p263-91.html

References:

[1] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux

[2] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University Press.

[3] Kahneman, D. and A. Tversky (1979), Prospect Theory: An Analysis of Decision under Risk, Econometrica, Vol. 47, No. 2, pp. 263-292

Anamaria Aldea, AACPI, octombrie 2020 Page 11


Curs 3-4, Exemplul 6

Conf. Dr. Anamaria Aldea

Exemplu bazat pe: Kahneman and Tversky, ’79, Econometrica

Fiecare problemă reprezintă o alegere ce va ilustra un anumit concept specific Economiei


Comportamentale.

I. Rezolvăm fiecare problemă şi interpretăm.

Alegeți între următoarele variante și completați în xlsx pe coloana corespunzătoare fiecărei


probleme. Completaţi folosind litere mari (A,B,C, etc.). Ştiţi că sumele folosite reprezintă
câştiguri sau pierderi exprimate în lei.

Pb1. Alegeți între

A: 2500 cu probabilitatea 0.33 B: 2400 cu certitudine

2400 cu probabilitatea 0.66

0 cu probabilitatea 0.01

Pb2. Alegeți între:

C: 2500 cu probabilitatea 0.33 D: 2400 cu probabilitatea 0.34

0 cu probabilitatea 0.67 0 cu probabilitatea 0.66

Pb3. Alegeți între: (loteriile sunt scrise pe linie!)

A1: (4000, 0.80; 0, 0.20) B1: 3000 cu certitudine

Pb4:

C1: (4000, 0.20; 0, 0.80) D1: (3000, 0.25; 0, 0.75)

Pb5:

D: aveți 50% șanse să câștigați o excursie de 3 săptămâni în UK, Franța, Italia

E: câștigați o excursie de o săptămână în UK cu certitudine

1
Pb6:

D1: aveți 5% șanse să câștigați o excursie de 3 săptămâni în UK, Franța, Italia

E1: aveți 10% șanse să câștigați o excursie de o săptămână în UK

Pb7:

F: (6000, 0.45; 0, 0.55) G: (3000, 0.9; 0, 0.1)

Pb8:

F1: (6000, 0.001; 0, 999) G1: (3000, 0.02; 0, 0.998)

II. Preluați xlsx-ul în R și analizaţi toate răspunsurile furnizate.

2
Analiza Deciziei Întreprinderii

(Folosind elemente de Economie Comportamentală)

Cursurile 5 – 6

(Continuare cursul trecut)

Determinarea funcţiei valoare (cf. Kahneman-Tversky, Econometrica, 79)

1. Fazele procesului decizional în teoria prospectelor


Un element important al teoriei prospectelor este reprezentat de ideea că
ponderile asociate veniturilor posibile de către decidenţi nu corespund
probabilităţilor reale ca aceste venituri să fie obţinute.
Conform teoriei prospectelor, procesul luării unei decizii are două faze şi
utilitatea unui prospect, reprezentată de combinaţia (x1, p1; … ;xn, pn) este
evaluată şi ea în două faze distincte: o fază de editare şi o fază de evaluare.
În primul stadiu al procesului decizional (faza de editare), oamenii îşi
schiţează perspectivele în termeni de câștiguri (gains) şi pierderi (losses) în
funcție de un reper (punct de referinţă). În acest sens, aceştia aplică regula
euristică ce facilitează interpretarea diferitelor posibilităţi dintre care trebuie
să aleagă.

În al doilea stadiu al procesului decizional (faza de evaluare) are loc


evaluarea în urma căreia se alege perspectiva (investiţională) cu valoarea
cea mai mare.

Faza de editare, la rândul ei, are 4 componente principale:

1) Codificarea – în această fază oamenii percep rezultatele ca fiind fie


câştiguri, fie pierderi, relativ la un punct de referinţă neutru. Punctul
de referinţă corespunde, de obicei, poziţiei curente a activului – pe
piaţa de capital, dar poate fi şi o anumită valoare aşteptată a
decidentului sau un status quo;

Anamaria Aldea, AACPI, noiembrie 2020 Page 1


2) Combinarea – prospectele pot fi simplificate prin combinarea
probabilităţilor pentru rezultate identice. De exemplu: (200, 0.25; 200,
0.25) va deveni (200, 0.50);

3) Separarea – componentele fără risc sunt separate de componentele


riscante. De exemplu: în cazul loteriei (300, 0.80; 200, 0.20) se poate
gândi că aceasta are un echivalent cert de reprezentate de cei 200$ ce
se pot obţine în fiecare caz, la care se poate adăuga o loterie din care
se câştigă 100$ cu 0.8.

4) Ştergerea – componentele care sunt comune celor două prospecte nu


sunt luate în considerare. În exemplul de la “framing” [vezi cursul
trecut], cei 1000$ apar în ambele loterii şi vor fi ignoraţi.

2. Funcţia de ponderi decizionale

Puşi în faţa conceptului de probabilitate, s-a observat că oamenii percep


această noţiune diferit. De fapt, în realitate, ei pot supra sau sub-evalua
valoarea probabilităţii, în funcţie de experienţa proprie.

Fie o loterie cu două rezultate:

✓ x cu probabilitatea p şi

✓ y cu probabilitatea 1-p, unde x  0  y .

De fapt, x reprezintă câștigul (gain) şi y reprezintă pierderea (loss).

Teoria utilităţii aşteptate (EU) stabileşte că, dacă o persoană porneşte de la


o avere iniţială W>0, atunci utilitatea aşteptată a loteriei va fi:

EU ( L) = pU (W + x ) + (1 − p )U (W + y ) (1)

Teoria prospectelor generalizează principiul anticipărilor, prin care oamenii


transferă propriile aşteptări asupra probabilităţii ca un eveniment să se
producă. În această situaţie, aceştia nu stabilesc probabilităţi fixe

Anamaria Aldea, AACPI, noiembrie 2020 Page 2


evenimentelor, ci ataşează o pondere decizională,  ( p) , fiecărei

probabilități în parte.

În momentul în care oamenii nu cunosc probabilităţile asociate


evenimentelor, atunci se spune că aceştia se confruntă cu situaţii proprii
fenomenului de ambiguitate (ambiguity). Acesta fenomen scade atunci
când oamenii sunt familiari cu situaţiile în care sunt puşi să facă alegeri.

De exemplu: deosebirea dintre semnificaţia indicilor bursieri pentru


investitorii profesionişti şi pentru cei care sunt începători.

Astfel, Teoria prospectelor (PT) stabileşte că valoarea loteriei va fi:

EU ( L) =  ( p )U ( x) +  (1 − p)U ( y ) , (2)

unde  ( p ) este o funcție de ponderi decizionale.

În teoria standard,  este o funcție liniară.

După ce diferitele perspective (investiţionale) au fost enunţate şi încadrate la


câştiguri şi pierderi, acestea sunt evaluate şi se alege prospectul cu valoarea
cea mai mare. Regulile de aproximare utilizate în cele două faze reprezintă
un exemplu de simplificare.

Astfel, probabilităţile sau veniturile sunt rotunjite, iar veniturile cu


probabilităţi reduse de a se realiza sunt eliminate. Rezultă că sumele
ponderate, pe baza cărora se iau deciziile, sunt funcţii neliniare de
probabilităţi.

În teoria prospectelor,  este o funcţie concavă la început şi apoi convexă.

Kahneman-Tversky (1979) au definit funcţia de ponderi decizionale pe


intervalul [0,1], aceasta este continuă şi convexă pe (0,1) şi se află

Anamaria Aldea, AACPI, noiembrie 2020 Page 3


deasupra primei bisectoare în vecinătatea lui 0 şi sub prima bisectoare pe
cea mai mare parte a intervalului.

O funcţie de ponderi decizionale poate lua forma:

p
 ( p) = ,   ( 0,1) . (3)
p + (1 − p)

Se va reprezenta grafic funcţia respectivă pentru un  = 0.7 .

Grafic 1. Reprezentare generală a funcţiei  ( p )

Funcţia de ponderi decizionale are următoarele proprietăţi:

1) Supraevaluarea probabilităţilor mici: pentru orice p  p* , se obţin

ponderi decizionale mai mari,  ( p )  p ;

Anamaria Aldea, AACPI, noiembrie 2020 Page 4


De exemplu: este mai probabil ca persoanele sărace sau mai puţin
educate să joace la loto, deşi probabilitatea de câştig este foarte mică.
În acest caz, apare situaţia de aversiune extremă faţă de risc
(extreme risk aversion).
2) Subevaluarea probabilităţilor mari: pentru orice p  p* , se obţin

ponderi decizionale mai mici,  ( p )  p , constatându-se că, în realitate,

avem tendinţa de a subevalua probabilităţile mari, nepercepându-le ca


fiind pe deplin posibile;
3)  ( p ) = p în jur de 0.30 şi 0.35 şi estimările iau valori între 0.20 şi 0.40;

4) Este discontinuă la capete:  ( 0 ) = 0 şi  (1) = 1 . Această proprietate se

datorează supraevaluării pentru valori mici ale lui p şi subevaluării


pentru valori mari ale lui p.
În aplicaţiile economice, cel mai des se folosește  ( p ) = p , cu excepția

loteriilor şi a asigurărilor.

O altă formă a funcţiei de ponderi decizionale poate fi:



p
 ( p) = ,   ( 0,1 . (4)
(p )
1
  
+ (1 − p)

Valorile mici ale lui  conduc la o formă S mai accentuată a funcţiei.

Anamaria Aldea, AACPI, noiembrie 2020 Page 5


Grafic 2. Reprezentare generală a funcției  ( p )

Astfel, pentru valori mici ale lui p, se observă că (p) > p, unde p este
probabilitatea de realizare a unui eveniment şi (p) este ponderea
corespunzătoare din funcţia de decizie.
Prin urmare, după ce individul a depăşit de cele două faze decizionale,
acesta alege prospectul cu valoare maximă:

 ( p ) v ( x )
i
i i (5)

Întrebare: Care sunt principalele diferenţe între cele două modalităţi de a


calcula funcțiile de ponderi decizionale?

Exercițiu: reprezentați grafic funcțiile de pondere decizionale pentru valori


succesive ale parametrului γ. De exemplu: 𝛾𝜖{0.25, 0.5, 0.75, 0.9, 1}

Anamaria Aldea, AACPI, noiembrie 2020 Page 6


References:

[1] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University
Press.
[2] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux
[3] Kahneman, D. and A. Tversky (1979), Prospect Theory: An Analysis of Decision under Risk,
Econometrica, Vol. 47, No. 2, pp. 263-292
[4] Shefrin, H. (2008), A Behavioral Approach to Asset Pricing, Elsevier, 2nd Edition.

Anamaria Aldea, AACPI, noiembrie 2020 Page 7


Analiza Deciziei Întreprinderii

(Folosind elemente de Economie Comportamentală)

Cursurile 5 – 6

(Continuare cursul trecut)

Determinarea funcţiei valoare (cf. Kahneman-Tversky, Econometrica, 79)

1. Fazele procesului decizional în teoria prospectelor


Un element important al teoriei prospectelor este reprezentat de ideea că
ponderile asociate veniturilor posibile de către decidenţi nu corespund
probabilităţilor reale ca aceste venituri să fie obţinute.
Conform teoriei prospectelor, procesul luării unei decizii are două faze şi
utilitatea unui prospect, reprezentată de combinaţia (x1, p1; … ;xn, pn) este
evaluată şi ea în două faze distincte: o fază de editare şi o fază de evaluare.
În primul stadiu al procesului decizional (faza de editare), oamenii îşi
schiţează perspectivele în termeni de câștiguri (gains) şi pierderi (losses) în
funcție de un reper (punct de referinţă). În acest sens, aceştia aplică regula
euristică ce facilitează interpretarea diferitelor posibilităţi dintre care trebuie
să aleagă.

În al doilea stadiu al procesului decizional (faza de evaluare) are loc


evaluarea în urma căreia se alege perspectiva (investiţională) cu valoarea
cea mai mare.

Faza de editare, la rândul ei, are 4 componente principale:

1) Codificarea – în această fază oamenii percep rezultatele ca fiind fie


câştiguri, fie pierderi, relativ la un punct de referinţă neutru. Punctul
de referinţă corespunde, de obicei, poziţiei curente a activului – pe
piaţa de capital, dar poate fi şi o anumită valoare aşteptată a
decidentului sau un status quo;

Anamaria Aldea, AACPI, noiembrie 2020 Page 1


2) Combinarea – prospectele pot fi simplificate prin combinarea
probabilităţilor pentru rezultate identice. De exemplu: (200, 0.25; 200,
0.25) va deveni (200, 0.50);

3) Separarea – componentele fără risc sunt separate de componentele


riscante. De exemplu: în cazul loteriei (300, 0.80; 200, 0.20) se poate
gândi că aceasta are un echivalent cert de reprezentate de cei 200$ ce
se pot obţine în fiecare caz, la care se poate adăuga o loterie din care
se câştigă 100$ cu 0.8.

4) Ştergerea – componentele care sunt comune celor două prospecte nu


sunt luate în considerare. În exemplul de la “framing” [vezi cursul
trecut], cei 1000$ apar în ambele loterii şi vor fi ignoraţi.

2. Funcţia de ponderi decizionale

Puşi în faţa conceptului de probabilitate, s-a observat că oamenii percep


această noţiune diferit. De fapt, în realitate, ei pot supra sau sub-evalua
valoarea probabilităţii, în funcţie de experienţa proprie.

Fie o loterie cu două rezultate:

✓ x cu probabilitatea p şi

✓ y cu probabilitatea 1-p, unde x  0  y .

De fapt, x reprezintă câștigul (gain) şi y reprezintă pierderea (loss).

Teoria utilităţii aşteptate (EU) stabileşte că, dacă o persoană porneşte de la


o avere iniţială W>0, atunci utilitatea aşteptată a loteriei va fi:

EU ( L) = pU (W + x ) + (1 − p )U (W + y ) (1)

Teoria prospectelor generalizează principiul anticipărilor, prin care oamenii


transferă propriile aşteptări asupra probabilităţii ca un eveniment să se
producă. În această situaţie, aceştia nu stabilesc probabilităţi fixe

Anamaria Aldea, AACPI, noiembrie 2020 Page 2


evenimentelor, ci ataşează o pondere decizională,  ( p) , fiecărei

probabilități în parte.

În momentul în care oamenii nu cunosc probabilităţile asociate


evenimentelor, atunci se spune că aceştia se confruntă cu situaţii proprii
fenomenului de ambiguitate (ambiguity). Acesta fenomen scade atunci
când oamenii sunt familiari cu situaţiile în care sunt puşi să facă alegeri.

De exemplu: deosebirea dintre semnificaţia indicilor bursieri pentru


investitorii profesionişti şi pentru cei care sunt începători.

Astfel, Teoria prospectelor (PT) stabileşte că valoarea loteriei va fi:

EU ( L) =  ( p )U ( x) +  (1 − p)U ( y ) , (2)

unde  ( p ) este o funcție de ponderi decizionale.

În teoria standard,  este o funcție liniară.

După ce diferitele perspective (investiţionale) au fost enunţate şi încadrate la


câştiguri şi pierderi, acestea sunt evaluate şi se alege prospectul cu valoarea
cea mai mare. Regulile de aproximare utilizate în cele două faze reprezintă
un exemplu de simplificare.

Astfel, probabilităţile sau veniturile sunt rotunjite, iar veniturile cu


probabilităţi reduse de a se realiza sunt eliminate. Rezultă că sumele
ponderate, pe baza cărora se iau deciziile, sunt funcţii neliniare de
probabilităţi.

În teoria prospectelor,  este o funcţie concavă la început şi apoi convexă.

Kahneman-Tversky (1979) au definit funcţia de ponderi decizionale pe


intervalul [0,1], aceasta este continuă şi convexă pe (0,1) şi se află

Anamaria Aldea, AACPI, noiembrie 2020 Page 3


deasupra primei bisectoare în vecinătatea lui 0 şi sub prima bisectoare pe
cea mai mare parte a intervalului.

O funcţie de ponderi decizionale poate lua forma:

p
 ( p) = ,   ( 0,1) . (3)
p + (1 − p)

Se va reprezenta grafic funcţia respectivă pentru un  = 0.7 .

Grafic 1. Reprezentare generală a funcţiei  ( p )

Funcţia de ponderi decizionale are următoarele proprietăţi:

1) Supraevaluarea probabilităţilor mici: pentru orice p  p* , se obţin

ponderi decizionale mai mari,  ( p )  p ;

Anamaria Aldea, AACPI, noiembrie 2020 Page 4


De exemplu: este mai probabil ca persoanele sărace sau mai puţin
educate să joace la loto, deşi probabilitatea de câştig este foarte mică.
În acest caz, apare situaţia de aversiune extremă faţă de risc
(extreme risk aversion).
2) Subevaluarea probabilităţilor mari: pentru orice p  p* , se obţin

ponderi decizionale mai mici,  ( p )  p , constatându-se că, în realitate,

avem tendinţa de a subevalua probabilităţile mari, nepercepându-le ca


fiind pe deplin posibile;
3)  ( p ) = p în jur de 0.30 şi 0.35 şi estimările iau valori între 0.20 şi 0.40;

4) Este discontinuă la capete:  ( 0 ) = 0 şi  (1) = 1 . Această proprietate se

datorează supraevaluării pentru valori mici ale lui p şi subevaluării


pentru valori mari ale lui p.
În aplicaţiile economice, cel mai des se folosește  ( p ) = p , cu excepția

loteriilor şi a asigurărilor.

O altă formă a funcţiei de ponderi decizionale poate fi:



p
 ( p) = ,   ( 0,1 . (4)
(p )
1
  
+ (1 − p)

Valorile mici ale lui  conduc la o formă S mai accentuată a funcţiei.

Anamaria Aldea, AACPI, noiembrie 2020 Page 5


Grafic 2. Reprezentare generală a funcției  ( p )

Astfel, pentru valori mici ale lui p, se observă că (p) > p, unde p este
probabilitatea de realizare a unui eveniment şi (p) este ponderea
corespunzătoare din funcţia de decizie.
Prin urmare, după ce individul a depăşit de cele două faze decizionale,
acesta alege prospectul cu valoare maximă:

 ( p ) v ( x )
i
i i (5)

Întrebare: Care sunt principalele diferenţe între cele două modalităţi de a


calcula funcțiile de ponderi decizionale?

Exercițiu: reprezentați grafic funcțiile de pondere decizionale pentru valori


succesive ale parametrului γ. De exemplu: 𝛾𝜖{0.25, 0.5, 0.75, 0.9, 1}

Anamaria Aldea, AACPI, noiembrie 2020 Page 6


References:

[1] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University
Press.
[2] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux
[3] Kahneman, D. and A. Tversky (1979), Prospect Theory: An Analysis of Decision under Risk,
Econometrica, Vol. 47, No. 2, pp. 263-292
[4] Shefrin, H. (2008), A Behavioral Approach to Asset Pricing, Elsevier, 2nd Edition.

Anamaria Aldea, AACPI, noiembrie 2020 Page 7


Analiza Deciziei Întreprinderii
(Folosind elemente de Economie Comportamentală)

Curs 7-8

Notă:
Curs 8 însoțit de testarea unui experiment.

Funcția de ponderi decizionale și funcția valoare – completare

1. Proprietatea de sub-certitudine

Proprietatea de sub-certitudine: În această situație, în care oamenii nu


cunosc probabilitățile obiective, ei vor folosi ponderi asemănătoare
probabilităților subiective. Prin urmare, ei acordă fiecărei probabilități o
pondere decizională fie pe baza experienței, fie bazându-se pe memoria
ultimului eveniment asemănător din viața lor.

Dar, suma acestor ponderi decizionale NU trebuie să fie 1! De exemplu:


0   ( p ) +  (1 − p )  1 .

Astfel, proprietatea de sub-certitudine surprinde un element esențial al


atitudinii indivizilor față de incertitudine: suma ponderilor asociate
evenimentelor complementare este, de obicei, mai mică decât ponderea
asociată evenimentului cert. [Kahneman and Tversky (2000) – Choices,
values and frames]

Exemplu important pentru ilustrarea principiului sub-certitudinii [vezi cursul]

Anamaria Aldea, AACPI, noiembrie 2020 Page 1


2. Legătura funcție valoare – funcție de ponderi decizionale
(interpretări – Shefrin, 2008)
Din forma funcției de valoare știm că oamenii sunt adverși la risc
atunci când vine vorba de câștiguri și înclinați spre risc atunci când trebuie
să facă față pierderilor.
Khaneman-Tversky (1979) afirmă că supraevaluarea probabilităților
mici este proprietatea care poate genera și situații de aversiune față de risc
în cazul pierderilor și înclinație spre risc în cazul câștigurilor. De exemplu:
✓ în primul caz: oamenii sunt dispuși să plătească prime de risc mari
pentru a se asigura împotriva evenimentelor cu probabilități mici de
apariție, cum ar fi prăbușirea avioanelor;
✓ în al doilea caz: oamenii sunt dispuși să plătească sume mari pentru a
achiziționa bilete la loto.
Observație: aceste comportamente sunt opuse celor evidențiate de
forma funcției valoare.
Khaneman şi Tversky afirmă că principiul ce stă la baza formelor celor
două funcții are la bază principiul psiho-fizicii (psychophysics), care
arată că, dintr-un anumit punct de referință al evaluării averii unui individ,
senzitivitatea (reacția) acestuia față de modificarea averii sale este
descrescătoare. Khaneman a folosit acest principiu al senzitivităţii (al psiho-
fizicii) pentru a arăta că, în anumite condiții, oamenii greșesc în percepția pe
care au cu privire la stimulii obiectivi.
Astfel, în cazul funcției valoare, o persoană este mult mai puțin
sensibilă față de câștigurile marginale, în timp ce câștigul total crește în
raport cu punctul său de referință din acel moment (concavitatea funcției
valoare în zona de câștiguri). De asemenea, aceeași persoană poate să
devină mai puțin sensibilă față de pierderile marginale pe măsură ce

Anamaria Aldea, AACPI, noiembrie 2020 Page 2


valoarea totală a pierderii crește, în valoare absolută, față de un punct de
referință (convexitatea funcției valoare în zona pierderilor).
În cazul funcției de ponderi decizionale, există două puncte de
referință, 0 și 1, ce corespund cazurilor de certitudine. Porțiunea concavă a
funcției în formă de S-invers caracterizează sensitivitatea descrescătoare
față de creșteri în probabilitate pe măsură ce probabilitatea crește față de 0.
Porțiunea convexă a funcției în formă de S-invers caracterizează
sensitivitatea descrescătoare față de scăderi în probabilitate pe măsură ce
probabilitatea descrește față de 1.

3. Conceptul de contabilitate mentală (mental accounting)

Teoria prospectului arată că oamenii folosesc o altă proprietate


interesantă atunci când trebuie să dea un sens pierderilor și câștigurilor.
Atunci când trebuie să ia decizii ce se pot solda cu pierderi mai mari sau mai
mici (mai ales de ordin financiar), oamenii apelează la proprietatea de
contabilitate mentală. Pin aceasta se înțelege faptul că ei au tendința de a
clasifica diferitele probleme de decizii (inclusiv financiare) cu care se
confruntă în conturi mentale separate: pierderile sunt percepute ca pierderi
și câștigurile ca și câștiguri, dar se ignoră complet faptul că ar fi rațional să
se integreze aceste alternative într-un “portofoliu” mental, în care o pierdere
să fie contrabalansată de un potențial câștig.
De fapt, deciziile luate sunt aplicate fiecărui cont „mental” în parte,
ignorând orice altă posibilă combinație. Acest concept explică, astfel, de ce
oamenii cumpără bilete la loto, dar în același timp renunță la asigurări de
viață sau de ce oamenii caută riscul investind la bursă și apoi doresc să

Anamaria Aldea, AACPI, noiembrie 2020 Page 3


realizeze operațiuni de hedging pentru diversificarea acestuia (Friedman şi
Savage, 1948).
Un exemplu în acest sens este dat chiar de către investitorii la bursă,
care au conturi mentale separate, câte unul pentru fiecare investiție: unul
pentru acoperirea riscurilor de depreciere – pentru care se utilizează
instrumente cum ar fi obligațiunile – și unul pentru a beneficia de potențialul
de apreciere, pentru care folosesc acțiuni. Deși teoria portofoliilor prevede că
ar fi optim să se combine aceste instrumente, în realitate, oamenii gândesc
diferit.
O motivație a acestui comportament ar putea fi dată de faptul că
investitorii doresc să-și exercite autocontrolul. Dacă ar tine conturi separate
pentru diferite categorii de cheltuieli, ar putea fi mai puțin tentați să-și
utilizeze rezerva pentru un impuls de cumpărare oarecare (Thaler şi Shefrin,
1981) și, în momentul în care achiziționează acțiuni noi, ei reacționează prin
“deschiderea” unui nou cont mental (Thaler 1980, Shefrin şi Statman 1985).

4. Aplicații ale teoriei prospectelor: Efectul înzestrării

Teoria Prospectelor a identificat câteva elemente ce completează sau


modifică teoria economică standard. Unul dintre acestea este efectul
înzestrării (endowment effect) care artată cât de important este pentru un
individ faptul că el este cel ce deține un obiect (sau serviciu).

Astfel, prețul, perceput în Teoria Economică clasică sub forma unei


sume de bani ce reprezintă același lucru și pentru cumpărători și pentru
vânzători, devine, în Teoria Prospectelor un element diferit pentru cele două
părți ale unei tranzacții de vânzare-cumpărare.

Anamaria Aldea, AACPI, noiembrie 2020 Page 4


Prin urmare, s-au definit două noi concepte:

Disponibilitatea pe care o are o persoană de a plăti pentru un bun


(willingness to pay – WTP) reprezintă suma maximă de bani la care ar
trebui să renunțe pentru a intra în posesia bunului respectiv.

Disponibilitatea pe care o are o persoană de a accepta un bun


(willingness to accept - WTA) reprezintă suma minimă de bani pe care ar
trebui să o primească pentru a renunța la bunul pe care îl deține.

WTP exprimă cu cât de mulți bani s-ar achiziționa bunul respectiv; WTA
exprimă cu cât s-ar vinde bunul respectiv.

Observație. Conform teoriei economice standard, WTP≈WTA.

❖ În teoria prospectelor, valoarea obținerii bunului și pierderii banilor


(x$) este dată de:

V = U(bun) + U(−x) = A – λx

Aici apare și conceptul de contabilitate mentale deoarece se folosesc


conturi mentale diferite pentru felul în care se evaluează bunurile și bani.

WTP: se renunță la suma în bani, dar se câștigă bunul: -U(bani)=U(bun);

WTA: se câștigă suma de bani, dar se pierde bunul: U(bani)=-U(bun).

Atunci, în Teoria Prospectelor, o persoană acceptă să vândă bunul dacă:

A
A − λx ≥ 0, atunci: WTA=

❖ În teoria prospectelor, valoarea pierderii bunului și a câștigării banilor
(x$) este dată de:

V = U(−bun) + U(x) = −λA + x

Anamaria Aldea, AACPI, noiembrie 2020 Page 5


Se observă că banii și obiectul vânzării sunt evaluate în conturi “mentale”
separate.

Deci, în Teoria Prospectelor, o persoană plătește pentru bunul respectiv dacă


−λA + x ≥ 0, și atunci: WTP=  A .

Teoria economică permite celor două valori să difere puțin, datorită efectelor
de venit. În cazul WTA, venitul persoanei care a vândut bunul respectiv
crește. Dacă venitul este mai mare, atunci cererea de bunuri normale este
mai mare și va fi nevoie de o compensație mai mare.

Prin urmare, în termeni de curbe de indiferență, acestea pot fi desenate


fără a face vreo referință la averea inițială a consumatorului (decidentului)
respectiv. Astfel, curbele de indiferență vor fi valabile tot timpul, și nu sunt
funcții de averea inițială.

Grafic 1. Reprezentarea clasică a curbelor de indiferență

Anamaria Aldea, AACPI, noiembrie 2020 Page 6


Sau avem următorul exemplu în R pentru construcția curbelor de indiferență
asociate unei funcții de utilitate concavă de forma: U ( x, y ) = x + y

Și, totuși, ce lipsește atunci când vine vorba de interpretarea


curbelor de indiferență? Conform Khaneman şi Tversky, lipsește punctul
de referință față de care calculăm curbele de indiferență.

Anamaria Aldea, AACPI, noiembrie 2020 Page 7


Contra-Exemplu: colecționarii de artă, colecționarii de bunuri rare,
posesorii de bilete la spectacole, etc.

A se vedea (citi!): Kahneman, Knetsch and Thaler (1991), pag. 193-199.

Exemplu: Kahneman, 2011 – curbe de indiferență între venit anual și timp


liber anual – la curs

Anamaria Aldea, AACPI, noiembrie 2020 Page 8


Efectul înzestrării – testare pe bază de experimente
(Experiment la curs)

Pornind de la ideea testării modalității de funcționare a principiului care


guvernează însăși economia de piață, și anume întâlnirea cererii cu oferta,
Kahneman şi Thaler (ambii laureați ai premiului Nobel în Economie pentru
Behavioral Economics, primul în 2002, al doilea în 2017) au demonstrat
prezenta efectului înzestrării printr-un experiment realizat cu studenții de la
Standford University.

Într-o clasă de studenți, jumătate dintre aceștia primesc un obiect ieftin: un


pix sau o cană.

Studenții care nu au primit nimic trebuie să spună cât ar plăti pentru obiectul
respectiv (cană sau pix); aceștia trebuie să stabilească prețul maxim de
cumpărare (WTP).

Studenții care au primit bunul respectiv trebuie să spună care ar fi prețul


minim la care ar fi dispuși să vândă bunul respectiv (WTA).

Profesorii au fost cei care au înregistrat tranzacțiile dintre studenți și


preturile la care acestea s-au realizat.

Din moment ce bunurile au fost alocate aliator, ar trebui ca jumătate dintre


obiecte să fie vândute.

În realitate, s-a observat că nici un student nu a fost dispus să facă vreo


tranzacție.

Valorile WTA au fost mult prea mari față de valorile WTP. Adică, vânzătorii
au nevoie de sume mult mai mari pentru a renunța la obiectul deținut, în
timp ce cumpărătorii sunt dispuși să plătească sume mai mici.

Anamaria Aldea, AACPI, noiembrie 2020 Page 9


Efectul înzestrării reprezintă fenomenul prin care oamenii apreciază și tind
să supraevalueze un bun sau un serviciu atunci când intră în posesia lui.

Daniel Kahneman, Jack L. Knetsch şi Richard H. Thaler (1991) (vezi


articolul) și-au pus problema dacă acest efect provine de la vânzători
sau de la cumpărători.

Într-un experiment asemănător, bazat pe căni (evaluate inițial la


aproximativ 6$), au ajuns să observe că prețul mediu de vânzare era
aproape dublu față de cel de cumpărare, iar numărul estimat de tranzacții
este mai mic cu aproape 50% față de cel estimat de teoria economică
standard.

S-a propus, atunci, introducerea în analiză a încă unui grup: Choosers


(alegătorii), care nu dețineau cana. Aceștia aveau posibilitatea de a alege
între a primi banii sau cana, la fiecare preț pe care vânzătorii și cumpărătorii
îl stabileau, comportându-se pe rând fie ca vânzători, fie ca și cumpărători.

Rezultatele obținute au fost:

Vânzătorii – 7.12$;

Cumpărătorii – 2.87$;

Choosers (Alegătorii) – 3.12$. [cf. Kahneman, 2011]

S-a observat apoi că aceștia (Choosers) au un comportament mult mai


apropiat vânzătorilor decât cumpărătorilor. Astfel, s-a ajuns la observația că
efectul înzestrării nu pornește de la cumpărători, ci de la vânzătorii care
supraevaluează bunul din momentul în care intră în posesia lor.

Anamaria Aldea, AACPI, noiembrie 2020 Page 10


Alte explicații posibile pentru efectul de înzestrare:

a) Cumpărătorii pot percepe tranzacțiile ca fiind ilegitime, dacă ei chiar


nu doresc să vândă;

b) Obiceiurile de tranzacționare – de obicei, vânzătorii supraevaluează


obiectul vândut, în timp ce cumpărătorii au tendința de a-l subevalua;

c) Costurile de tranzacționare.

Pentru a testa dacă efectul de înzestrare poate fi explicat prin obiceiuri de


tranzacționare se pot analiza piețe pe care bunurile sunt achiziționate pentru
a fi revândute și nu pentru a fi utilizate. În acest caz, nu există efect de
înzestrare. (exemplu: traderii)

Exemplu: [cf. Kahneman, 2011] jetoanele – estimarea valorii acestora la


diferite preturi.

Întrebare: care este motivația comportamentală pentru apariția efectului de


înzestrare?

Indivizii evaluează tranzacțiile posibile relativ față de un punct de


referință, ceea ce înseamnă că aceștia sunt supuși efectului de aversiune
față de pierderi (loss aversion).

Astfel, în exemplul de mai sus, atunci când se calculează prețul de achiziție,


WTA, individul are nevoie de suficienți bani pentru a compensa trecerea de
la starea în care deține bunul respectiv (pixul/cana) la starea în care nu îl
mai deține.
Aversiunea față de pierderea obiectului arată că, de fapt, pierderea
obiectului are un impact mai mare pentru vânzător decât prețul estimat de
către cumpărător, WTP.

Anamaria Aldea, AACPI, noiembrie 2020 Page 11


Totuși, există și situații în care efectul înzestrării nu există.
Kahneman (2011, cap 27) prezintă câteva categorii de persoane ce se pot
încadra în această situație:

a) Persoanele care dețin un obiect pe care îl percep ca fiind purtător de


valoare și îl păstrează pentru schimburi viitoare. De obicei, acesta este
cazul persoanelor care lucrează în comerț sau pe piețe financiare și
care percep orice bun ca pe un potențial câștig. Prin urmare, aceștia
sunt indiferenți între a renunța sau a câștiga obiectul respectiv, care
pentru ei nu are valoare emoțională. De exemplu: traderii care
tranzacționează acțiuni în numele clienților.
b) Persoanele cu venituri mici și care se încadrează în categoria “săraci”
reprezintă și ele un alt grup al celor care nu au efect al înzestrării
deoarece, în Teoria Prospectelor, aceștia trăiesc sub punctul lor de
referință. În realitatea economică în care aceștia își desfășoară viața,
ei vor fi deseori situați în zona de pierderi a funcției valoare, iar
alegerilor lor se fac mereu între potențiale situații de pierdere. Orice
cost, pentru ei, reprezintă o pierdere a unui alt bun de care ar fi avut
nevoie.

Diferențele culturale sunt, la rândul lor, un element important al felului în


care percepem banii și cum înțelegem să îi cheltuim. De aceea, efectul
înzestrării ia expresii și forme diferite de la o cultură la alta, chiar dacă
facem o analiză pe aceeași categorie socială. Un bun exemplu în acest sens
sunt chiar experimentele realizate cu studenți din țâri diferite.

Anamaria Aldea, AACPI, noiembrie 2020 Page 12


References:

[1] Benartzi S. şi R. H. Thaler (1995), Myopic Loss Aversion and the Equity Premium Puzzle,
Quarterly Journal of Economics, 110(1), pp. 73-92. http://links.jstor.org/sici?sici=0033-
5533%28199502%29110%3A1%3C73%3AMLAATE%3E2.0.CO%3B2-T

[2] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University
Press.
[3] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux
[4] Kahneman, D. and A. Tversky (1979), Prospect Theory: An Analysis of Decision under Risk,
Econometrica, Vol. 47, No. 2, pp. 263-292
[5] Kahneman D., Knetsch J.L. and R. H. Thaler (1991), Anomalies: The Endowment Effect, Loss
Aversion, and Status Quo Bias, The Journal of Economic Perspectives, Vol. 5, No. 1, pp. 193-
206

[6] Mehra, Rajnish; Edward C. Prescott (2003). "The Equity Premium Puzzle in Retrospect". In G.M.
Constantinides, M. Harris and R. Stulz. Handbook of the Economics of Finance. Amsterdam:
North Holland. pp. 889–938.

[7] Shefrin, H. (2008), A Behavioral Approach to Asset Pricing, Elsevier, 2nd Edition.

Anamaria Aldea, AACPI, noiembrie 2020 Page 13


Analiza Deciziei Întreprinderii
(Folosind elemente de Economie Comportamentală)

Curs 9

Evoluția preferințelor în timp și preferințele sociale

A. Efectul înzestrării și curbele de indiferență - continuare

Curbele de indiferenţă în teoria prospectelor


Curbele de indiferenţă în cazul prospectelor nu vor mai avea aceleaşi
proprietăţi ca cele din cazul teoriei economice clasice, în primul rând datorită
prezenţei unui punct de referinţă ce se poate modifica în timp. Astfel, un
exemplu de curbe de indiferenţă sunt cele prezentate de Kahneman şi
Tversky (1992).

Vezi: Tversky, Kahneman, Advances in Prospect Theory, Journal of Risk and


Uncertainty, pg 18

Observaţie:

✓ Curbele de indiferenţă se deplasează spre interior sau spre interior;

✓ Curbele de indiferenţă sunt mai “pronunţate” spre marginile


triunghiurilor;

✓ Curbele de indiferenţă pentru prospecte negative se aseamănă


curbelor pentru prospecte pozitive reflectate în jurul primei bisectoare,
care reprezintă neutralitatea faţă de risc.

Curbele de indiferență în teoria prospectelor - detaliere

În teoria utilității așteptate, o funcție de utilitate concavă reflectă aversiunea


la risc, o funcție liniară – neutralitatea față de risc și o funcție convexă –
înclinația spre risc.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 1


Mulțimea “punctelor mai bune”, B(c) asociată oricărui plan de consum este
mulțimea tuturor planurilor de consum care sunt cel puțin la fel de bune ca
c. Orice mulțime a punctelor mai bune este limitată de o curbă de
indiferență.

Atunci când funcția de utilitate este strict concavă, mulțimile


punctelor mai bune sunt convexe atunci când sunt proiectate pe
spațiul de consum și liniare atunci când sunt proiectate pe spațiul
probabilităților.

Atunci când funcția de utilitate este liniară, această mulțime va fi


liniară atunci când este proiectată pe spațiul de consum, dar şi atunci
când este proiectată pe spațiul probabilităților.

Atunci când funcția de utilitate este strict convexă, mulțimile


punctelor mai bune sunt concave atunci când sunt proiectate pe spațiul
de consum și liniare atunci când sunt proiectate pe spațiul
probabilităților.

Se va considera o curbă de indiferență asociată teoriei prospectelor.

O mulțime a curbelor de indiferență în spațiul câștig/pierdere este


prezentată în figura de mai jos, ce se bazează pe presupunerea că avem
ponderi egale pentru cele două evenimente la t=1.

În colțul din dreapta sus avem o curbă de indiferență corespunzătoare


formei obișnuite celei asociate persoanelor cu aversiune la risc. Această
curbă corespunde situațiilor favorabile doar câștigurilor. Deoarece teoria
prospectelor prezintă utilități concave în câștiguri, mulțimile punctelor mai
bune asociate domeniului câștigurilor vor fi convexe.

Proprietatea de subcertitudine conduce la o discontinuitate a curbelor de


indiferență de-a lungul primei bisectoare. Curbele de indiferență asociate
punctelor aflate pe prima bisectoare se află, de fapt, deasupra acestor
puncte, ceea ce reflectă faptul că rezultatele ce conduc la câștig sau la
pierdere cu certitudine încorporează şi alte ponderi decizionale ce se referă
la rezultatele riscante.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 2


Porțiunea din stânga-jos prezintă o curbă de indiferență asociată unui
investitor care se confruntă doar cu pierderi la t=1. Deoarece teoria
prospectelor prezintă utilități convexe în pierderi, mulțimile punctelor mai
bune asociate domeniului pierderilor vor fi concave.

Curbele de indiferență ce se află între cele două extreme prezintă atât


câștiguri cât și pierderi. Astfel, unele dintre aceste curbe au porțiuni concave
și porțiuni convexe. Se observă, mai ales, că o curbă de indiferență ce trece
prin origine are un punct de inflexiune chiar în origine. Acest punct de
inflexiune corespunde inflexiunii funcției de utilitate, în origine. Figura
reprezintă spațiul câștigurilor și al pierderilor și nu spațiul consumurilor.

Figura 1. Curbele de indiferență în teoria prospectelor (câștiguri și pierderi)

Mulțimea
punctelor mai bune

este convexă

Mulţimea punctelor

mai bune este local concavă

Mulțimea punctelor

mai bune este concavă

B. Prima de risc în teoria prospectelor

În teoria economică standard, un investitor care dispune de o avere W o


foloseşte pentru mai multe planuri de consum: (c1,c2,...,cT) – de exemplu:
rezultate ale prospectelor, la diferite momente de timp (1...T) sau consumul
pe individ la diferite momente de timp.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 3


Atunci, se obține utilitatea acestuia ca fiind:

U (c1 ) +  U (c2 ) +  2U (c3 ) + ... +  T −1U (cT ) (1)

Unde  i , i = 0, T − 1 este un factor de actualizare subiectiv ce arată cât de

nerăbdător este un individ să achiziționeze un bun la un moment de timp.

Averea ce se urmăreşte să se obţină pentru planurile viitoare de consum se


va investi în instrumente financiare de tipul: bonuri de tezaur, obligaţiuni
sau acţiuni.

Prin urmare, riscul asociat portofoliului investitorului se va transfera asupra


riscurilor pentru planurile de consum viitoare.

Se presupune, în general, că acest investitor are o funcţie de utilitate de tip


CRRA, de forma:

c
U (c ) = ,  0 (2)

[Obs. O astfel de funcţie este preferată, de obicei, pentru că are randamente


constante la scală]

C. Aversiunea la risc de tip miopic

Mehra şi Prescott (2003) au estimat că investitorii ar avea nevoie de


coeficienţi de aversiune faţă de risc foarte mari, de ordinul:   0.30 pentru a
explica prima de risc mai mare pentru acţiuni faţă de cea pentru active fără
risc. Această afirmaţie este cunoscută sub numele de problema primei de
risc (equity premium puzzle).

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 4


Cu alte cuvinte, oamenii ar trebui să fie foarte adverși față de risc
pentru a justifica faptul că nu aleg activele, ci doar bonuri de tezaur, ţinând
cont de rentabilităţile mult mai mici ale activelor faţă de rentabilităţile
activelor fără risc.

De obicei, coeficienţii de risc au valori estimate între 0.3 şi 0.7.

Interpretarea din punct de vedere comportamental a problemei primei de


risc este dată de noţiunea de aversiune faţă de pierderi de tip miopic.
(myopic loss aversion)

Astfel, există doi factori ce contribuie la faptul că un investitor nu este dispus


să suporte riscurile asociate deţinerii de acţiuni:
• aversiunea faţă de pierderi şi
• perioada scurtă de evaluare.
Această combinaţie de factori se numeşte myopic loss aversion (Benartzi and
Thaler, 1995, pg 75.)

Întrebarea care se pune este: Poate aversiunea faţă de pierderi de tip


miopic (myopic loss aversion) să explice problema primei de risc (equity
premium puzzle)?

Aceasta presupune două componente de analiză pentru un investitor:


✓ Aversiunea faţă de pierderi şi
✓ O perioadă de evaluare a portofoliului.

v( x) = x a , x  0;
Ştim că funcţia valoare are forma:
v( x) = − (− x)b , x  0.

Astfel, deoarece activele au o probabilitate destul de mare de a avea


rentabilităţi negative, aversiunea faţă de pierderi face ca acestea să fie mai

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 5


puţin interesante comparativ cu activele fără risc, de exemplu: bonurile de
tezaur.

Dar, pe perioade lungi de timp, ţinând cont că se pot face mult mai multe
investiţii în active în acest timp, rentabilităţile activelor sunt mult mai mari
faţă de rentabilităţile bonurilor de tezaur sau ale obligaţiunilor.

Întrebare: care este deosebirea dintre bonuri de tezaur şi obligaţiuni?

Cu cât perioada de timp este mai mică, investiţia de tipul rentabilitate mare
- risc mare devine din ce în ce mai puţin atractivă.

Atunci, aversiunea faţă de pierderi nu poate explica, singură, problema


primei de risc.
Oamenii pot avea aversiune faţă de pierderi pentru evaluări periodice ale
portofoliilor, dar aceste evaluări pot fi prea dese.

Benartzi şi Thaler (1995): la ce intervale ar trebui să-şi evalueze


investitorii portofoliile folosind coeficienţii de aversiune faţă de pierdere
estimaţi?

Folosind eşantioane de rentabilităţi lunare ale activelor, obligaţiunilor şi


bonurilor de tezaur pentru perioada 1926-1990, au ajuns la concluzia că:

✓ Folosind rentabilităţi nominale, investitorii ar trebui să-şi evalueze


portofoliile o dată pe an;

✓ Folosind rentabilităţi reale, investitorii ar trebui să-şi evalueze


portofoliile aproximativ la fiecare 10 luni.

Vezi Benarzi and Thaler, pg 84.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 6


Asocierea unor ponderi decizionale diferite nu modifică rezultatele obţinute.

Apoi, aceştia au presupus că un investitor face o evaluare a portofoliului său


o dată pe an. În această situaţie au calculat utilităţi pentru portofolii care
conţineau şi acţiuni şi obligaţiuni. S-a observat că utilitatea obţinută este
maximă pentru portofolii formate din 50%-active şi 50%-obligaţiuni, ceea ce
se întâmplă şi în majoritatea cazurilor din realitate.

Observaţii:

✓ Faţă de teoria economică clasică, în teoria prospectelor, investitorii nu


vor alege portofolii diversificate.
✓ Curbele de indiferenţă folosind teoria prospectelor nu respectă
proprietăţile curbelor de indiferenţă din teoria clasică.

Lipsa diversificării se datorează următoarelor aspecte specifice teoriei


prospectelor:

✓ Funcție de utilitate convexă pe domeniul pierderilor;

✓ Contabilitatea mentală;

✓ Funcția de ponderare neliniară;

✓ Funcția de valoare cu un punct de inflexiune în origine.

Toleranța la risc heterogenă și preferința față de timp

Meyer și Meyzer (2005, 2006) subliniază, în urma analizei literaturii empirice


referitoare la măsurarea aversiunii relative față de risc, că un coeficient al
aversiunii relative față de risc reprezintă modificarea procentuală a
utilității marginale raportată la modificarea procentuală a argumentului
funcției de utilitate. Sau, se mai poate spune că acesta este elasticitatea
utilității marginale în raport cu argumentul funcției de utilitate.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 7


Aceștia demonstrează că elasticitatea respectivă este dependentă de modul
în care argumentul funcției este definit. Va conta dacă argumentul funcției
de utilitate este:

- Averea individului sau

- Consumul acestuia.

După analiza literaturii de specialitate s-a ajuns la concluzia că pot fi luați în


considerare mai mulți factori, care însă trebuie identificați prin analize
complexe.

KT (1986) au făcut câteva modificări referitoare la funcţia de ponderi


decizionale din Teoria Prospectelor. Astfel:

1. Mai întâi, au pornit de la ideea că ponderile decizionale se vor calcula


diferit pentru câştiguri şi pentru pierderi;

2. Apoi, au considerat ca bază pentru ponderi, folosirea unor funcţii de


distribuţie (cumulate);

3. S-a ajuns astfel la propunerea unei noi funcţii de ponderare,


obţinându-se o nouă abordare: prospectele cumulate.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 8


1. Introducere în Teoria Prospectelor Cumulate (CPT)

Referitor la reprezentarea unui prospect cumulat se vor parcurge următorii


paşi:

1. Se notează cu xk rezultatele câştigurilor şi cu x-k rezultatele pierderilor;

2. În prospectul cumulat, se ordonează rezultatele câştigurilor de la x1 –


cel mai slab rezultat la xn – cel mai bun rezultat posibil şi, apoi, se
ordonează pierderile de la x-1 – cel mai favorabil rezultat în termeni de
pierderi până la x-n – cel mai puţin favorabil rezultat.

3. Pentru k=0 se va considera rezultatul 0 şi se obţine un prospect de


x ... x− 2 0 x1 x2 ...x n 
forma: P :  −n 
 p−n .... p − 2 p0 p1 p2 ... p n 

4. KT definesc o nouă funcţie de ponderi decizionale, notată w + pe


domeniul de definiție al câștigurilor și numită funcție de probabilități
decumulative pentru câștiguri, respectiv w − pe domeniul de definiţie al
pierderilor, numită funcţie de probabilităţi cumulative pentru pierderi.

5. Atunci, se vor defini funcțiile w + ( D + ) , respectiv w − ( D − ) ca fiind funcţiile

de probabilități decumulative, respectiv cumulative ce conduc la


funcţiile de densitate de probabilitate: v + , respectiv v − .

KT au propus următoarele forme funcţionale pentru funcţiile de ponderare


w + şi w − :

+ +
)=
(D ) + 
(1);
(D ) + (1 − (D ) )
w (D 1
+  +  

w− (D − ) =
(D ) − 
(2).
(D ) + (1 − (D )
−  − 
) 1

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 9


Şi care reprezintă raportul dintre o funcție putere și o medie Holder (medie
generaliză a funcţiilor putere).

Pe baza experimentelor s-a ajuns la concluzia că  şi  variază în jurul

valorii de 0.6. Astfel:  = 0.65 şi  = 0.61 .

Funcţiile de ponderare pentru câștiguri w+ sunt funcții care


supraevaluează probabilităţile asociate câştigurilor extreme, iar funcţia de
ponderare pentru pierderi, w − , supraevaluează probabilitățile asociate
pierderilor extreme.

Atunci, funcţia de valoare pentru prospectele cumulate se va obține


n
calculând: v i  v(xi ) , unde vi ia valori diferite pentru câștiguri şi pentru
i =1

pierderi: v i = v i+ , atunci când rezultatele sunt câştiguri;

v i = v i− , atunci când rezultatele sunt pierderi.

2. Diferenţa dintre PT şi CPT

Diferenţa de bază este dată de funcţia de decizii ponderate, dar, pentru a


ordona prospectele se folosesc noțiunile de dominanță stohastică și
proprietatea de independenţă.

Ponderea ataşată unui anumit rezultat în PT depinde doar de p –


probabilitatea asociată rezultatului şi aceasta este independentă de
probabilităţile asociate altor rezultate.

În CPT, se introduce ideea de folosire a rangurilor pentru a putea ierarhiza


prospectele, iar acestea permit demonstrarea faptului că proprietatea de
independenţă dintre probabilităţi şi apariţia altor rezultate nu are loc .

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 10


Din PT se poate demonstra că, în anumite cazuri, o anumită alternativă
(prospect) dominantă din punct de vedere stohastic va avea o valoare, într-
un punct, mai mare decât valoarea alternativei sau prospectului pe care îl
domină stohastic, cu excepţia cazului în care  ( p ) = p .

Recapitulare – noţiunea de dominanţă stohastică

Dominanţa stohastică este o situaţie ce arată că o loterie sau un prospect


poate fi preferată alteia sau poate fi ierarhizată ca fiind superioară alteia
SD
(strict preferată). Adică: A  B .

Dominanţa stohastică de ordinul I permite următoarea scriere:

SD
Date fiind două loterii, A şi B, se poate spune că A  B dacă
p ( A  x)  p ( B  x), x , adică: pentru orice x, loteria A va da cel puţin o
probabilitate cel puţin la fel de mare ca şi loteria B de a obţine rezultatul cel
mai bun şi, pentru anumite valori ale lui x, loteria A conduce la probabilităţi
mai mari de a obţine x.

SD
Obs 1: în termeni ai funcţiilor de distribuţie cumulative se spune că A  B
dacă FA ( x)  FB ( x), x .

Obs 2: În termeni ai utilităţii, dominanţa stohastică de ordinul I arată că,

dacă A B , iar funcția de utilitate este crescătoare, atunci: U ( A)  U ( B ) sau


SD
A B.

3. Noţiunile de transparenţă şi opacitate în dominanţa stohastică

Proprietatea de transparenţă arată că oamenii nu aleg prospectul


dominant în mod conştient. Astfel, atunci când evaluează două prospecte, un
individ le încadrează într-o situaţie sau alta, distingându-se, de obicei, două
etape:

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 11


- Se încadrează un rezultat ca fiind cel primit cu certitudine (de exp:
100 u.m. se câştigă cu probabilităţi egale în ambele prospecte);

- Apoi, individul estimează probabilitatea de a obţine o sumă în plus.

Decidenții evită să aleagă variantele dominate atunci când alegerea este


transparentă (evidentă), dar pot alege o variantă dominată atunci când
apare noţiunea de dominanţă stohastică opacă şi el nu distinge între
probabilităţile mici, care, totuşi, îi afectează câştigurile şi pierderile.

Atunci, CPT vor avea un impact major asupra teoriei portofoliilor şi a


curbelor de indiferenţă.

După acest moment, analizele viitoare folosind aceste noțiuni s-au îndreptat
spre comportamente ale decidenților care acționează pe piața de capital
punând baza unei noi ramuri de studiu și anume, Finețele comportamentale
(Behavioral Finance), iar analizele la nivel de individ, pe bază de
experimente, au permis dezvoltarea Economiei Experimentale (Experimental
Economics).

References:

[1] Benartzi S. şi R. H. Thaler (1995), Myopic Loss Aversion and the Equity Premium Puzzle,
Quarterly Journal of Economics, 110(1), pp. 73-92. http://links.jstor.org/sici?sici=0033-
5533%28199502%29110%3A1%3C73%3AMLAATE%3E2.0.CO%3B2-T

[2] Kahneman, D. and A. Tversky, eds. (2000), Choices, Values and Frames, Cambridge University
Press.

[3] Kahneman, D. (2011), Thinking, fast and slow, Farrar, Straus and Giroux

[4] Kahneman D., Knetsch J.L. and R. H. Thale (1991), Anomalies: The Endowment Effect, Loss
Aversion, and Status Quo Bias, The Journal of Economic Perspectives, Vol. 5, No. 1, pp. 193-
206
Anamaria Aldea, AACPI – 7 decembrie 2020 Page 12
[5] Kahneman, D. and A. Tversky (1979), Prospect Theory: An Analysis of Decision under Risk,
Econometrica, Vol. 47, No. 2, pp. 263-292

[6] Tversky A and D. Kahneman, (1992), Advances in Prospect Theory: Cumulative Representation
of Uncertainty, Journal of Risk and Uncerctainty, Vol 5, pp 297-323

[7] Mehra, Rajnish; Edward C. Prescott (2003). "The Equity Premium Puzzle in Retrospect". In G.M.
Constantinides, M. Harris and R. Stulz. Handbook of the Economics of Finance. Amsterdam:
North Holland. pp. 889–938.

[8] Shefrin, H. (2008), A Behavioral Approach to Asset Pricing, Elsevier, 2nd Edition.

Anamaria Aldea, AACPI – 7 decembrie 2020 Page 13


Analiza Deciziei Întreprinderii

Curs 10

Diversificarea riscului: Decizii pe piețe de capital

(Elemente de Behavioral Finance)

Elemente de Teoria Arbitrajului: Index Model

1. Introducere:

Abordarea portofoliului optim are, totuşi, câteva puncte slabe:

- Necesită un număr mare de observaţii (eventual, zilnice) pentru o


acţiune;

- Estimările făcute pentru un număr limitat de observaţii ar putea să nu


fie corecte.

Atunci, s-a observat că rentabilitatea oricărei acţiuni tranzacţionate este


formată din două părţi:

- Rentabilitate normală (aşteptată), la care acţionarii “se aşteaptă”


şi cate depinde de toate informaţiile pe care aceştia le deţin;

- Rentabilitate incertă, care provine din informaţii ce vor fi primite în


perioadele următoare momentului analizei.

Astfel, rentabilitatea unui activ poate fi scrisă într-o manieră simplistă ca


fiind: Ri=ERi+U.

Anamaria Aldea, AACPI, Curs 10 Page 1


Factorii care pot determina rentabilitatea incertă pot fi de natură
macroeconomică, pot ţine de anunţurile făcute pe bursă, etc.

Prin urmare, riscul unei acţiuni se va împărţi şi el în:

▪ Riscul sistematic - cel care influenţează un număr mare de acţiuni,


într-o proporţie mai mare sau mai mică, iar

▪ Riscul nesistematic - acela care influenţează un singur activ sau un


grup mai mic de active.

Diferenţa dintre riscul sistematic şi riscul nesistematic nu este atât de clară


pe cât s-ar dori. Astfel, tot într-o manieră simplistă, putem scrie că
rentabilitatea unei acţiuni include şi riscurile ce apar din tranzacţionare:

Ri=ERi+m+ε,

Unde: m=riscul sistematic sau riscul de piaţă (market risc);

ε =riscul specific companiei. [cov(εi, εj)=0]

Influenţa riscului sistematic asupra unui activ se determină folosind


coeficientul de volatilitate, β.

Astfel: dacă β>1, atunci titlul este unul agresiv (amplifică evoluţia pieţei);

Dacă   (0,1) , titlul este unul care urmează evoluţia pieţei;

dacă β=1, atunci titlul este unul neutru, care nu influenţează evoluţia
pieţei.

Atunci, influenţa tuturor factorilor asupra evoluţiei unei acţiuni se va numi


model factorial (factor model), în care sursele de risc sistematic se numesc
factori, F.

Anamaria Aldea, AACPI, Curs 10 Page 2


Ri = ERi + 1 F1 +  2 F2 + ... +  k Fk +  i (1)

Relaţia (1) se numeşte model k-factorial.

În practică, se aplică un model unic-factorial (single factor model), care


presupune folosirea indicelui de piaţă ca fiind factor unic, cel mai important
factor, ce influenţează rentabilitatea activului. Astfel:

Ri = ERi +  ( RMi − ERM ) +  i (2)

Unde RMi = rentabilitatea portofoliului de piaţă. Acest portofoliu conţine toate

tipurile de acţiuni şi are un risc cât mai mic.

Relaţia (2) se mai poate scrie şi ca fiind:

Ri =  i +  i  RMi +  i (3)

2. Index model – ecuaţia de bază

Modelul presupune că există o variabilă care influenţează toate rentabilităţile


acţiunilor şi că, pentru o singură acţiune, cel puţin o singură variabilă
influenţează rentabilitatea acesteia.

Atunci, ecuația de bază presupune legătura dintre rentabilitatea în exces a


activului şi rentabilitatea în exces a indicelui de piaţă:

Ri − rf =  i +  i  ( RMi − rf ) +  i (4)

Unde:

Ri − rf = rentabilitatea în exces a activului riscant faţă de cel fără risc;

RMi − rf =rentabilitatea în exces a pieţei faţă de activul fără risc sau market

risk premium.

Anamaria Aldea, AACPI, Curs 10 Page 3


Iar: Ri =rentabilitatea activului i la momentul de timp t;

rf=rentabilitatea activului fără risc (observaţii ex-ante);

 i =constantă specifică acţiunii i;

 i =coeficientul de volatilitate (senzitivitate) al acţiunii i;

 i = erorile specifice acţiunii i.

Scopul acestui model constă în determinarea portofoliului de piaţă folosind


estimatorii ˆ i , ˆi . Astfel, relaţiile rentabilitate – preţ - riscul unei acţiuni ne

dau informaţii ce permit estimarea evoluţiei viitoare a activelor (asset


pricing), în timp ce  i arată impactul evenimentelor specifice firmei asupra

evoluţiei acţiunii pe piaţă.

Concluzie: estimând dreapta de regresie se obţine Security Characteristic


Line (SCL) sau Dreapta caracteristică a acţiunii.

Grafic 1. Security Characteristic Line (SCL)

Sursa: http://en.wiki2.org/wiki/Security_characteristic_line

Anamaria Aldea, AACPI, Curs 10 Page 4


Observaţie:  i estimat prin modelul unic factorial măsoară răspunsul

rentabilităţii activului la mişcări ale pieţei.

3. Determinarea portofoliului de piaţă – pe scurt

Proporţia cu care fiecare acţiune intră în componenţa portofoliului de piaţă


este dată de valoarea pe piaţă a acesteia (market value).

Valoarea pe piaţă a unei acţiuni (market value)=(preţul acţiunii*nr de


acţiuni)/valoarea totală pe piaţă a tuturor acţiunilor

Ipoteze:

Pentru determinare portofoliului de piață sunt necesare câteva ipoteze:

a) valoarea aşteptată a erorilor nu duce la o rentabilitate aşteptată în


exces pozitivă: E ( i ) = 0 ;

b) nu există corelaţie între erorile acţiunilor: cov( i ,  j ) = 0 ;

c) nu există corelaţie între prima de risc a pieței (market risc premium) şi


erorile acţiunilor: cov(RMi − rf ,  i ) = 0 .

Riscul diversificabil

Atunci, riscul portofoliului de piaţă are următoarea formulă:

 2Ri − rf  = i2   2RMi − rf  +  2 i  (5)

Unde:  2Ri −rf  = riscul total al portofoliului de piaţă;

 2R Mi − rf  = riscul sistematic, nediversificabil;

 2  = riscul specific firmei, nesistematic, diversificabil.


i

Anamaria Aldea, AACPI, Curs 10 Page 5


a) Cazul a două acţiuni

Se consideră un portofoliu de piaţă format din două acţiuni, A şi B, care intră


1
în componenţa portofoliului cu ponderi egale:  A =  B = .
2

Atunci, rentabilitatea şi riscul portofoliului de piaţă sunt date de:

1 1
ER pfp =  ER A +  ER B (6a)
2 2

2 2
1 1 1 1
 2
pfp =     A2 +     B2 + 2    cov(R A , RB ) (6b)
2 2 2 2

Folosind ecuaţia specifică index model, (4) şi formula covarianței dintre două

acţiuni: cov(R A , R B ) =  A2   B2 , dar şi relaţia Cauchy-Schwartz:

cov(R A , RB ) =  A   B   2RMi −rf  (7)

Se obţine formula riscului portofoliului de piaţă:

 pfp
2
=
1
4
2

4
(
 ( A +  B )   2RMi − rf  +   2A +  2B (8)
1
)

Sau, generalizând:

2
 1  
2

 2
pfp
1
(
=    ( A +  B )   2RMi −rf  +     2A +  2B (8’) )
 2   2

b) Cazul general - N acţiuni

Dacă se includ în portofoliul de piaţă mai mult de două acţiuni, putem


generaliza formula (8’) pentru N- acţiuni:

2
 1  
2

 2
pfp
1
(
=    ( A +  B + ... +  N )   2RMi −rf  +     2A +  2B + ... +  2N (9) )
 N   N
Anamaria Aldea, AACPI, Curs 10 Page 6
Sau:

 pfp
2
( ) 2
=  P   2R Mi − rf  +
1
N
( )
  2P (9’)

1 N 
Unde:  P =  i = media volatilităţilor individuale;
N  i =1 

1 N 2
 2P =   i  =
N  i =1
media varianţelor specifice firmei (riscul specific

firmei).

Dar cov( i ,  j ) = 0 , de unde rezultă că lim  2P 


N →
( ) 1
N
= 0.

Pe măsură ce numărul de acţiuni în portofoliu creşte, riscul nesistematic,


specific firmei tinde să dispară ca urmare a diversificării. Acest proces se
numeşte efectul diversificării.

Grafic 2. Efectul diversificării riscului portofoliului de piaţă

 pfp
2

 2i

2
 p pfp
2

număr de acţiuni

Concluzie: Într-un portofoliu diversificat, N este suficient de mare astfel


încât:

Anamaria Aldea, AACPI, Curs 10 Page 7


( )
2
 pfp
2
=  P   2R
Mi − rf  (10)

iar riscul specific firmei poate fi ignorat.

Astfel, din formula (10), riscul sistematic, al portofoliului de piaţă:

▪ depinde de volatilităţile acţiunilor individuale;

▪ Se păstrează indiferent de gradul de diversificare;

▪ Indiferent de numărul de acţiuni deţinute, expunerea lor la riscul pieţei


se va reflecta în riscul sistematic.

M. Statman (1987): 30 acţiuni sunt suficiente pentru a realiza portofoliul


cu diversificare optimă.

Legătura dintre portofoliul de piaţă şi modelul unic factorial:

Un portofoliul diversificat nu are risc nesistematic (al firmei) sau acesta este
foarte mic. Atunci, se presupune că există suficiente titluri astfel încât
portofoliul de piaţă să fie complet diversificat şi, presupunând că nici un titlu
nu are o pondere foarte mare pe piaţă, un astfel de portofoliul este:

- diversificat,

- nu conţine risc sistematic.

Prin urmare, portofoliul de piaţă este perfect corelat cu un singur


factor, ceea ce presupune că acest portofoliu este o variaţie mai mare sau
mai mică a factorului respectiv. După scalare, portofoliul de piaţă poate fi
considerat un factor din modelul unic factorial.

Portofoliul de piaţă, ca orice portofoliu se află pe o dreaptă caracteristică lui,


numită Security Market Line (SML) şi, dacă el reprezintă factorul din
modelul unic factorial, prin definiţie, va avea  = 1 .
Anamaria Aldea, AACPI, Curs 10 Page 8
4. Relaţia risc-rentabilitate aşteptată: Modelul CAPM (Capital
Asset Pricing Model)

În Finanţe, modelul CAPM se foloseşte pentru a determina o rată a


rentabilităţii unei acţiuni care se adaugă la un portofoliu deja bine
diversificat, ştiind că riscul acestei acţiuni este nediversificabil.

Modelul CAPM permite calcularea capitalului propriu al unei companii pe baza


coeficientului  rezultat din model1.

4.1. Ecuaţia de bază

Pentru orice acţiune pentru care s-a aplicat modelul unic factorial şi s-a
determinat coeficientul de volatilitate  i , se poate calcula rentabilitatea în

exces faţă de rentabilitatea activului fără risc ca fiind o funcţie liniară de


rentabilităţi în exces ale pieţei (în funcţie de diferite valori ale lui  ).

ERi − rf = i  ( ERMi − rf ) (11)

Unde:  i =se determină din modelul unic factorial;

rf=rentabilitatea aşteptată a activului fără risc.

ERi − rf = prima de risc (risk premium)

ERMi − rf = prima de risc a pieţei (market risk premium)

Din (11), se poate obţine:

ERi = rf + i  ( ERMi − rf ) (11’)

1
James Chong; Yanbo Jin; Michael Phillips (April 29, 2013). "The Entrepreneur's Cost of Capital: Incorporating Downside Risk in
the Buildup Method".

French, Craig W. (2003). "The Treynor Capital Asset Pricing Model". Journal of Investment Management 1 (2): 60–72. SSRN 447580

Anamaria Aldea, AACPI, Curs 10 Page 9


Dar,  i , prin CAPM, măsoară răspunsul acţiunii faţă de mişcările portofoliului

de piaţă.

Atunci, relaţia dintre rentabilitatea așteptată a unei acţiuni şi volatilitatea


activului respectiv se numeşte Dreapta titlului pe piaţă sau Security Market
Line (SML) şi reprezintă graficul asociat modelului CAPM.

Grafic 3. Security Market Line (SML)

sursa: https://alphahive.files.wordpress.com/2013/01/bnxd.jpeg?w=545&h=545

Observaţie: modelul factorial nu impune restricţii asupra lui  i , dar modelul

CAPM, da. În ecuaţia de bază a modelului CAPM:  i = 0 .

Anamaria Aldea, AACPI, Curs 10 Page 10


4.2. Ecuaţia de bază a CAPM: portofoliul de piaţă

Se presupune că există i = 1, I acţiuni cu aceeaşi volatilitate: i =  .

Se presupune că se alcătuieşte un portofoliu investind în fiecare acţiune 1


I
1
din investiţia iniţială, adică:  = .
I

Atunci, ecuaţia de bază a portofoliului de piaţă este:

I
i I
i
ER pfp − rf =  +  ( ERM − rf ) +  (12)
i =1 I i =1 I

Dacă I →  , atunci relaţia (12) devine: ER pfp = rf +   ( ERM − rf ) (12’)

Sau: ER pfp =   ERM + (1 −  )rf (12”) .

În acest portofoliu se alocă  % din fondurile pentru investiţii în portofoliul de

piaţă şi (1 −  ) % în active fără risc.

Analog, riscul portofoliului de piaţă este:

 pfp
2
=  2   R2 + (1 −  ) rf2 =  2   R2 (13), deoarece  rf2 = 0 .
M M

Atunci, reprezentarea grafică dintre riscul şi rentabilitatea portofoliului de


piaţă conduce la Capital Market Line (CML). Dacă se adaugă sau se elimină o
acţiune la/din portofoliul de piaţă, atunci acest lucru corespunde unei
deplasări de-a lungul dreptei CML.

Anamaria Aldea, AACPI, Curs 10 Page 11


Grafic 4. Capital Market Line (CML)

Sursa: http://upload.wikimedia.org/wikipedia/en/7/7d/CML-plot.PNG

Observaţii:

1. Modelul CAPM presupune că, pentru orice investitor, portofoliul optim


riscant este acelaşi;

2. Modelul CAPM previzionează că acest portofoliu este, de fapt,


portofoliul de piaţă.

Pe scurt:

✓ CML – măsoară rentabilitatea în exces pe unitatea de risc total;


(Erpf,sdpf)

✓ CML – se aplică doar pentru portofolii eficiente;

✓ SML – reprezintă relaţia dintre coeficientul de volatilitate,  , şi


rentabilitatea portofoliului de piaţă sau rentabilitatea unui activ;

Anamaria Aldea, AACPI, Curs 10 Page 12


✓ SML – măsoară rentabilitatea în exces a portofoliului sau a acţiunii pe
unitatea de risc sistematic,  ;

✓ SML – se aplică titlurilor individuale: (ERi,  i) sau portofoliilor (ERpf,

 i).

Concluzie:

▪ Modelul CAPM se bazează pe estimări obţinute pe date istorice.


Evaluarea acţiunilor în acest fel are ca scop previzionarea preţului
viitor al acţiunii respective.

▪ Totuşi, există o abatere sistematică de la predicţia făcută de CAPM.

References

[1] Bebczuk R. (2003), Asymmetric information in financial markets:


introduction and applications, Cambridge University Press;

[2] Jehle, G.A, Renh, P. J. (2001), Advanced Microeconomic Theory,


Addison Wesley;

[3] Varian, H (1992), Microeconomic Analysis, 3rd Edition, W.W.


Norton&Company Inc.

Anamaria Aldea, AACPI, Curs 10 Page 13


Analiza Deciziei Întreprinderii
(Folosind elemente de Economie Comportamentală)

Ipotezele pieţei eficiente (EMH- Efficiency Market Hypothesis) și


Anomaliile pieței de capital

(Elemente de Behavioral Economics)

Teoria financiară modernă1 s-a fundamentat aproape, în exclusivitate,


pe sistemul de ipoteze al pieţelor financiare eficiente. Conceptul de piaţa
financiară eficientă2 (efficient market hypothesis) introdus şi dezvoltat în
primul rând de Eugene Fama are la bază ideea de integrare a tuturor
informaţiilor legate de firma emitentă în cursul bursier al acţiunilor emise de
aceasta, pe o piaţă lichidă.

În condiţiile pieţei financiare eficiente, preţul de piaţă va coincide


cu valoarea intrinsecă a acţiunilor companiei, ceea ce înseamnă că preţurile
activelor sunt cei mai buni indicatori ai valorii acestora. Valoarea activului
este determinată, în aceste condiţii, pe baza actualizării fluxurile viitoare de
numerar/beneficii pe care respectivul activ le generează.

R. Shiller3 menţionează (într-unul din cursurile sale de la Yale despre


eficienţa pieţelor) că George Gibson (1889, în cartea The Stock Exchanges of
London, Paris and New York) a fost primul cercetător care a afirmat că
preţurile cuprind cea mai bună informaţie referitoare la piaţă. Acesta a
afirmat că, atunci când acţiunile unei companii devin publice pe o piaţă
deschisă, valoarea de pe respectiva piaţă poate fi privită ca fiind cea mai

1
Dragotă, V.(2003), Politica de dividend. Bucuresti : Editura All Beck.
2
idem
3
Shiller R., www.econ.yale.edu/~shiller/course/252/Lect06EffMark.ppt
Anamaria Aldea, AACPI, ianuarie 2021 Page 1
bună evaluare a acesteia. ("when shares become publicly-known in an open
market, the value, which they acquire there, may be regarded as the
judgment of the best intelligence concerning them"). Astfel, el afirma că nu
poţi obţine randamente mai bune decât piaţa, pentru că preţul de piaţă
include toate informaţiile.

În acest context se discută, de fapt, despre o eficienţă


informaţională a pieţei şi nu despre o alocare eficientă a resurselor de
producţie.

În strânsă legătură cu ipoteza pieţelor eficiente, trebuie menţionat


procesul mersului aleator (random walk), care înseamnă că, de fapt,
preţurile acţiunilor se modifică doar ca rezultat al unei informaţii noi,
imposibil de previzionat.

Printre primii cercetători care au menţionat procesul mersului aleator a


fost un matematician francez Louis Bachelier, care în lucrarea sa de doctorat
Theorie de la Speculation (1900) a dezvoltat principiile matematice şi
statistice ale mişcării browniene, cu cinci ani înaintea lui Einstein (1905). Dar
termenul de mers aleator a fost folosit pentru prima oară de profesorul Karl
Pearson într-un articol din Nature din 1905. Dacă modificările de preţ
urmează un proces de mers aleator, fără a putea fi previzionate, înseamnă
că investitorii au exploatat toate oportunităţile de arbitraj.

Un proces de tip mers aleator poate fi modelat matematic astfel:

xt = xt −1 +  t , unde x este variabila aleatoare, iar  t este „zgomotul”,

componenta care nu poate fi previzionată.

Dezbaterile ştiinţifice privind ipoteza mersului aleator al modificărilor


preţurilor acţiunilor şi chiar ipoteza pieţelor eficiente au continuat în
următoarea perioadă, fiind susţinute, printre alţii, şi de J.M. Keynes, P.
Samuelson, M. Friedman.
Anamaria Aldea, AACPI, ianuarie 2021 Page 2
În anul 1965, E. Fama a definit piaţa eficientă în lucrarea sa
empirică privind preţurile pe piaţa de capital care evoluează urmărind un
mers aleator. Ipoteza pieţelor eficiente (efficient market hypothesis – EMH)
a fost legată, mai târziu, de ipoteza aşteptărilor raţionale ale
macroeconomiei neoclasice. Dar, această ipoteză este opusă opiniei
susţinătorilor analizei tehnice, care afirmă că pot estima preţurile activelor
pe baza studiului modelelor de evoluţie a acestora şi că pot obţine
rentabilităţi mai mari decât piaţa. Astfel, ipoteza pieţelor eficiente
demonstrează inconsistenţa a ceea ce se credea până în anii ‘60, şi anume
că instrumentele analizei tehnice sau cele ale analizei fundamentale pot
folosi la obţinerea unor rentabilităţi mai mari decât cele care ar fi obţinute
dacă s-ar “copia” evoluţia pieţei (beat the market).

Ipotezele conceptului de piaţă eficientă sunt:

✓ un număr foarte mare de participanţi pe piaţă care urmăresc


maximizarea profiturilor, care evaluează titlurile de pe piaţă
independent de ceilalţi şi îşi ajustează rapid aşteptările privind
preţurile titlurilor pentru a încorpora efectul noilor informaţii;

✓ investitorii sunt raţionali, adică au aversiune la risc şi


intenţionează să achiziţioneze active care să le aducă cea mai mare
rentabilitate la un nivel dat al riscului;

✓ informaţiile noi apar pe piaţă în mod aleator şi sunt


independente;

✓ preţurile urmează o mişcare aleatorie şi imposibil de previzionat


(random walk);

✓ nu există costuri de informare (participanţii pe piaţă sunt perfect


informaţi), fiscalitate şi tranzacţionare;

✓ rentabilitatea acţiunilor urmează o distribuţie normală.


Anamaria Aldea, AACPI, ianuarie 2021 Page 3
Există trei limite principale privind capacitatea pieţei de a produce
eficienţa informaţională:

1) procesarea informaţiilor noi antrenează costuri şi timp. Analiştii


şi traderii care reacţionează rapid şi corect la noile informaţii sunt cei
care trebuie răsplătiţi.

2) “preţurile ineficiente” pot persista atât timp cât câştigul din


tranzacţionare folosind informaţiile respective este mai mic decât
costurile de tranzacţionare, aşa cum a intuit trader-ul. Operaţiunile de
vânzare în lipsă (short-selling) pot fi considerate ca având costuri mai
mari.

3) arbitrajul nu este lipsit de risc: dacă apare o ofertă de preluare


lansată pentru acţiunile respective s-ar putea înregistra pierderi.

În 1967, profesorul Harry Roberts4 defineşte trei forme ale ipotezei


pieţelor eficiente. Cele trei forme ale eficienţei informaţionale a pieţei,
menţionate mai târziu şi de către Fama (1970), sunt:

Forma slabă a ipotezei pieţelor eficiente (weak form) – preţul activelor


financiare încorporează toate informaţiile din trecut legate de tranzacţionarea
acestor acţiuni.

Astfel, preţurile reflectă toate informaţiile trecute privind ratele de


rentabilitate, volum, preţuri istorice. În concluzie, nu se pot previziona
preţurile viitoare pe baza preţurilor din şedinţele de tranzacţionare
anterioare. Majoritatea testelor a demonstrat eficienţa informaţională a
pieţei în formă slabă. Interesant este faptul că, deşi preţurile reacţionează

4
Roberts, H. V. Statistical versus clinical Prediction of the Stock Market, lucrare nepublicată şi prezentată la seminarul The
Analysis of Security Prices, Universitatea Chicago, mai 1967.

Anamaria Aldea, AACPI, ianuarie 2021 Page 4


rapid la noile informaţii, se pune problema dacă acestea se ajustează corect.
Este posibil ca scopul mişcării preţurilor să fie în sensul căutării atingerii
nivelului corect.

Testele statistice care se pot realiza pentru a demonstra eficienţa


pieţei în formă slabă sunt:

✓ testarea corelaţiei seriale;

✓ teste de tip mobil (runs tests);

✓ teste de tip filtru (filter tests) ;

✓ teste de tip semnificaţie relativă (relative strength tests).

Forma semi-forte a ipotezei pieţelor eficiente (semi-strong form) –


preţurile acţiunilor încorporează toate informaţiile publice disponibile precum
şi aşteptările privind viitorul.

Acest lucru înseamnă că preţurile se ajustează foarte rapid la


informaţii noi şi informaţia veche nu poate fi folosită pentru a obţine
rentabilităţi mai mari. Este unanim acceptat faptul că existenţa formei semi-
puternice a pieţei elimină raţiunea de a exista a analizei fundamentale.
Rezultatele testelor privind această formă de eficienţă nu au fost
concludente.

Testele statistice, care se pot realiza pentru a demonstra eficienţa


pieţei în formă semi-forte, pot fi clasificate astfel:

1) studii de eveniment prin care se testează rapiditatea cu care


preţurile acţiunilor încorporează informaţiile (se ajustează) la diverse
anunţuri (de ex.: anunţul acţiunilor de divizare a acţiunilor companiei,

Anamaria Aldea, AACPI, ianuarie 2021 Page 5


anunţul rezultatelor trimestriale/semestriale/anuale ale companiile,
anunţul recomandărilor sau modificării recomandărilor analiştilor).

2) studii privind analiza seriilor de timp a rentabilităţilor acţiunilor sau


privind distribuţia rentabilităţilor mai multor acţiuni la un moment dat
pentru a observa dacă se pot previziona rentabilităţi viitoare pe baza
celor obţinute în trecut (cross-sectional return prediction). În ultimul
tip de studii menţionat mai sus se testează de fapt dacă se obţin
rentabilităţi statistic semnificativ diferite de rentabilităţile normale de
către companii cu anumite caracteristici comune ce se referă la
dimensiune, la niveluri ale raportului capitaluri proprii şi capitalizare
bursieră (book value/market value – BV/MV) mai mare sau ale
raportului preţ şi profit net pe acţiune (price/earnings per share –
P/E).

Forma forte a ipotezei pieţelor eficiente (strong form) – preţurile


acţiunilor reflectă toate informaţiile relevante, inclusiv informaţiile privind
tranzacţiile insiderilor.

Acest lucru înseamnă că toate companiile listate nu au niciun secret,


dezvăluie totul pieţei şi atunci preţul include toate informaţiile dorite. Testele
au arătat că pieţele nu sunt eficiente în acest sens şi că profesioniştii din
mediul pieţei de capital obţin adesea rentabilităţi mai mari, dar fondurile
mutuale nu înregistrează rentabilităţi mai mari decât piaţa, ci, dimpotrivă
85% din fonduri obţin mai puţin decât piaţa.

Anamaria Aldea, AACPI, ianuarie 2021 Page 6


Pentru a testa eficienţa informaţională a pieţei s-au realizat mai multe
studii de caz care au evidenţiat uneori punctele slabe ale teoriei, numite
anomalii, dar nu grave:

✓ efectul de mărime al companiilor – numeroase studii, începând


cu anul 1980, au demonstrat că rentabilităţile oferite de acţiunile
companiilor de mărime redusă sunt mai mari decât cele ale
companiilor de mărime mai mare. Rezultatele au fost aceleaşi şi în
cazul testelor aplicate companiilor cu capitalizare mare care sunt
incluse în S&P 500 comparativ cu cele ale companiilor cu capitalizare
şi mai mare incluse în acelaşi indice. În acest sens, Banz5 (1981) a
fundamentat efectul de mărime şi a observat că firmele cu capitalizare
bursieră mică obţin rentabilităţi medii mai mari decât cele estimate
prin modelul de estimare a rentabilităţii activelor – CAPM.

✓ efectul P/E6 (price- earnings ratio) – s-a demonstrat că portofoliile


formate din acţiuni cu P/E mic obţin rentabilităţi mai mari decât cele
cu P/E mai mare. Acest lucru poate fi explicat şi prin faptul că acţiunile
companiilor cu dimensiuni mici au un P/E mic, în timp ce acţiunile
companiilor mari au un P/E ridicat. Basu7 (1977) observă că acţiunile
cu P/E mic obţin în viitor rentabilităţi mai mari decât cele previzionate
de CAPM, în condiţiile unei pieţe eficiente în formă semi-forte.

✓ efect de ianuarie (January effect) – rentabilităţile oferite de


acţiuni sunt mai mari în luna ianuarie comparativ cu celelalte luni ale
anului (Rozeff&Kinney8,1976; Keim, 19839). Această situaţie poate fi

5
Banz, R.W. (1981), “The Relationship Between Return and Market Value of Common Stocks,” Journal of
Financial Economics 9, 3-18.
6
P/E numit raport preţ-câştig sau durata de recuperare a investiţiei, este calculat ca raport între preţul acţiunii şi
profitul net pe acţiune obţinut de companie în ultimele 12 luni.
7
Basu, S.( 1977), “Investment Performance of Common Stocks in Relation to Their Price-Earnings Ratios: A Test of
the Efficient Market Hypothesis”, Journal of Finance 12 (3), 129-56.
8
Rozeff, M.S., Kinney, W.R. (1976), “ Capital Market Seasonality: The Case of Stock Returns”, Journal of
Financial Economics 3, 379-402.
Anamaria Aldea, AACPI, ianuarie 2021 Page 7
explicată prin vânzări determinate de evitarea impozitului ce trebuie
plătit (M. Reinganum10, 1983), dar unele studii au arătat că nu este
singura explicaţie, cel puţin pentru pieţele din afara SUA: de exemplu,
Japonia – Kato&Schallheim, 198511, Canada – Berges, McConnell&
Schlarbaum12, 1984). O altă observaţie importantă este dată de faptul
că rentabilităţile companiilor mici tind să fie mai mari în luna ianuarie
decât cele ale companiilor mari (M. Reinganum13, 1983).

✓ efectul zilei din săptămână (efectul zilei de luni/efectul de week-


end) – în perioada 1989 – 1998 s-a observat că în ziua de luni s-au
înregistrat cele mai mici rentabilităţi dintre celelalte zile ale săptămânii
(Kenneth14, 1980). Au existat studii care au analizat comportamentul
investitorilor individuali comparativ cu cel al celor instituţionali.
Rezultatele cercetărilor au arătat că investitorii individuali tind să
tranzacţioneze mai mult în ziua de luni comparativ cu celelalte zile ale
săptămânii şi, mai mult, numărul de tranzacţii de vânzare este mai
mare decât cel al tranzacţiilor de cumpărare (Lakonishok& Maberly,
199015; Braham&Ikenberry16, 1994), explicând într-o anumită măsură
efectul zilei de luni.

9
Keim, D.(1983), “Size-related anomalies and stock return seasonality : Further empirical evidence”, Journal of
Financial Economics 12 (1), 13-32.
10
Reinganum, M. (1983), “The anomalous stock market behavior of small firms in January: Empirical tests for tax-
loss selling effects”, Journal of Financial Economics 12 (1), 89-104.
11
Kato, K. ,J.S. Schallheim (1985), “ Seasonal and Size Anomalies in the Japanese Stock Market “, The Journal of
Financial and Quantitative Analysis 20: 107-18.
12
Berges, A., J.J. Mcconnel şi G.G. Schlarbaum, G.G.(1984), “An investigation of the Turn-of-the-Year Effect, the
Small Firm Effect and the Tax-Loss-Selling-Pressure Hypothesis in Canadian Stock Return”, Journal of Finance
39: 185-92.
13
Idem
14
French, K. (1980), “Stock Returns and the Weekend Effect”, Journal of Financial Economics 8 (1): 55-69.
15
Lakonishok, J., Maberly, E.(1990), “The Weekend Effect: Trading Patterns of Individual and Institutional
Investors”, The Journal of Finance 45 ( 1) 231-243.
16
Abraham, A., Ikenberry, D. (1994), “The Individual Investor and the Weekend Effect”, the Journal of Financial
and Quantitative Analysis 29 (2), 263-277.

Anamaria Aldea, AACPI, ianuarie 2021 Page 8


În concluzie, pieţele nu sunt eficiente perfect din punct de vedere
informaţional pentru că, prin deţinerea de informaţii private care nu
sunt publice, se pot obţine randamente mai mari decât în mod normal.

Investitorii trebuie să fie atenţi la anomaliile pieţei pentru că:

✓ măsurarea rentabilităţii anormale se face de cele mai multe ori


prin utilizarea CAPM pentru măsurarea rentabilităţii normale. Modelul
CAPM este un model de echilibru, prin care rentabilitatea estimată a
unei acţiuni este influenţată de rentabilitatea pieţei şi de coeficientul
beta, care nu surprinde întotdeauna riscul firmei;

✓ există riscul strategiei – dacă un investitor urmăreşte o


strategie, s-ar putea ca şi alţii s-o identifice şi să o urmărească,
disipându-se efectele aplicării acesteia;

✓ există metode de tip data mining – acestea se referă la diverse


metode şi tehnici statistice, pe care analiştii le folosesc pentru a găsi
corelaţii între datele analizate şi de a identifica modele de evoluţie a
lor pentru realizarea previziunilor;

✓ există o anumită deviaţie (abatere) determinată de excluderea


din eşantionul analizat a unor date (bias survivorship), ca de
exemplu: acţiuni cu performanţe reduse sau ale unor companii care
şi-au încetat existenţa din diverse motive, cum ar fi faliment, fuziune
sau cumpărare de către o altă companie; este o categorie a deviaţiilor
apărute în procesul de alegere a eşantionului pentru care se face
analiza;

✓ există deviaţii rezultate de alegerea eşantionului (sample


selection bias); în procesul alegerii eşantionului sunt eliminate acele
observaţii care au un atribut nedorit;
Anamaria Aldea, AACPI, ianuarie 2021 Page 9
✓ există diferenţe în frecvenţa şi intensitatea cu care se
tranzacţionează acţiunile (nonsynchronous trading) deoarece anumite
acţiuni se tranzacţionează mai des şi mai intens decât altele. Astfel se
creează premisele apariţiei corelaţiei seriale între rentabilităţile
acţiunilor.

Enumerarea unor anomalii, deviaţii de la principiile teoriilor finanţelor


moderne, în special cele referitoare la eficienţa pieţei de capital,
demonstrează necesitatea de a avea şi o altă perspectivă asupra modului în
care se formează şi evoluează preţurile activelor pe piaţa financiară. Prin
urmare, s-a ajuns la concluzia că este nevoie şi de alte ştiinţe (de ex.:
psihologie, sociologie) care să contribuie la caracterizarea unei categorii de
investitori.

References:

[1] Barberis, Nicholas & Thaler, Richard (2003) - A survey of behavioral finance,
Handbook of the Economics of Finance, in: G.M. Constantinides & M. Harris &
R. M. Stulz (ed.), Handbook of the Economics of Finance, edition 1, volume
1, chapter 18, pages 1053-1128 Elsevier.

[2] Lipară, C. (2011) – Evaluarea acţiunilor – o abordare din perspectiva teoriilor


comportamentale, forthcoming

[3] MacKinlay, C. A. (1997), Event studies in economics and finance, Journal of


Economic Literature 35 (1): 13—39.

Anamaria Aldea, AACPI, ianuarie 2021 Page 10


Analiza Deciziei Întreprinderii

Curs 12

Testarea comportamentului agenţilor economici pe bursă: testarea


reacţiilor acestora la ştiri pozitive şi negative (event studies)

1. Introducere

Scop: se analizează modul în care evoluează preţurile acţiunilor


companiilor, ca rezultat al reacţiilor investitorilor la ştirile pozitive, negative
sau neutre anunţate de emitenţi, prin utilizarea studiilor de eveniment
(event studies).

O serie de lucrări ştiinţifice din domeniul finanţelor a demonstrat


existenţa unei reacţii excesive (over-reaction) sau a unei reacţii slabe
(under-reaction) la anunţul unor ştiri ale companiilor.

Reacţiile excesive şi cele slabe ale preţurilor acţiunilor la ştirile


anunţate de companii sunt printre primele anomalii care au pus sub semnul
întrebării validitatea teoriei pieţelor eficiente (EMH) şi au fost, de asemenea,
printre primele noţiuni care au stat la baza definirii teoriilor finanţelor
comportamentale (Behavioural Finance).

Importanţa studiului reacţiilor excesive şi a celor slabe ale preţurilor:


explicarea modului în care se formează preţurile acţiunilor pe piaţa de
capital.

Observaţie: Investitorii devin interesaţi de aceste abateri ale


preţurilor acţiunilor de la valoarea lor intrinsecă pentru că pot obţine
informaţii cu privire la strategiile de investiţii pe care le pot implementa.

Anamaria Aldea, AACPI – ianuarie 2021 Page 1


2. Metodologie şi exemplificare

Pentru realizarea unui studiu de eveniment se foloseşte metodologia


descrisă de MacKinlay (1997) şi care presupune următorii paşi:

Pasul 1: definirea evenimentului care va fi studiat şi definirea perioadei


pentru care se va efectua analiza evoluţiei cursurilor bursiere.

✓ De exemplu, un eveniment este reprezentat de anunţul


rezultatelor trimestriale ale companiilor listate.

✓ Perioada pentru care se studiază evenimentul se numeşte


perioada evenimentului (event window) şi reprezintă un
număr de zile (N) înainte de producerea evenimentului şi un
număr egal de zile (N) după realizarea acestuia, adică (T1,T2) din
figura de mai jos (Figura 1: Axa timpului pentru un studiu de
eveniment general). Momentul exact al producerii evenimentului
este τ=0.

Axa timpului generalizată pentru un studiu de eveniment este prezentată în


figura următoare:

Figura 1: Axa timpului pentru un studiu de eveniment general

Perioada
Perioada Perioada post
de
evenimentului eveniment
estimare

T0 T1 0 T2 T3

✓ S-a convenit să se aleagă o perioadă de studiu a evenimentului


şi nu doar un singur moment de studiu, pentru a se realiza o

Anamaria Aldea, AACPI – ianuarie 2021 Page 2


analiză relevantă a efectelor evenimentului asupra evoluției
preţurilor acţiunilor companiilor incluse în studiu.

✓ De fapt, se analizează evoluţia rentabilităţii în exces (anormale)


pe durata perioadei evenimentului.

Pasul 2: se aleg companiile care vor fi incluse în studiu, în funcţie de criterii


prestabilite: disponibilitatea datelor privind evenimentul ales, lichiditatea
acţiunilor companiilor respective, etc.
Pasul 3: dintre modelele cunoscute în literatura de specialitate, se alege
modelul de estimare a rentabilităţii normale aşteptate a acţiunilor şi, apoi, se
face estimarea rentabilității normale aşteptate pentru perioada
evenimentului.
✓ Rentabilitatea normală aşteptată a acţiunii i ( R it ) este

rentabilitatea estimată pe piaţă pe perioada evenimentului, dar


calculată în lipsa acestuia.

✓ Rentabilitatea normală aşteptată se calculează pe baza


parametrilor estimaţi ai modelului ales şi aplicat pentru perioada
de estimare (estimation window). Perioada de estimare are o
lungime prestabilită de către autorul studiului (x zile) şi se
încheie în ziua precedentă celei în care începe perioada
evenimentului.

Pasul 4: Determinarea rentabilităţii în exces (anormale) ( AR it ) se face ca

diferenţă între rentabilitatea realizată efectiv şi rentabilitatea normală


aşteptată a acţiunii estimată pe perioada evenimentului, la pasul anterior.
Rentabilitatea realizată efectiv este cea înregistrată pe piaţă în zilele
perioadei evenimentului şi este determinată ca variaţie procentuală
zilnică a cursurilor de închidere ale acţiunilor companiilor considerate
în studiu.

Anamaria Aldea, AACPI – ianuarie 2021 Page 3


Pasul 5: Se testează ipoteza referitoare la faptul că rentabilitatea excesivă
(anormală) este statistic diferită de zero, folosind testul statistic t.

Revenind la modelarea rentabilităţii normale aşteptate (Pasul 3 –


modele din literatura de specialitate) pot fi folosite:

✓ modele statistice (de ex.: modelul rentabilităţii medii constante, unde


Xτ este o constantă)

✓ modele economice (de ex.: modelul factorial (single factor model sau
multiple factors model) sau modelul de piaţă (market model), care
presupune o relaţie liniară între rentabilitatea pieţei şi rentabilitatea
acţiunii).

În continuare se va folosi un model economic şi se testează modelul


de piaţă pentru o perioadă de estimare de N zile cu scopul de a obţine
parametrii modelului (  i ,  i ) exprimat sub forma de mai jos:

Rit = i + i Rmt +  it (1)


unde:
Rit = rentabilitatea acţiunii i în momentul t,

Rmt = rentabilitatea indicelui pieţei în momentul t,

 i , i = coeficienţii modelului, folosind datele pentru perioada

evenimentului,
εit= termenul eroare (diferenţa dintre rentabilitatea reală şi cea
estimată).
De obicei, aplicarea modelului de piaţă pentru companiile tranzacţionate
la bursă duce la concluzia că  i nu este statistic semnificativ diferit de zero.

Astfel, modelul utilizat pentru estimarea rentabilităţii normale ia forma:

Anamaria Aldea, AACPI – ianuarie 2021 Page 4


Rit = i Rmt +  it (2)

Pentru estimarea parametrilor modelului de piaţă, literatura de


specialitate consideră că 120 zile de tranzacţionare înainte de producerea
evenimentului sunt suficiente pentru o analiză pertinentă.

MacKinlay (1997) foloseşte o perioadă de estimare de 250 zile


anterioare realizării evenimentului, în timp ce în studiul Volis et. al. (2006)
făcut pentru companii tranzacţionate la BVB, perioada de estimare a cuprins
200 de zile de tranzacţionare.

De exemplu, schema grafică a realizării studiului de eveniment,


particularizat pentru o perioadă de 260 zile, în care perioada evenimentului
este de 10 zile poate avea forma:

Figura 2. Schema de realizare a unui studiu de eveniment

Analiştii îşi anunţă Compania anunţă


estimările privind rezultatele trimestriale
rezultatele trimestriale
Perioadă pentru
estimarea parametrilor Perioada post eveniment

T0=t-260 zile T3=t+260


T1=t-10 zile τ=t=0 T2=t+10 zile
zile
t-3 (5) zile

Perioada evenimentului

Anamaria Aldea, AACPI – ianuarie 2021 Page 5


Observaţie: în exemplul dat, se consideră cazul analiştilor financiari care
anunţă estimările privind rezultatele trimestriale ale companiilor (evenimentul).
Estimările analiştilor privind rezultatele financiare trimestriale ale companiilor sunt
transmise şi publicate pe platforma Reuters cu aproximativ 5 zile înaintea anunţului
rezultatelor trimestriale.

Anunţurile rezultatelor trimestriale pot fi clasificate în funcţie de


valoarea profitului net anunţat, comparativ cu media estimărilor analiştilor.

Astfel, un anunţ este:

✓ Pozitiv, dacă profitul net anunţat a fost mai mare cu 2.5% faţă de
media estimărilor analiştilor (MacKinlay (1997)) sau 5% în Volis et. al.
(2006) pentru studiul făcut pe România;

✓ Neutru, dacă acesta a fost de +2.5% în studiul lui MacKinlay,


respectiv +5% în cazul studiului Volis et. al. (2006);

✓ Negativ, dacă profitul anunţat a fost mai mic cu peste 2.5% decât
media estimărilor analiştilor.

De exemplu, un studiu din 2011 (Lipară, C.) foloseşte un prag de decizie de 10%, mai mare faţă
de celelalte două studii menţionate, din cauza calităţii mai scăzute a estimărilor rezultatelor
financiare. Calitatea scăzută este determinată nu doar de aptitudinile analiştilor care realizează
estimările, ci şi de alţi factori, de exemplu: apariţia unor elemente de cheltuieli/venituri care nu
se vor mai repeta, cum ar fi venituri din provizioane – vezi cazul OMV Petrom, dar şi din cauza
gradului mai redus de detaliere a rezultatelor financiare aferente trimestrului întâi şi respectiv
trei, transmise de companiile româneşti participanţilor pieţei comparativ cu cele de pe pieţele
mature.

Anamaria Aldea, AACPI – ianuarie 2021 Page 6


De obicei se foloseşte metoda celor mai mici pătrate (Ordinary Least
Squares-OLS) pentru a calcula parametrii modelului de piaţă. Astfel, pentru
compania i, aceştia sunt:

T1

 (R  −  )(R
 =T 0 +1
i i m − m )
i = T (3)
 (R
 =T 0 +1
m − m ) 2

şi i =  i − i  m unde:

R i  = rentabilitatea acţiunii i în orice momentul  al perioadei evenimentului;

R m = rentabilitatea pieţei în orice moment  al perioadei evenimentului;

i = media rentabilităţilor Ri înregistrate de acţiunea i pe perioada

evenimentului, folosind formula:

1 T1
i =  Ri
L1  =T 0 +1
(4) , unde:

L1 este lungimea perioadei de estimare, adică T1-T0

m = este media rentabilităţilor pieţei R m înregistrate pe perioada

evenimentului, folosind formula de mai jos:

1 T1
m =  R m
L1  =T 0 +1
(5)

Ecuaţia pentru calculul varianţei erorilor ˆ  i


2

Anamaria Aldea, AACPI – ianuarie 2021 Page 7


2

( )
T1
1
ˆi =
2
 Ri − ˆi − ˆi Rm
L1 − 2  =T0 +1
(6)

Rentabilitatea în exces (anormală), care este măsura impactului


evenimentului asupra preţului pieţei se va calcula ca diferenţa între
rentabilitatea realizată şi cea estimată pe durata ferestrei evenimentului (L 2,
adică T1-T2) pentru fiecare companie i.

Pentru compania i şi evenimentul  , se calculează apoi diferenţa dintre


rentabilitatea realizată şi rentabilitatea estimată:

AR i  = R i  −  i −  i R m (7)

unde AR i  = rentabilitatea în exces (anormală) pentru perioada  a ferestrei


evenimentului,

şi Ri = rentabilitatea realizată pentru perioada  a ferestrei evenimentului.

Rentabilitatea în exces va reprezenta termenul de “perturbare” al


modelului de piaţă şi se calculează pe baza unei abateri (bias) datorată
lucrului cu eşantioane.
În condiţiile unei ipoteze nule H0, conform căreia evenimentul nu are
nici un impact asupra comportamentului rentabilităţilor (fie folosind medii,
fie folosind varianţe), proprietăţile legii de distribuţie ale rentabilităţii în
exces pot fi folosite pentru a face inferenţă pe orice perioadă de timp din
fereastra de eveniment (event window).
Astfel, în condiţiile ipotezei nule, H0, distribuţia rentabilităţii în exces
calculată pe baza eşantionului pentru o observaţie dată din fereastra
eveniment este una normală de forma:

ARi N (0,  2 ( ARi ))

Anamaria Aldea, AACPI – ianuarie 2021 Page 8


Relaţia precedentă stă la baza ideii de agregare a rentabilităţilor în
exces pe perioada evenimentului.

Rentabilităţile în exces trebuie să fie însumate pentru fiecare pas al


perioadei evenimentului, în două direcţii: în timp şi pe mulţimea companiilor.

Se va face mai întâi o agregare în timp pentru un singur titlu şi apoi se


va face o agregare atât pe mulţimea titlurilor cât şi în timp.

Astfel, conceptul de rentabilitate în exces (anormală) cumulată va fi


aplicat pentru o fereastră a evenimentului cu perioade multiple (în cele ce
urmează vom considera 3 perioade).

Rentabilitatea în exces cumulată (CAR) de la  1 la  2 , (T1<  1 ≤  2

≤ T2), este:

2
CAR i ( 1 , 2 ) =  AR i  (8)
 =1

unde CAR i (1 , 2 ) = rentabilitatea în exces cumulată aferentă perioadei (  1 ,  2 )

pentru compania i,

AR i  = rentabilitatea în exces, înregistrată în momentul  pentru compania i.

Varianţa CAR se calculează astfel:

 i2 (1 , 2 ) = ( 2 −  1 + 1)   2
i (9)
Distribuţia rentabilităţii în exces cumulate în condiţiile ipotezei nule este:

CARi (1 ,1 ) N (0,  i2 (1 ,1 ))

Anamaria Aldea, AACPI – ianuarie 2021 Page 9


Prin însumarea tuturor rentabilităţilor în exces ale tuturor ştirilor,
pentru fiecare moment al perioadei, şi împărţind această sumă la numărul
total al ştirilor, media rentabilităţii în exces este calculată astfel:

N
1
AR  =
N
 AR 
i =1
i (10)

unde AR  este media rentabilităţilor în exces înregistrate pentru fiecare


moment  al perioadei eveniment.

Varianţa AR  este dată de formula:

N
1
var( AR ) =
N2
 
i =1
2
i
(11)

Aplicând acceaşi metodologie pentru o companie i, media


rentabilităţilor în exces poate fi cumulată pentru toate companiile, rezultând
o medie cumulată a rentabilităţilor în exces pentru orice interval din
fereastra eveniment, dată de ecuaţia:

2
CAR ( 1 , 2 ) =  AR (12)
 =1

unde CAR(t1, t2 ) = media CAR pentru perioada (  1 ,  2 ).

Varianţa mediei CAR va fi calculată astfel:


2
var(CAR ( 1 , 2 )) =  var(AR )
 =1
(13)
De asemenea, se poate calcula rentabilitatea în exces cumulată pentru
fiecare titlu în parte şi apoi se face agregarea în timp:
N
1
CAR( 1 , 2 ) =
N
 CAR ( ,
i =1
i 1 2 ), (14)

N
1
cu varianţa var(CAR( 1 , 2 )) =
N2

i =1
i
2
( 1 , 2 )

Anamaria Aldea, AACPI – ianuarie 2021 Page 10


Pentru a testa dacă rentabilitatea anormală medie este statistic
semnificativ diferită de zero în fiecare dintre zilele aferente perioadei
evenimentului, se foloseşte testul statistic t:

CAR( 1 , 2 )
tstat = (15)
var( AR)( 2 −  1 )

Figura 3 prezintă rezultatele obţinute pentru CAR pentru toate


companiile, pentru fiecare categorie de ştiri (bune, neutre şi rele), în cazul
celor două lucrări citate (MacKinlay (1997), Volis et. al. (2006)):

Figura 3. Rezultatele studiilor menţionate MacKinlay (1997) şi Volis et. al.


(2006)

MacKinlay (1997) Volis et. al. (2006)

Companii care au anunţat ştiri bune Companii care au anunţat ştiri neutre
Companii care au anunţat ştiri proaste
Companii care au anunţat ştiri neutre Companii care au anunţat ştiri bune

Companii care au anunţat ştiri proaste

Anamaria Aldea, AACPI – ianuarie 2021 Page 11


În exemplul în care s-a considerat anunţul rezultatelor trimestriale şi
anuale ca fiind ştirea la care investitorii reacţionează, rentabilităţile obţinute
ulterior anunţului rezultatelor companiilor arată dacă şi în ce măsură
preţurile acţiunilor diferă de valoarea lor intrinsecă. Aceste erori de apreciere
a preţului acţiunilor de către investitori putând fi utilizate pentru obţinerea
de rentabilităţi anormale.

Mărimea acestor rentabilităţi anormale arată dacă respectivele acţiuni


sunt supraevaluate sau subevaluate de piaţă, iar dacă perioada pentru care
acestea se înregistrează este una lungă, se poate afirma că a existat o
suprareacţie.

Pe termen mediu s-ar putea vorbi de crearea unui interes fie de


cumpărare, fie de vânzare, fie de păstrare în funcţie de modul în care au fost
percepute ştirile de către investitori.

Diferenţele între rezultatele reale trimestriale ale companiilor şi


estimările analiştilor reprezintă criteriul pe baza căruia s-a apreciat dacă
ştirea este pozitivă, negativă sau neutră şi în funcţie de care investitorii
reacţionează.

Reacţiile investitorilor au o magnitudine mai mare pe pieţele de capital


emergente şi pe cele de frontieră, deoarece acestea sunt caracterizate de o
volatilitate ridicată, dar şi de rentabilităţi excesive. În aceste condiţii,
testarea ipotezei pieţei eficiente poate avea rezultate neconcludente.

Anamaria Aldea, AACPI – ianuarie 2021 Page 12


References:

[1] Lipară, C. (2011) – Evaluarea acţiunilor – o abordare din perspectiva teoriilor comportamentale,
forthcoming
[2] MacKinlay, C. A. (1997), Event studies in economics and finance, Journal of Economic
Literature 35 (1): 13—39.
[3] Volis, A., Lipară, C., Tzineurakis, S. (2006) , Over-reaction and Under-reaction on Athens Stock
Exchange, The XII International Conference on Economic Cybernetics Sustainable Development
models for European Union Extension Process Cybernetics Conference, ASE Bucureşti, ISBN
973-594-864-8, ISBN 978-973-594-864-1

Anamaria Aldea, AACPI – ianuarie 2021 Page 13


Package ‘rmarkdown’
October 21, 2020
Type Package
Title Dynamic Documents for R
Version 2.5
Maintainer Yihui Xie <xie@yihui.name>
Description Convert R Markdown documents into a variety of formats.
Depends R (>= 3.0)
Imports tools, utils, knitr (>= 1.22), yaml (>= 2.1.19), htmltools (>=
0.3.5), evaluate (>= 0.13), jsonlite, tinytex (>= 0.11), xfun
(>= 0.15), methods, stringr (>= 1.2.0)
Suggests shiny (>= 0.11), tufte, testthat, digest, dygraphs, vctrs,
tibble, fs, rsconnect
SystemRequirements pandoc (>= 1.14) - http://pandoc.org

URL https://github.com/rstudio/rmarkdown

BugReports https://github.com/rstudio/rmarkdown/issues
License GPL-3
RoxygenNote 7.1.1
Encoding UTF-8
VignetteBuilder knitr
NeedsCompilation no
Author JJ Allaire [aut],
Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>),
Jonathan McPherson [aut],
Javier Luraschi [aut],
Kevin Ushey [aut],
Aron Atkins [aut],
Hadley Wickham [aut],
Joe Cheng [aut],
Winston Chang [aut],
Richard Iannone [aut] (<https://orcid.org/0000-0003-3925-190X>),
Andrew Dunning [ctb] (<https://orcid.org/0000-0003-0464-5036>),

1
2 R topics documented:

Atsushi Yasumoto [ctb, cph] (<https://orcid.org/0000-0002-8335-495X>,


Number sections Lua filter),
Barret Schloerke [ctb],
Christophe Dervieux [ctb],
Frederik Aust [ctb] (<https://orcid.org/0000-0003-4900-788X>),
Jeff Allen [ctb],
JooYoung Seo [ctb] (<https://orcid.org/0000-0002-4064-6012>),
Malcolm Barrett [ctb],
Rob Hyndman [ctb],
Romain Lesur [ctb],
Roy Storey [ctb],
Ruben Arslan [ctb],
Sergio Oller [ctb],
RStudio, PBC [cph],
jQuery Foundation [cph] (jQuery library),
jQuery contributors [ctb, cph] (jQuery library; authors listed in
inst/rmd/h/jquery-AUTHORS.txt),
jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in
inst/rmd/h/jqueryui-AUTHORS.txt),
Mark Otto [ctb] (Bootstrap library),
Jacob Thornton [ctb] (Bootstrap library),
Bootstrap contributors [ctb] (Bootstrap library),
Twitter, Inc [cph] (Bootstrap library),
Alexander Farkas [ctb, cph] (html5shiv library),
Scott Jehl [ctb, cph] (Respond.js library),
Ivan Sagalaev [ctb, cph] (highlight.js library),
Greg Franko [ctb, cph] (tocify library),
John MacFarlane [ctb, cph] (Pandoc templates),
Google, Inc. [ctb, cph] (ioslides library),
Dave Raggett [ctb] (slidy library),
W3C [cph] (slidy library),
Dave Gandy [ctb, cph] (Font-Awesome),
Ben Sperry [ctb] (Ionicons),
Drifty [cph] (Ionicons),
Aidan Lister [ctb, cph] (jQuery StickyTabs),
Benct Philip Jonsson [ctb, cph] (pagebreak Lua filter),
Albert Krewinkel [ctb, cph] (pagebreak Lua filter)
Repository CRAN
Date/Publication 2020-10-21 05:00:06 UTC

R topics documented:
rmarkdown-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
all_output_formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
beamer_presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
compile_notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
context_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
R topics documented: 3

default_output_format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
draft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
find_external_resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
find_pandoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
github_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
html-dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
html_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
html_document_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
html_fragment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
html_notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
html_notebook_metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
html_notebook_output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
html_vignette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
includes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
ioslides_presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
knitr_options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
knitr_options_html . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
knitr_options_pdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
knit_params_ask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
latex-dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
latex_dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
md_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
odt_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
output_format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
output_metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
paged_table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
pandoc_args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
pandoc_available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
pandoc_citeproc_convert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
pandoc_convert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
pandoc_exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
pandoc_options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
pandoc_path_arg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
pandoc_self_contained_html . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
pandoc_template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
parse_html_notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
pdf_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
pkg_file_lua . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
powerpoint_presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
publish_site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
relative_to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
render . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
render_delayed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
render_site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
render_supporting_files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
resolve_output_format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
rmarkdown_format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4 rmarkdown-package

rmd_metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
rtf_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
shiny_prerendered_chunk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
shiny_prerendered_clean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
site_resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
slidy_presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
tufte_handout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
word_document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Index 84

rmarkdown-package R Markdown Document Conversion

Description
Convert R Markdown documents into a variety of formats including HTML, MS Word, PDF, and
Beamer.

Details
The rmarkdown package includes high level functions for converting to a variety of formats. For
example:

render("input.Rmd", html_document())
render("input.Rmd", pdf_document())

You can also specify a plain markdown file in which case knitting will be bypassed:

render("input.md", html_document())

Additional options can be specified along with the output format:

render("input.Rmd", html_document(toc = TRUE))


render("input.Rmd", pdf_document(latex_engine = "lualatex"))
render("input.Rmd", beamer_presentation(incremental = TRUE))

You can also include arbitrary pandoc command line arguments along with the other options:

render("input.Rmd", pdf_document(toc = TRUE, pandoc_args = "--listings"))

See Also
render, html_document, pdf_document, word_document, beamer_presentation
all_output_formats 5

all_output_formats Determine all output formats for an R Markdown document

Description
Read the YAML metadata (and any common output YAML file) for the document and return the
output formats that will be generated by a call to render.

Usage
all_output_formats(input, output_yaml = NULL)

Arguments
input Input file (Rmd or plain markdown)
output_yaml Paths to YAML files specifying output formats and their configurations. The first
existing one is used. If none are found, then the function searches YAML files
specified to the output_yaml top-level parameter in the YAML front matter,
_output.yml or _output.yaml, and then uses the first existing one.

Details
This function is useful for front-end tools that require additional knowledge of the output to be
produced by render (e.g. to customize the preview experience).

Value
A character vector with the names of all output formats.

beamer_presentation Convert to a Beamer presentation

Description
Format for converting from R Markdown to a Beamer presentation.

Usage
beamer_presentation(
toc = FALSE,
slide_level = NULL,
number_sections = FALSE,
incremental = FALSE,
fig_width = 10,
fig_height = 7,
6 beamer_presentation

fig_crop = TRUE,
fig_caption = TRUE,
dev = "pdf",
df_print = "default",
theme = "default",
colortheme = "default",
fonttheme = "default",
highlight = "default",
template = "default",
keep_tex = FALSE,
keep_md = FALSE,
latex_engine = "pdflatex",
citation_package = c("default", "natbib", "biblatex"),
self_contained = TRUE,
includes = NULL,
md_extensions = NULL,
pandoc_args = NULL
)

Arguments
toc TRUE to include a table of contents in the output (only level 1 headers will be
included in the table of contents).
slide_level The heading level which defines individual slides. By default this is the highest
header level in the hierarchy that is followed immediately by content, and not
another header, somewhere in the document. This default can be overridden by
specifying an explicit slide_level.
number_sections
TRUE to number section headings
incremental TRUE to render slide bullets incrementally. Note that if you want to reverse the
default incremental behavior for an individual bullet you can precede it with >.
For example: > - Bullet Text
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_crop TRUE to automatically apply the pdfcrop utility (if available) to pdf figures
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to pdf)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
beamer_presentation 7

theme Beamer theme (e.g. "AnnArbor").


colortheme Beamer color theme (e.g. "dolphin").
fonttheme Beamer font theme (e.g. "structurebold").
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass
NULL to prevent syntax highlighting.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. See the documentation on pandoc
online documentation for details on creating custom templates.
keep_tex Keep the intermediate tex file used in the conversion to PDF
keep_md Keep the markdown file generated by knitting.
latex_engine LaTeX engine for producing PDF output. Options are "pdflatex", "lualatex", and
"xelatex".
citation_package
The LaTeX package to process citations, natbib or biblatex. Use default if
neither package is to be used, which means citations will be processed via the
command pandoc-citeproc.
self_contained Whether to generate a full LaTeX document (TRUE) or just the body of a La-
TeX document (FALSE). Note the LaTeX document is an intermediate file unless
keep_tex = TRUE.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details

See the online documentation for additional details on using the beamer_presentation format.
Creating Beamer output from R Markdown requires that LaTeX be installed.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value

R Markdown output format to pass to render


8 compile_notebook

Examples
## Not run:

library(rmarkdown)

# simple invocation
render("pres.Rmd", beamer_presentation())

# specify an option for incremental rendering


render("pres.Rmd", beamer_presentation(incremental = TRUE))

## End(Not run)

compile_notebook Compiling R scripts to a notebook

Description
R Markdown can also compile R scripts to a notebook which includes commentary, source code,
and script output. Notebooks can be compiled to any output format including HTML, PDF, and MS
Word.

Overview
To compile a notebook from an R script you simply pass the script to render. For example:
rmarkdown::render("analysis.R")
rmarkdown::render("analysis.R", "pdf_document")
The first call to render creates an HTML document, whereas the second creates a PDF document.
By default the name of the script, username, and current date and time are included in the header of
the generated notebook. You can override this default behavior by including explicit metadata in a
specially formatted R comment:
#' ---
#' title: "Crop Analysis Q3 2013"
#' author: "John Smith"
#' date: "May 3rd, 2014"
#' ---

Including Markdown
Note that the R comment used above to add a title, author, and date includes a single-quote as a
special prefix character. This is a roxygen2 style comment, and it’s actually possible to include
many such comments in an R script, all of which will be converted to markdown content within the
generated notebook. For example:
#' A script comment that includes **markdown** formatting.
Rather than displaying as an R comment in the compiled notebook any roxygen2 style comment
will be treated as markdown and rendered accordingly.
context_document 9

knitr Spin
Including markdown within R comments is possible because render calls the knitr spin function
to convert the R script to an Rmd file. The spin function also enables you to add knitr chunk options
with another special comment prefix (#+).
Here’s an example of a script that uses the various features of spin:
https://github.com/yihui/knitr/blob/master/inst/examples/knitr-spin.R
For more details on knitr::spin see the following documentation:
https://yihui.org/knitr/demo/stitch/

context_document Convert to a ConTeXt document

Description
Format for converting from R Markdown to PDF using ConTeXt.

Usage
context_document(
toc = FALSE,
toc_depth = 2,
number_sections = FALSE,
fig_width = 6.5,
fig_height = 4.5,
fig_crop = TRUE,
fig_caption = TRUE,
dev = "pdf",
df_print = "default",
template = NULL,
keep_tex = FALSE,
keep_md = FALSE,
citation_package = c("none", "natbib", "biblatex"),
includes = NULL,
md_extensions = NULL,
output_extensions = NULL,
pandoc_args = NULL,
context_path = NULL,
context_args = NULL,
ext = c(".pdf", ".tex")
)

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
10 context_document

number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_crop TRUE to automatically apply the pdfcrop utility (if available) to pdf figures
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to pdf)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. See the documentation on pandoc
online documentation for details on creating custom templates.
keep_tex Keep the intermediate tex file used in the conversion to PDF
keep_md Keep the markdown file generated by knitting.
citation_package
The LaTeX package to process citations, natbib or biblatex. Use default if
neither package is to be used, which means citations will be processed via the
command pandoc-citeproc.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
output_extensions
Pandoc extensions to be added or removed from the output format, e.g., "-smart"
means the output format will be latex-smart.
pandoc_args Additional command line options to pass to pandoc
context_path Path of the ConTeXt executable. If not provided, ConTeXt has to be available
from the PATH environment variable.
context_args Command line arguments passed to ConTeXt.
ext Format of the output document (defaults to ".pdf").

Details
ConTeXt needs to be installed. To install the most recent version, see https://wiki.contextgarden.
net/Installation. A less recent version is also available in TeX Live, you can install it with
tinytex::tlmgr_install("context").
default_output_format 11

R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value

R Markdown output format to pass to render.

Examples
## Not run:
library(rmarkdown)

# simple invocation
render("input.Rmd", context_document())

## End(Not run)

default_output_format Determine the default output format for an R Markdown document

Description

Read the YAML metadata (and any common output YAML file) for the document and return the
output format that will be generated by a call to render.

Usage

default_output_format(input, output_yaml = NULL)

Arguments

input Input file (Rmd or plain markdown)


output_yaml Paths to YAML files specifying output formats and their configurations. The first
existing one is used. If none are found, then the function searches YAML files
specified to the output_yaml top-level parameter in the YAML front matter,
_output.yml or _output.yaml, and then uses the first existing one.

Details

This function is useful for front-end tools that require additional knowledge of the output to be
produced by render (e.g. to customize the preview experience).
12 draft

Value
A named list with a name value containing the format name and an options value that is a list
containing all the options for the format and their values. An option’s default value will be returned
if the option isn’t set explicitly in the document.

draft Create a new document based on a template

Description
Create (and optionally edit) a draft of an R Markdown document based on a template.

Usage
draft(file, template, package = NULL, create_dir = "default", edit = TRUE)

Arguments
file File name for the draft
template Template to use as the basis for the draft. This is either the full path to a template
directory or the name of a template directory within the rmarkdown/templates
directory of a package.
package (Optional) Name of package where the template is located.
create_dir TRUE to create a new directory for the document (the "default" setting leaves this
behavior up to the creator of the template).
edit TRUE to edit the template immediately

Details
The draft function creates new R Markdown documents based on templates that are either located
on the filesystem or within an R package. The template and its supporting files will be copied to the
location specified by file.

Value
The file name of the new document (invisibly).

Note
An R Markdown template consists of a directory that contains a description of the template, a
skeleton Rmd file used as the basis for new documents, and optionally additional supporting files
that are provided along with the skeleton (e.g. a logo graphic).
If the template directory is contained within a package then it should be located at inst/rmarkdown/templates.
For example, a package named pubtools that wanted to provide a template named quarterly_report
would need to provide the following files within the pubtools/inst/rmarkdown/templates di-
rectory:
find_external_resources 13

quarterly_report/template.yaml
quarterly_report/skeleton/skeleton.Rmd

The template.yaml file should include a name field. If you want to ensure that a new directory is
always created for a given template, then you can add the create_dir field to the template.yaml
file. For example:
create_dir: true

The skeleton/skeleton.Rmd file should include the initial contents you want for files created from
this template. Additional files can be added to the skeleton directory, for example:
skeleton/logo.png

These files will automatically be copied to the directory containing the new R Markdown draft.

Examples
## Not run:
rmarkdown::draft("Q4Report.Rmd",
template="/opt/rmd/templates/quarterly_report")

rmarkdown::draft("Q4Report.Rmd",
template="quarterly_report", package="pubtools")

## End(Not run)

find_external_resources
Find External Resource References

Description

Given an R Markdown document or HTML file, attempt to determine the set of additional files
needed in order to render and display the document.

Usage

find_external_resources(input_file, encoding = "UTF-8")

Arguments

input_file path to the R Markdown document or HTML file to process


encoding Ignored. The encoding is always assumed to be UTF-8.
14 find_pandoc

Details
This routine applies heuristics in order to scan a document for possible resource references.
In R Markdown documents, it looks for references to files implicitly referenced in Markdown (e.g.
![alt](img.png)), in the document’s YAML header, in raw HTML chunks, and as quoted strings
in R code chunks (e.g. read.csv("data.csv")).
Resources specified explicitly in the YAML header for R Markdown documents are also returned.
To specify resources in YAML, use the resource_files key:

---
title: My Document
author: My Name
resource_files:
- data/mydata.csv
- images/figure.png
---

Each item in the resource_files list can refer to:

1. A single file, such as images/figure.png, or


2. A directory, such as resources/data, in which case all of the directory’s content will be
recursively included, or
3. A wildcard pattern, such as data/*.csv, in which case all of the files matching the pattern
will be included. No recursion is done in this case.

In HTML files (and raw HTML chunks in R Markdown documents), this routine searches for re-
sources specified in common tag attributes, such as <img src="...">, <link href="...">, etc.
In all cases, only resources that exist on disk and are contained in the document’s directory (or a
child thereof) are returned.

Value
A data frame with the following columns:

path The relative path from the document to the resource


explicit Whether the resource was specified explicitly (TRUE) or discovered implicitly (FALSE)
web Whether the resource is needed to display a Web page rendered from the document

find_pandoc Find the pandoc executable

Description
Searches for the pandoc executable in a few places and use the highest version found, unless a
specific version is requested.
github_document 15

Usage
find_pandoc(cache = TRUE, dir = NULL, version = NULL)

Arguments
cache Whether to search for pandoc again if a Pandoc directory containing the pandoc
executable of the expected version (if provided) has been found previously.
Search again if cache = FALSE.
dir A character vector of potential directory paths under which pandoc may be
found. If not provided, this function searches for pandoc from the environ-
ment variable RSTUDIO_PANDOC (the RStudio IDE will set this variable to
the directory of Pandoc bundled with the IDE), the environment variable PATH ,
and the directory ‘~/opt/pandoc/’.
version The version of Pandoc to look for (e.g., "2.9.2.1"). If not provided, this func-
tion searches for the highest version under the potential directories.

Value
A list containing the directory and version of Pandoc (if found).

Note
Usually you do not need to install Pandoc if you use the RStudio IDE, because the IDE has bundled
a version of Pandoc. If you have installed a version of Pandoc by yourself and want to use this
version instead, you may use the dir argument of this function.

Examples
rmarkdown::find_pandoc()
rmarkdown::find_pandoc(dir = '~/Downloads/Pandoc')
rmarkdown::find_pandoc(version = '2.7.3')

github_document Convert to GitHub Flavored Markdown

Description
Format for converting from R Markdown to GitHub Flavored Markdown.

Usage
github_document(
toc = FALSE,
toc_depth = 3,
number_sections = FALSE,
fig_width = 7,
fig_height = 5,
16 github_document

dev = "png",
df_print = "default",
includes = NULL,
md_extensions = NULL,
hard_line_breaks = TRUE,
pandoc_args = NULL,
html_preview = TRUE,
keep_html = FALSE
)

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
hard_line_breaks
TRUE to generate markdown that uses a simple newline to represent a line break
(as opposed to two-spaces and a newline).
pandoc_args Additional command line options to pass to pandoc
html_preview TRUE to also generate an HTML file for the purpose of locally previewing what
the document will look like on GitHub.
keep_html TRUE to keep the preview HTML file in the working directory. Default is FALSE.

Details
See the online documentation for additional details on using the github_document format.

Value
R Markdown output format to pass to render
html-dependencies 17

html-dependencies Provide common HTML dependencies for R Markdown formats

Description

These functions provide common HTML dependencies (e.g. jquery, bootstrap) for re-use by other
R Markdown formats.

Usage

html_dependency_jquery()

html_dependency_jqueryui()

html_dependency_bootstrap(theme)

html_dependency_tocify()

html_dependency_font_awesome()

html_dependency_ionicons()

html_dependency_pagedtable()

html_dependency_highlightjs(highlight)

Arguments

theme Visual theme ("default", "cerulean", "journal", "flatly", "darkly", "readable",


"spacelab", "united", "cosmo", "lumen", "paper", "sandstone", "simplex", or
"yeti"). Pass NULL for no theme (in this case you can use the css parameter
to add your own styles).
highlight Highlighter to use

html_document Convert to an HTML document

Description

Format for converting from R Markdown to an HTML document.


18 html_document

Usage
html_document(
toc = FALSE,
toc_depth = 3,
toc_float = FALSE,
number_sections = FALSE,
anchor_sections = TRUE,
section_divs = TRUE,
fig_width = 7,
fig_height = 5,
fig_retina = 2,
fig_caption = TRUE,
dev = "png",
df_print = "default",
code_folding = c("none", "show", "hide"),
code_download = FALSE,
self_contained = TRUE,
theme = "default",
highlight = "default",
mathjax = "default",
template = "default",
extra_dependencies = NULL,
css = NULL,
includes = NULL,
keep_md = FALSE,
lib_dir = NULL,
md_extensions = NULL,
pandoc_args = NULL,
...
)

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
toc_float TRUE to float the table of contents to the left of the main document content.
Rather than TRUE you may also pass a list of options that control the behavior of
the floating table of contents. See the Floating Table of Contents section below
for details.
number_sections
TRUE to number section headings
anchor_sections
TRUE to show section anchors when mouse hovers
section_divs Wrap sections in <div> tags, and attach identifiers to the enclosing <div> rather
than the header itself.
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
html_document 19

fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
code_folding Enable document readers to toggle the display of R code chunks. Specify "none"
to display all code chunks (assuming they were knit with echo = TRUE). Spec-
ify "hide" to hide all R code chunks by default (users can show hidden code
chunks either individually or document-wide). Specify "show" to show all R
code chunks by default.
code_download Embed the Rmd source code within the document and provide a link that can be
used by readers to download the code.
self_contained Produce a standalone HTML file with no external dependencies, using data:
URIs to incorporate the contents of linked scripts, stylesheets, images, and
videos. Note that even for self contained documents MathJax is still loaded
externally (this is necessary because of its size).
theme Visual theme ("default", "cerulean", "journal", "flatly", "darkly", "readable",
"spacelab", "united", "cosmo", "lumen", "paper", "sandstone", "simplex", or
"yeti"). Pass NULL for no theme (in this case you can use the css parameter
to add your own styles).
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", "haddock", and "text-
mate". Pass NULL to prevent syntax highlighting.
mathjax Include mathjax. The "default" option uses an https URL from a MathJax CDN.
The "local" option uses a local version of MathJax (which is copied into the out-
put directory). You can pass an alternate URL or pass NULL to exclude MathJax
entirely.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. Note that if you don’t use the "de-
fault" template then some features of html_document won’t be available (see
the Templates section below for more details).
extra_dependencies, ...
Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base
20 html_document

css One or more css files to include


includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
keep_md Keep the markdown file generated by knitting.
lib_dir Directory to copy dependent HTML libraries (e.g. jquery, bootstrap, etc.) into.
By default this will be the name of the document with _files appended to it.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details
See the online documentation for additional details on using the html_document format.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value
R Markdown output format to pass to render

Navigation Bars
If you have a set of html documents which you’d like to provide a common global navigation bar
for, you can include a "_navbar.yml" or "_navbar.html" file within the same directory as your html
document and it will automatically be included at the top of the document.
The "_navbar.yml" file includes title, type, left, and right fields (to define menu items for the
left and right of the navbar respectively). Menu items include title and href fields. For example:

title: "My Website"


type: default
left:
- text: "Home"
href: index.html
- text: "Other"
href: other.html
right:
- text: GitHub
href: https://github.com

The type field is optional and can take the value "default" or "inverse" (which provides a different
color scheme for the navigation bar).
Alternatively, you can include a "_navbar.html" file which is a full HTML definition of a boot-
strap navigation bar. For a simple example of including a navigation bar see https://github.
html_document 21

com/rstudio/rmarkdown-website/blob/master/_navbar.html. For additional documentation


on creating Bootstrap navigation bars see https://getbootstrap.com/docs/4.5/components/
navbar/.

Floating Table of Contents


You may specify a list of options for the toc_float parameter which control the behavior of the
floating table of contents. Options include:

• collapsed (defaults to TRUE) controls whether the table of contents appears with only the
top-level (H2) headers. When collapsed the table of contents is automatically expanded inline
when necessary.
• smooth_scroll (defaults to TRUE) controls whether page scrolls are animated when table of
contents items are navigated to via mouse clicks.
• print (defaults to TRUE) controls whether the table of contents appears when user prints out
the HTML page.

Tabbed Sections
You can organize content using tabs by applying the .tabset class attribute to headers within a
document. This will cause all sub-headers of the header with the .tabset attribute to appear within
tabs rather than as standalone sections. For example:

## Quarterly Results {.tabset}

### By Product

### By Region

You can also specify two additional attributes to control the appearance and behavior of the tabs.
The .tabset-fade attributes causes the tabs to fade in and out when switching. The .tabset-pills
attribute causes the visual appearance of the tabs to be "pill" rather than traditional tabs. For exam-
ple:

## Quarterly Results {.tabset .tabset-fade .tabset-pills}

Templates
You can provide a custom HTML template to be used for rendering. The syntax for templates is
described in the pandoc documentation. You can also use the basic pandoc template by passing
template = NULL.
Note however that if you choose not to use the "default" HTML template then several aspects of
HTML document rendering will behave differently:

• The theme parameter does not work (you can still provide styles using the css parameter).
• For the highlight parameter, the default highlighting style will resolve to "pygments" and
the "textmate" highlighting style is not available
• The toc_float parameter will not work.
22 html_document_base

• The code_folding parameter will not work.


• Tabbed sections (as described above) will not work.
• Navigation bars (as described above) will not work.
• MathJax will not work if self_contained is TRUE (these two options can’t be used together
in normal pandoc templates).

Due to the above restrictions, you might consider using the includes parameter as an alternative to
providing a fully custom template.

Examples
## Not run:
library(rmarkdown)

render("input.Rmd", html_document())

render("input.Rmd", html_document(toc = TRUE))

## End(Not run)

html_document_base Base output format for HTML-based output formats

Description

Creates an HTML base output format suitable for passing as the base_format argument of the
output_format function.

Usage

html_document_base(
theme = NULL,
self_contained = TRUE,
lib_dir = NULL,
mathjax = "default",
pandoc_args = NULL,
template = "default",
dependency_resolver = NULL,
copy_resources = FALSE,
extra_dependencies = NULL,
bootstrap_compatible = FALSE,
...
)
html_fragment 23

Arguments
theme Visual theme ("default", "cerulean", "journal", "flatly", "darkly", "readable",
"spacelab", "united", "cosmo", "lumen", "paper", "sandstone", "simplex", or
"yeti"). Pass NULL for no theme (in this case you can use the css parameter
to add your own styles).
self_contained Produce a standalone HTML file with no external dependencies, using data:
URIs to incorporate the contents of linked scripts, stylesheets, images, and
videos. Note that even for self contained documents MathJax is still loaded
externally (this is necessary because of its size).
lib_dir Directory to copy dependent HTML libraries (e.g. jquery, bootstrap, etc.) into.
By default this will be the name of the document with _files appended to it.
mathjax Include mathjax. The "default" option uses an https URL from a MathJax CDN.
The "local" option uses a local version of MathJax (which is copied into the out-
put directory). You can pass an alternate URL or pass NULL to exclude MathJax
entirely.
pandoc_args Additional command line options to pass to pandoc
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. Note that if you don’t use the "de-
fault" template then some features of html_document won’t be available (see
the Templates section below for more details).
dependency_resolver
A dependency resolver
copy_resources Copy resources
extra_dependencies
Extra dependencies as a list of the html_dependency class objects typically
generated by htmltools::htmlDependency().
bootstrap_compatible
Bootstrap compatible
... Ignored

Value
HTML base output format.

html_fragment Convert to an HTML fragment.

Description
An html fragment is suitable for inclusion into an external html page. See html_document for full
details - this is a minor variation that assumes you will include the output into an existing document
(e.g. a blog post).
24 html_fragment

Usage
html_fragment(
number_sections = FALSE,
section_divs = TRUE,
fig_width = 7,
fig_height = 5,
fig_retina = 2,
fig_caption = TRUE,
dev = "png",
df_print = "default",
mathjax = TRUE,
includes = NULL,
keep_md = FALSE,
md_extensions = NULL,
pandoc_args = NULL,
...
)

Arguments
number_sections
TRUE to number section headings
section_divs Wrap sections in <div> tags, and attach identifiers to the enclosing <div> rather
than the header itself.
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
mathjax TRUE to convert $ and $$ math blocks into MathJax compatible output. Note that
you’ll still need to ensure that the page where the fragment is included loads the
required MathJax scripts.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
html_notebook 25

keep_md Keep the markdown file generated by knitting.


md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc
... Additional arguments passed to html_document

Details
See the online documentation for additional details on using the html_fragment format.

Value
R Markdown output format to pass to render

html_notebook Convert to an HTML notebook

Description
Format for converting from R Markdown to an HTML notebook.

Usage
html_notebook(
toc = FALSE,
toc_depth = 3,
toc_float = FALSE,
number_sections = FALSE,
fig_width = 7,
fig_height = 5,
fig_retina = 2,
fig_caption = TRUE,
code_folding = "show",
theme = "default",
highlight = "textmate",
mathjax = "default",
extra_dependencies = NULL,
css = NULL,
includes = NULL,
md_extensions = NULL,
pandoc_args = NULL,
output_source = NULL,
self_contained = TRUE,
...
)
26 html_notebook

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
toc_float TRUE to float the table of contents to the left of the main document content.
Rather than TRUE you may also pass a list of options that control the behavior of
the floating table of contents. See the Floating Table of Contents section below
for details.
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
fig_caption TRUE to render figures with captions
code_folding Enable document readers to toggle the display of R code chunks. Specify "none"
to display all code chunks (assuming they were knit with echo = TRUE). Spec-
ify "hide" to hide all R code chunks by default (users can show hidden code
chunks either individually or document-wide). Specify "show" to show all R
code chunks by default.
theme Visual theme ("default", "cerulean", "journal", "flatly", "darkly", "readable",
"spacelab", "united", "cosmo", "lumen", "paper", "sandstone", "simplex", or
"yeti"). Pass NULL for no theme (in this case you can use the css parameter
to add your own styles).
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", "haddock", and "text-
mate". Pass NULL to prevent syntax highlighting.
mathjax Include mathjax. The "default" option uses an https URL from a MathJax CDN.
The "local" option uses a local version of MathJax (which is copied into the out-
put directory). You can pass an alternate URL or pass NULL to exclude MathJax
entirely.
extra_dependencies
Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base
css One or more css files to include
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc
output_source Define an output source for R chunks (ie, outputs to use instead of those pro-
duced by evaluating the underlying R code). See html_notebook_output for
more details.
html_notebook_metadata 27

self_contained Produce a standalone HTML file with no external dependencies. Defaults to


TRUE. In notebooks, setting this to FALSE is not recommended, since the setting
does not apply to embedded notebook output such as plots and HTML widgets.
... Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base

Details
See the online documentation for additional details on using the html_notebook format.

html_notebook_metadata
Generate R Notebook Metadata

Description
A structured helper for the construction of metadata used by the R Notebook output functions. See
html_notebook_output for more details.

Usage
html_notebook_metadata(iframe = TRUE)

Arguments
iframe Boolean; should output be shown in an <iframe>?

html_notebook_output Generate R Notebook Output

Description
Utilities for generating output for the html_notebook format, through the output_source function
attached to a output_format.

Usage
html_notebook_output_html(html, meta = NULL)

html_notebook_output_img(
path = NULL,
bytes = NULL,
attributes = NULL,
meta = NULL,
format = c("png", "jpeg")
)
28 html_vignette

html_notebook_output_png(
path = NULL,
bytes = NULL,
attributes = NULL,
meta = NULL,
format = c("png", "jpeg")
)

html_notebook_output_code(code, attributes = list(class = "r"), meta = NULL)

Arguments
html Arbitrary HTML content to insert.
meta An R list of arbitrary meta-data. The data will be converted to JSON, base64-
encoded, and injected into the header comment.
path A path to a file. For functions accepting both path and bytes, if bytes is NULL,
the bytewise contents will be obtained by reading the file.
bytes The bytewise representation of content.
attributes A named R list of HTML attributes. These will be escaped and inserted into the
generated HTML as appropriate.
format The image format; one of "png" or "jpeg".
code Source code.

Details
See the online documentation for additional details on using the html_notebook format.

html_vignette Convert to an HTML vignette

Description
A HTML vignette is a lightweight alternative to html_document suitable for inclusion in packages
to be released to CRAN. It reduces the size of a basic vignette from 100k to around 10k.

Usage
html_vignette(
fig_width = 3,
fig_height = 3,
dev = "png",
df_print = "default",
css = NULL,
keep_md = FALSE,
html_vignette 29

readme = FALSE,
self_contained = TRUE,
...
)

Arguments
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
css One or more css files to include
keep_md Keep the markdown file generated by knitting.
readme Use this vignette as the package README.md file (i.e. render it as README.md
to the package root). Note that if there are image files within your vignette you
should be sure to add README_files to .Rbuildignore
self_contained Produce a standalone HTML file with no external dependencies, using data:
URIs to incorporate the contents of linked scripts, stylesheets, images, and
videos. Note that even for self contained documents MathJax is still loaded
externally (this is necessary because of its size).
... Additional arguments passed to html_document. Please note that theme, fig_retina
and highlight are hard coded. Setting any of those will yield an error.

Details
Compared to html_document, it:

• never uses retina figures


• never uses a theme
• has a smaller default figure size
• uses a custom css stylesheet
• uses a custom highlight scheme

See the online documentation for additional details on using the html_vignette format.

Value
R Markdown output format to pass to render
30 includes

includes Include content within output

Description

Specify additional content to be included within an output document.

Usage

includes(in_header = NULL, before_body = NULL, after_body = NULL)

includes_to_pandoc_args(includes, filter = identity)

Arguments

in_header One or more files with content to be included in the header of the document.
before_body One or more files with content to be included before the document body.
after_body One or more files with content to be included after the document body.
includes Includes to convert to pandoc args.
filter Filter to pre-process includes with.

Details

Non-absolute paths for resources referenced from the in_header, before_body, and after_body
parameters are resolved relative to the directory of the input document.

Value

Includes list or pandoc args

Examples
## Not run:
library(rmarkdown)

html_document(includes = includes(before_body = "header.htm"))

pdf_document(includes = includes(after_body = "footer.tex"))

## End(Not run)
ioslides_presentation 31

ioslides_presentation Convert to an ioslides Presentation

Description
Format for converting from R Markdown to an ioslides presentation.

Usage
ioslides_presentation(
number_sections = FALSE,
logo = NULL,
slide_level = 2,
incremental = FALSE,
fig_width = 7.5,
fig_height = 4.5,
fig_retina = 2,
fig_caption = TRUE,
dev = "png",
df_print = "default",
smart = TRUE,
self_contained = TRUE,
widescreen = FALSE,
smaller = FALSE,
transition = "default",
mathjax = "default",
analytics = NULL,
template = NULL,
css = NULL,
includes = NULL,
keep_md = FALSE,
lib_dir = NULL,
md_extensions = NULL,
pandoc_args = NULL,
extra_dependencies = NULL,
...
)

Arguments
number_sections
TRUE to number section headings
logo Path to file that includes a logo for use in the presentation (should be square and
at least 128x128).
slide_level Header level to consider as slide separator (Defaults to header 2).
32 ioslides_presentation

incremental TRUE to render slide bullets incrementally. Note that if you want to reverse the
default incremental behavior for an individual bullet you can preceded it with >.
For example: > - Bullet Text.
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
smart Produce typographically correct output, converting straight quotes to curly quotes,
--- to em-dashes, -- to en-dashes, and ... to ellipses.
self_contained Produce a standalone HTML file with no external dependencies, using data:
URIs to incorporate the contents of linked scripts, stylesheets, images, and
videos. Note that even for self contained documents MathJax is still loaded
externally (this is necessary because of its size).
widescreen Display presentation with wider dimensions.
smaller Use smaller text on all slides. You can also enable this for individual slides by
adding the .smaller attribute to the slide header (see Presentation Size below
for details).
transition Speed of slide transitions. This can be "default", "slower", "faster", or a numeric
value with a number of seconds (e.g. 0.5).
mathjax Include mathjax. The "default" option uses an https URL from a MathJax CDN.
The "local" option uses a local version of MathJax (which is copied into the out-
put directory). You can pass an alternate URL or pass NULL to exclude MathJax
entirely.
analytics A Google analytics property ID.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. Note that if you don’t use the "de-
fault" template then some features of html_document won’t be available (see
the Templates section below for more details).
css One or more css files to include
ioslides_presentation 33

includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
keep_md Keep the markdown file generated by knitting.
lib_dir Directory to copy dependent HTML libraries (e.g. jquery, bootstrap, etc.) into.
By default this will be the name of the document with _files appended to it.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc
extra_dependencies
Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base
... Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base

Details
See the online documentation for additional details on using the ioslides_presentation format.
Note that, if a before_body include is specified in includes, then it will replace the standard title
slide entirely.

Value
R Markdown output format to pass to render.

Slide Basics
You can create a slide show broken up into sections by using the # and ## heading tags (you can
also create a new slide without a header using a horizontal rule (----------). For example here’s
a simple slide show:

---
title: "Habits"
author: John Doe
date: March 22, 2005
output: ioslides_presentation
---

# In the morning

## Getting up

- Turn off alarm


- Get out of bed

## Breakfast

- Eat eggs
34 ioslides_presentation

- Drink coffee

# In the evening

## Dinner

- Eat spaghetti
- Drink wine

----------

![picture of spaghetti](images/spaghetti.jpg)

## Going to sleep

- Get in bed
- Count sheep

You can add a subtitle to a slide or section by including text after the pipe (|) character. For example:

## Getting up | What I like to do first thing

Display Modes
The following single character keyboard shortcuts enable alternate display modes:
• 'f' enable fullscreen mode
• 'w' toggle widescreen mode
• 'o' enable overview mode
• 'h' enable code highlight mode
• 'p' show presenter notes
Pressing Esc exits all of these modes. See the sections below on Code Highlighting and Presenter
Mode for additional detail on those modes.

Incremental Bullets
You can render bullets incrementally by adding the incremental option:

---
output:
ioslides_presentation:
incremental: true
---

If you want to render bullets incrementally for some slides but not others you can use this syntax:

> - Eat eggs


> - Drink coffee
ioslides_presentation 35

Presentation Size
You can display the presentation using a wider form factor using the widescreen option. You can
specify that smaller text be used with the smaller option. For example:

---
output:
ioslides_presentation:
widescreen: true
smaller: true
---

You can also enable the smaller option on a slide-by-slide basis by adding the .smaller attibute
to the slide header:

## Getting up {.smaller}

Adding a Logo
You can add a logo to the presentation using the logo option (the logo should be square and at least
128x128). For example:

---
output:
ioslides_presentation:
logo: logo.png
---

A 128x128 version of the logo graphic will be added to the title slide and an icon version of the
logo will be included in the bottom-left footer of each slide.

Build Slides
Slides can also have a .build attribute that indicate that their content should be displayed incre-
mentally. For example:

## Getting up {.build}

Slide attributes can be combined if you need to specify more than one, for example:

## Getting up {.smaller .build}

Code Highlighting
It’s possible to select subsets of code for additional emphasis by adding a special "highlight" com-
ment around the code. For example:

### <b>
x <- 10
y <- x * 2
### </b>
36 ioslides_presentation

The highlighted region will be displayed with a bold font. When you want to help the audience
focus exclusively on the highlighted region press the 'h' key and the rest of the code will fade
away.

Tables

The ioslides template has an attractive default style for tables so you shouldn’t hesitate to add tables
for presenting more complex sets of information. Pandoc markdown supports several syntaxes for
defining tables which are described in the pandoc online documentation.

Advanced Layout

You can center content on a slide by adding the .flexbox and .vcenter attributes to the slide title.
For example:

## Dinner {.flexbox .vcenter}

You can horizontally center content by enclosing it in a div tag with class centered. For example:

<div class="centered">
This text is centered.
</div>

You can do a two-column layout using the columns-2 class. For example:

<div class="columns-2">
![Image](image.png)

- Bullet 1
- Bullet 2
- Bullet 3
</div>

Note that content will flow across the columns so if you want to have an image on one side and text
on the other you should make sure that the image has sufficient height to force the text to the other
side of the slide.

Text Color

You can color content using base color classes red, blue, green, yellow, and gray (or variations of
them e.g. red2, red3, blue2, blue3, etc.). For example:

<div class="red2">
This text is red
</div>
knitr_options 37

Presenter Mode
A separate presenter window can also be opened (ideal for when you are presenting on one screen
but have another screen that’s private to you). The window stays in sync with the main presentation
window and also shows presenter notes and a thumbnail of the next slide. To enable presenter mode
add ?presentme=true to the URL of the presentation, for example:

mypresentation.html?presentme=true

The presenter mode window will open and will always re-open with the presentation until it’s dis-
abled with:

mypresentation.html?presentme=false

To add presenter notes to a slide you include it within a "notes" div. For example:

<div class="notes">
This is my *note*.

- It can contain markdown


- like this list

</div>

Printing and PDF Output


You can print an ioslides presentation from within browsers that have good support for print CSS
(i.e. as of this writing Google Chrome has the best support). Printing maintains most of the visual
styles of the HTML version of the presentation.
To create a PDF version of a presentation you can use Print to PDF from Google Chrome.

knitr_options Knitr options for an output format

Description
Define the knitr options for an R Markdown output format.

Usage
knitr_options(
opts_knit = NULL,
opts_chunk = NULL,
knit_hooks = NULL,
opts_hooks = NULL,
opts_template = NULL
)
38 knitr_options_html

Arguments
opts_knit List of package level knitr options (see opts_knit)
opts_chunk List of chunk level knitr options (see opts_chunk)
knit_hooks List of hooks for R code chunks, inline R code, and output (see knit_hooks)
opts_hooks List of hooks for code chunk options (see opts_hooks)
opts_template List of templates for chunk level knitr options (see opts_template)

Value
An list that can be passed as the knitr argument of the output_format function.

See Also
output_format

knitr_options_html Knitr options for an HTML output format

Description
Define knitr options for an R Markdown output format that creates HTML output.

Usage
knitr_options_html(fig_width, fig_height, fig_retina, keep_md, dev = "png")

Arguments
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
keep_md Keep the markdown file generated by knitting.
dev Graphics device to use for figure output (defaults to png)

Value
An list that can be passed as the knitr argument of the output_format function.

See Also
knitr_options, output_format
knitr_options_pdf 39

knitr_options_pdf Knitr options for a PDF output format

Description
Define knitr options for an R Markdown output format that creates PDF output.

Usage
knitr_options_pdf(fig_width, fig_height, fig_crop, dev = "pdf")

Arguments
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_crop TRUE to automatically apply the pdfcrop utility (if available) to pdf figures
dev Graphics device to use for figure output (defaults to png)

Value
An list that can be passed as the knitr argument of the output_format function.

See Also
knitr_options, output_format

knit_params_ask Run a shiny application asking for parameter configuration for the
given document.

Description
Run a shiny application asking for parameter configuration for the given document.

Usage
knit_params_ask(
file = NULL,
input_lines = NULL,
params = NULL,
shiny_args = NULL,
save_caption = "Save",
encoding = "UTF-8"
)
40 latex-dependencies

Arguments

file Path to the R Markdown document with configurable parameters.


input_lines Content of the R Markdown document. If NULL, the contents of file will be
read.
params A named list of optional parameter overrides used in place of the document
defaults.
shiny_args Additional arguments to runApp.
save_caption Caption to use use for button that saves/confirms parameters.
encoding Ignored. The encoding is always assumed to be UTF-8.

Value

named list with overridden parameter names and value.

latex-dependencies Provide common LaTeX dependencies

Description

These functions provide common LaTeX dependencies (e.g. tikz) for R Markdown formats that use
LaTeX.

Usage

latex_dependency_tikz(libraries, options = NULL, extra_lines = NULL)

Arguments

libraries A character vector of tikz libraries to load


options The LaTeX options for the package
extra_lines LaTeX code related to the package added to the preamble
latex_dependency 41

latex_dependency Define a LaTeX package dependency

Description
Define a LaTeX package dependency

Usage
latex_dependency(name, options = NULL, extra_lines = NULL)

Arguments
name The LaTeX package name
options The LaTeX options for the package
extra_lines LaTeX code related to the package added to the preamble

md_document Convert to a markdown document

Description
Format for converting from R Markdown to another variant of markdown (e.g. strict markdown or
github flavored markdown)

Usage
md_document(
variant = "markdown_strict",
preserve_yaml = FALSE,
toc = FALSE,
toc_depth = 3,
number_sections = FALSE,
fig_width = 7,
fig_height = 5,
fig_retina = NULL,
dev = "png",
df_print = "default",
includes = NULL,
md_extensions = NULL,
pandoc_args = NULL,
ext = ".md"
)
42 md_document

Arguments
variant Markdown variant to produce (defaults to "markdown_strict"). Other valid val-
ues are "commonmark", "markdown_github", "markdown_mmd", markdown_phpextra",
or even "markdown" (which produces pandoc markdown). You can also com-
pose custom markdown variants, see the pandoc online documentation for de-
tails.
preserve_yaml Preserve YAML front matter in final document.
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays. Defaults to NULL which performs no
scaling. A setting of 2 will work for all widely used retina displays, but will also
result in the output of <img> tags rather than markdown images due to the need
to set the width of the image explicitly.
dev Graphics device to use for figure output (defaults to png)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc
ext Extention of the output document (defaults to ".md").

Details
See the online documentation for additional details on using the md_document format.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.

Value
R Markdown output format to pass to render
metadata 43

Examples
## Not run:
library(rmarkdown)

render("input.Rmd", md_document())

render("input.Rmd", md_document(variant = "markdown_github"))

## End(Not run)

metadata The YAML metadata of the current R Markdown document

Description
The object metadata stores the YAML metadata of the current R Markdown document as a list,
which you may use in the R code chunks, e.g. rmarkdown::metadata$title (the title of the doc-
ument), rmarkdown::metadata$author, and rmarkdown::metadata$foo (if you have a YAML
field named foo), etc.

Format
An object of class list of length 0.

Examples
rmarkdown::metadata

odt_document Convert to an OpenDocument Text (ODT) document

Description
Format for converting from R Markdown to an ODT document.

Usage
odt_document(
number_sections = FALSE,
fig_width = 5,
fig_height = 4,
fig_caption = TRUE,
template = "default",
reference_odt = "default",
includes = NULL,
keep_md = FALSE,
44 odt_document

md_extensions = NULL,
pandoc_args = NULL
)

Arguments
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_caption TRUE to render figures with captions
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. See the documentation on pandoc
online documentation for details on creating custom templates.
reference_odt Use the specified file as a style reference in producing an odt file. For best
results, the reference odt should be a modified version of an odt file produced
using pandoc. Pass "default" to use the rmarkdown default styles.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
keep_md Keep the markdown file generated by knitting.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details
See the online documentation for additional details on using the odt_document format.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value
R Markdown output format to pass to render

Examples
## Not run:
library(rmarkdown)

# simple invocation
render("input.Rmd", odt_document())

# specify an option for syntax highlighting


output_format 45

render("input.Rmd", odt_document(highlight = "zenburn"))

## End(Not run)

output_format Define an R Markdown output format

Description
Define an R Markdown output format based on a combination of knitr and pandoc options.

Usage
output_format(
knitr,
pandoc,
keep_md = FALSE,
clean_supporting = TRUE,
df_print = NULL,
pre_knit = NULL,
post_knit = NULL,
pre_processor = NULL,
intermediates_generator = NULL,
post_processor = NULL,
on_exit = NULL,
file_scope = NULL,
base_format = NULL
)

Arguments
knitr Knitr options for an output format (see knitr_options)
pandoc Pandoc options for an output format (see pandoc_options)
keep_md Keep the markdown file generated by knitting. Note that if this is TRUE then
clean_supporting will always be FALSE.
clean_supporting
Cleanup any supporting files after conversion see render_supporting_files
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
46 output_format

pre_knit An optional function that runs before knitting which receives the input (input
filename passed to render) and ... (for future expansion) arguments.
post_knit An optional function that runs after knitting which receives the metadata, input_file,
runtime, and ... (for future expansion) arguments. This function can return
additional arguments to pass to pandoc and can call knitr::knit_meta_add to
add additional dependencies based on the contents of the input_file or on other
assets side by side with it that may be used to produce html with dependencies
during subsequent processing.
pre_processor An optional pre-processor function that receives the metadata, input_file,
runtime, knit_meta, files_dir, and output_dir and can return additional
arguments to pass to pandoc.
intermediates_generator
An optional function that receives the original input_file, and the intermedi-
ates directory (i.e. the intermediates_dir argument to render). The function
should generate and return the names of any intermediate files required to render
the input_file.
post_processor An optional post-processor function that receives the metadata, input_file,
output_file, clean, and verbose parameters, and can return an alternative
output_file.
on_exit A function to call when rmarkdown::render() finishes execution (as registered
with a on.exit handler).
file_scope A function that will split markdown input to pandoc into multiple named files.
This is useful when the caller has concatenated a set of Rmd files together (as
bookdown does), and those files may need to processed by pandoc using the
--file-scope option. The function should return a named list of files w/ name
and content for each file.
base_format An optional format to extend.

Value

An R Markdown output format definition that can be passed to render.

See Also

render, knitr_options, pandoc_options

Examples
## Not run:
output_format(knitr = knitr_options(opts_chunk = list(dev = 'png')),
pandoc = pandoc_options(to = "html"))

## End(Not run)
paged_table 47

output_metadata The output metadata object

Description
This object provides a mechanism for users to attach metadata as an attribute (named rmd_output_metadata)
of the returned value of render(). The initial value of the metadata comes from in the rmd_output_metadata
field of the YAML frontmatter of an R Markdown document. The metadata can be queried via the
output_metadata$get() method, and modified via the output_metadata$set() method.

paged_table Create a table in HTML with support for paging rows and columns

Description
Create a table in HTML with support for paging rows and columns

Usage
paged_table(x, options = NULL)

Arguments
x a data frame to be rendered as a paged table.
options options for printing the paged table. See details for specifics.

Details
Below are the recognized table pagination options.

Option Description Default


max.print The number of rows to print. 1000
sql.max.print The number of rows to print from a SQL data table. 1000
rows.print The number of rows to display. 10
cols.print The number of columns to display. 10
cols.min.print The minimum number of columns to display. -
pages.print The number of pages to display under page navigation. -
paged.print When set to FALSE turns off paged tables. TRUE
rownames.print When set to FALSE turns off row names. TRUE

Note: There is a hard cap of 10,000 rows to ensure that pandoc will not fail when rendering the
document.
48 pandoc_args

pandoc_args Functions for generating pandoc command line arguments

Description

Functions that assist in creating various types of pandoc command line arguments (e.g. for tem-
plates, table of contents, highlighting, and content includes).

Usage

pandoc_variable_arg(name, value)

pandoc_metadata_arg(name, value)

pandoc_include_args(in_header = NULL, before_body = NULL, after_body = NULL)

pandoc_highlight_args(highlight, default = "tango")

pandoc_latex_engine_args(latex_engine)

pandoc_toc_args(toc, toc_depth = 3)

pandoc_citeproc_args()

pandoc_lua_filter_args(lua_files)

Arguments

name Name of template variable to set.


value Value of template variable (defaults to true if missing).
in_header One or more files with content to be included in the header of the document.
before_body One or more files with content to be included before the document body.
after_body One or more files with content to be included after the document body.
highlight The name of a pandoc syntax highlighting theme.
default The highlighting theme to use if "default" is specified.
latex_engine LaTeX engine for producing PDF output. Options are "pdflatex", "lualatex", and
"xelatex".
toc TRUE to include a table of contents in the output.
toc_depth Depth of headers to include in table of contents.
lua_files Character vector of file paths to Lua filter files. Paths will be transformed by
pandoc_path_arg.
pandoc_available 49

Details
Non-absolute paths for resources referenced from the in_header, before_body, and after_body
parameters are resolved relative to the directory of the input document.

Value
A character vector with pandoc command line arguments.

About Pandoc citeproc


For Pandoc version before 2.11, a pandoc filter ‘pandoc-citeproc’ is used. Since Pandoc 2.11, the
feature is built-in and activated using ‘--citeproc’ flag. ‘pandoc_citeproc_arg’ will return the
correct switches depending on the Pandoc version in use.

Examples
## Not run:
library(rmarkdown)

pandoc_include_args(before_body = "header.htm")
pandoc_include_args(before_body = "header.tex")

pandoc_highlight_args("kate")

pandoc_latex_engine_args("pdflatex")

pandoc_toc_args(toc = TRUE, toc_depth = 2)

## End(Not run)

pandoc_available Check pandoc availability and version

Description
Determine whether pandoc is currently available on the system (optionally checking for a specific
version or greater). Determine the specific version of pandoc available.

Usage
pandoc_available(version = NULL, error = FALSE)

pandoc_version()

Arguments
version Required version of pandoc
error Whether to signal an error if pandoc with the required version is not found
50 pandoc_citeproc_convert

Details
The system environment variable ‘PATH’ as well as the version of pandoc shipped with RStudio (its
location is set via the environment variable ‘RSTUDIO_PANDOC’ by RStudio products like the RStudio
IDE, RStudio Server, Shiny Server, and RStudio Connect, etc) are scanned for pandoc and the
highest version available is used. Please do not modify the environment variable ‘RSTUDIO_PANDOC’
unless you know what it means.

Value
pandoc_available returns a logical indicating whether the required version of pandoc is available.
pandoc_version returns a numeric_version with the version of pandoc found.

Examples
## Not run:
library(rmarkdown)

if (pandoc_available())
cat("pandoc", as.character(pandoc_version()), "is available!\n")

if (pandoc_available("1.12.3"))
cat("required version of pandoc is available!\n")

## End(Not run)

pandoc_citeproc_convert
Convert a bibliograpy file

Description
Convert a bibliography file (e.g. a BibTeX file) to an R list, JSON text, or YAML text

Usage
pandoc_citeproc_convert(file, type = c("list", "json", "yaml"))

Arguments
file Bibliography file
type Conversion type

Value
For ‘type = "list"‘, and R list. For ‘type = "json"‘ or ‘type = "yaml"‘, a character vector with the
specified format.
pandoc_convert 51

pandoc_convert Convert a document with pandoc

Description

Convert documents to and from various formats using the pandoc utility.

Usage

pandoc_convert(
input,
to = NULL,
from = NULL,
output = NULL,
citeproc = FALSE,
options = NULL,
verbose = FALSE,
wd = NULL
)

Arguments

input Character vector containing paths to input files (files must be UTF-8 encoded)
to Format to convert to (if not specified, you must specify output)
from Format to convert from (if not specified then the format is determined based on
the file extension of input).
output Output file (if not specified then determined based on format being converted
to).
citeproc TRUE to run the pandoc-citeproc filter (for processing citations) as part of the
conversion.
options Character vector of command line options to pass to pandoc.
verbose TRUE to show the pandoc command line which was executed
wd Working directory in which code will be executed. If not supplied, defaults to
the common base directory of input.

Details

Supported input and output formats are described in the pandoc user guide.
The system path as well as the version of pandoc shipped with RStudio (if running under RStudio)
are scanned for pandoc and the highest version available is used.
52 pandoc_options

Examples

## Not run:
library(rmarkdown)

# convert markdown to various formats


pandoc_convert("input.md", to = "html")
pandoc_convert("input.md", to = "latex")

# process citations
pandoc_convert("input.md", to = "html", citeproc = TRUE)

# add some pandoc options


pandoc_convert("input.md", to = "latex", options = c("--listings"))

## End(Not run)

pandoc_exec Get the path of the pandoc executable

Description

Returns the path of the pandoc executable used by functions in the the rmarkdown package. This
is the most recent version of pandoc found in either the system path or shipped with RStudio.

Usage

pandoc_exec()

Details

See the pandoc manual for pandoc commands.

pandoc_options Pandoc options for an output format

Description

Define the pandoc options for an R Markdown output format.


pandoc_options 53

Usage

pandoc_options(
to,
from = rmarkdown_format(),
args = NULL,
keep_tex = FALSE,
latex_engine = c("pdflatex", "lualatex", "xelatex"),
ext = NULL,
lua_filters = NULL
)

Arguments

to Pandoc format to convert to


from Pandoc format to convert from
args Character vector of command line arguments to pass to pandoc
keep_tex Keep the intermediate tex file used in the conversion to PDF (applies only to
’latex’ and ’beamer’ target formats)
latex_engine LaTeX engine to producing PDF output (applies only to ’latex’ and ’beamer’
target formats)
ext File extension (e.g. ".tex") for output file (if NULL chooses default based on to).
This is typically used to force the final output of a latex or beamer conversion to
be .tex rather than .pdf.
lua_filters Character vector of file paths to Lua filters to use with this format. They will
be added to pandoc command line call using --lua-filter argument. See
vignette("lua-filters",package = "rmarkdown") to know more about Lua
filters.

Details

The from argument should be used very cautiously as it’s important for users to be able to rely on a
stable definition of supported markdown extensions.

Value

An list that can be passed as the pandoc argument of the output_format function.

See Also

output_format, rmarkdown_format
54 pandoc_self_contained_html

pandoc_path_arg Transform path for passing to pandoc

Description
Transform a path for passing to pandoc on the command line. Calls path.expand on all platforms.
On Windows, transform it to a short path name if it contains spaces, and then convert forward
slashes to back slashes (as required by pandoc for some path references).

Usage
pandoc_path_arg(path, backslash = TRUE)

Arguments
path Path to transform
backslash Whether to replace forward slashes in path with backslashes on Windows.

Value
Transformed path that can be passed to pandoc on the command line.

pandoc_self_contained_html
Create a self-contained HTML document using pandoc.

Description
Create a self-contained HTML document by base64 encoding images, scripts, and stylesheets re-
ferred by the input document.

Usage
pandoc_self_contained_html(input, output)

Arguments
input Input html file to create self-contained version of.
output Path to save output.

Value
(Invisibly) The path of the generated file.
pandoc_template 55

pandoc_template Render a pandoc template.

Description
Use the pandoc templating engine to render a text file. Substitutions are done using the metadata
list passed to the function.

Usage
pandoc_template(metadata, template, output, verbose = FALSE)

Arguments
metadata A named list containing metadata to pass to template.
template Path to a pandoc template.
output Path to save output.
verbose TRUE to show the pandoc command line which was executed.

Value
(Invisibly) The path of the generated file.

parse_html_notebook Parse an HTML Notebook

Description
Parse an HTML notebook, retrieving annotation information related to generated outputs in the
document, as well as the original R Markdown source document.

Usage
parse_html_notebook(path)

Arguments
path The path to an R Notebook file (with extension .nb.html).

Details
See the online documentation for additional details on using the html_notebook format.
56 pdf_document

pdf_document Convert to a PDF/LaTeX document

Description
Formats for converting from R Markdown to a PDF or LaTeX document.

Usage
pdf_document(
toc = FALSE,
toc_depth = 2,
number_sections = FALSE,
fig_width = 6.5,
fig_height = 4.5,
fig_crop = TRUE,
fig_caption = TRUE,
dev = "pdf",
df_print = "default",
highlight = "default",
template = "default",
keep_tex = FALSE,
keep_md = FALSE,
latex_engine = "pdflatex",
citation_package = c("default", "natbib", "biblatex"),
includes = NULL,
md_extensions = NULL,
output_extensions = NULL,
pandoc_args = NULL,
extra_dependencies = NULL
)

latex_document(...)

latex_fragment(...)

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_crop TRUE to automatically apply the pdfcrop utility (if available) to pdf figures
pdf_document 57

fig_caption TRUE to render figures with captions


dev Graphics device to use for figure output (defaults to pdf)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass
NULL to prevent syntax highlighting.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. See the documentation on pandoc
online documentation for details on creating custom templates.
keep_tex Keep the intermediate tex file used in the conversion to PDF
keep_md Keep the markdown file generated by knitting.
latex_engine LaTeX engine for producing PDF output. Options are "pdflatex", "lualatex", and
"xelatex".
citation_package
The LaTeX package to process citations, natbib or biblatex. Use default if
neither package is to be used, which means citations will be processed via the
command pandoc-citeproc.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
output_extensions
Pandoc extensions to be added or removed from the output format, e.g., "-smart"
means the output format will be latex-smart.
pandoc_args Additional command line options to pass to pandoc
extra_dependencies
A LaTeX dependency latex_dependency(), a list of LaTeX dependencies, a
character vector of LaTeX package names (e.g. c("framed","hyperref")), or
a named list of LaTeX package options with the names being package names
(e.g. list(hyperef = c("unicode=true","breaklinks=true"),lmodern =
NULL)). It can be used to add custom LaTeX packages to the .tex header.
... Arguments passed to pdf_document().

Details
See the online documentation for additional details on using the pdf_document format.
58 pdf_document

Creating PDF output from R Markdown requires that LaTeX be installed.


R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.
Many aspects of the LaTeX template used to create PDF documents can be customized using meta-
data. For example:

---
title: "Crop Analysis Q3 2013"
fontsize: 11pt
geometry: margin=1in
---

Available metadata variables include:

lang Document language code (e.g. "es", "fr", "pt-BR")


fontsize Font size (e.g. 10pt, 11pt, 12pt)
documentclass LaTeX document class (e.g. article)
classoption Option for documentclass (e.g. oneside); may be repeated
geometry Options for geometry class (e.g. margin=1in); may be repeated
mainfont, sansfont, monofont, mathfont Document fonts (works only with xelatex and luala-
tex, see the latex_engine option)
linkcolor, urlcolor, citecolor Color for internal, external, and citation links (red, green, ma-
genta, cyan, blue, black)
linestretch Options for line spacing (e.g. 1, 1.5, 3)

Value
R Markdown output format to pass to render

Examples
## Not run:
library(rmarkdown)

# simple invocation
render("input.Rmd", pdf_document())

# specify an option for latex engine


render("input.Rmd", pdf_document(latex_engine = "lualatex"))

# add a table of contents and pass an option to pandoc


render("input.Rmd", pdf_document(toc = TRUE, "--listings"))

## End(Not run)
pkg_file_lua 59

pkg_file_lua Get the full paths of Lua filters in an R package

Description
Lua filters stored in a source package in the ‘inst/rmarkdown/lua’ directory will be installed to
the ‘rmarkdown/lua’ directory in the package path. This function finds the full paths of the Lua
filters in the installed packages.

Usage
pkg_file_lua(filters = NULL, package = "rmarkdown")

Arguments
filters A character vector of filenames for Lua filters to be retrieved in ‘rmarkdown/lua’
folder of the package. By default (NULL), if none is provided, it returns all filters
in that folder.
package The name of the package in which to look for the filters.

Value
A character vector of absolute file paths for the Lua filter from the package. The returned paths
have been processed by pandoc_path_arg(), so they are ready to be used by Pandoc.

Examples
# List all Lua filters stored in the rmarkdown package
pkg_file_lua()
# or in a specific package
if (xfun::loadable("bookdown")) pkg_file_lua(package = "bookdown")
# get a specific filter
pkg_file_lua(c("pagebreak.lua", "latex_div.lua"))

powerpoint_presentation
Convert to a PowerPoint presentation

Description
Format for converting from R Markdown to a PowerPoint presentation. Pandoc v2.0.5 or above is
required.
60 powerpoint_presentation

Usage

powerpoint_presentation(
toc = FALSE,
toc_depth = 2,
number_sections = FALSE,
fig_width = 5,
fig_height = 4,
fig_caption = TRUE,
df_print = "default",
keep_md = FALSE,
md_extensions = NULL,
slide_level = NULL,
reference_doc = "default",
pandoc_args = NULL
)

Arguments

toc TRUE to include a table of contents in the output


toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_caption TRUE to render figures with captions
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
keep_md Keep the markdown file generated by knitting.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
slide_level The heading level which defines individual slides. By default this is the highest
header level in the hierarchy that is followed immediately by content, and not
another header, somewhere in the document. This default can be overridden by
specifying an explicit slide_level.
reference_doc Path to a PowerPoint template.
pandoc_args Additional command line options to pass to pandoc
publish_site 61

Value
R Markdown output format to pass to render

publish_site Publish an R Markdown Website

Description
Publish a website to RStudio Connect

Usage
publish_site(
site_dir = ".",
site_name = NULL,
method = c("rsconnect"),
server = NULL,
account = NULL,
render = TRUE,
launch_browser = interactive()
)

Arguments
site_dir Directory containing website. Defaults to current working directory.
site_name Name for the site (names must be unique within an account). Defaults to the
‘name‘ provided by the site generator (or to the name of the site_dir if there is
no ‘name‘ specified).
method Publishing method (currently only "rsconnect" is available)
server Server name. Required only if you use the same account name on multiple
servers.
account Account to deploy application to. This parameter is only required for the initial
deployment of an application when there are multiple accounts configured on
the system.
render ‘TRUE‘ to render the site locally before publishing.
launch_browser If ‘TRUE‘, the system’s default web browser will be launched automatically
after the site is deployed. Defaults to ‘TRUE‘ in interactive sessions only.

Examples
## Not run:
library(rmarkdown)
publish_site()

## End(Not run)
62 render

relative_to Relative path utility function

Description
Given a directory and a file, return a relative path from the directory to the file, or the unmodified
file path if the file does not appear to be in the directory.

Usage
relative_to(dir, file)

Arguments
dir Directory
file File

Value
Relative path from the directory to the file (or the unmodified file path if the file does not appear to
be in the directory).

render Render R Markdown

Description
Render the input file to the specified output format using pandoc. If the input requires knitting then
knit is called prior to pandoc.

Usage
render(
input,
output_format = NULL,
output_file = NULL,
output_dir = NULL,
output_options = NULL,
output_yaml = NULL,
intermediates_dir = NULL,
knit_root_dir = NULL,
runtime = c("auto", "static", "shiny", "shinyrmd", "shiny_prerendered"),
clean = TRUE,
params = NULL,
knit_meta = NULL,
render 63

envir = parent.frame(),
run_pandoc = TRUE,
quiet = FALSE,
encoding = "UTF-8"
)

Arguments
input The input file to be rendered. This can be an R script (.R), an R Markdown
document (.Rmd), or a plain markdown document.
output_format The R Markdown output format to convert to. The option "all" will render
all formats defined within the file. The option can be the name of a format (e.g.
"html_document") and that will render the document to that single format. One
can also use a vector of format names to render to multiple formats. Alterna-
tively, you can pass an output format object (e.g. html_document()). If using
NULL then the output format is the first one defined in the YAML frontmatter in
the input file (this defaults to HTML if no format is specified there). If you pass
an output format object to output_format, the options specified in the YAML
header or _output.yml will be ignored and you must explicitly set all the op-
tions you want when you construct the object. If you pass a string, the output
format will use the output parameters in the YAML header or _output.yml.
output_file The name of the output file. If using NULL then the output filename will be
based on filename for the input file. If a filename is provided, a path to the
output file can also be provided. Note that the output_dir option allows for
specifying the output file path as well, however, if also specifying the path, the
directory must exist. If output_file is specified but does not have a file exten-
sion, an extension will be automatically added according to the output format.
To avoid the automatic file extension, put the output_file value in I(), e.g.,
I('my-output').
output_dir The output directory for the rendered output_file. This allows for a choice
of an alternate directory to which the output file should be written (the default
output directory of that of the input file). If a path is provided with a filename in
output_file the directory specified here will take precedence. Please note that
any directory path provided will create any necessary directories if they do not
exist.
output_options List of output options that can override the options specified in metadata (e.g.
could be used to force self_contained or mathjax = "local"). Note that this
is only valid when the output format is read from metadata (i.e. not a custom
format object passed to output_format).
output_yaml Paths to YAML files specifying output formats and their configurations. The first
existing one is used. If none are found, then the function searches YAML files
specified to the output_yaml top-level parameter in the YAML front matter,
_output.yml or _output.yaml, and then uses the first existing one.
intermediates_dir
Intermediate files directory. If a path is specified then intermediate files will be
written to that path. If NULL, intermediate files are written to the same directory
as the input file.
64 render

knit_root_dir The working directory in which to knit the document; uses knitr’s root.dir
knit option. If NULL then the behavior will follow the knitr default, which is to
use the parent directory of the document.
runtime The runtime target for rendering. The static option produces output intended
for static files; shiny produces output suitable for use in a Shiny document
(see run). The default, auto, allows the runtime target specified in the YAML
metadata to take precedence, and renders for a static runtime target otherwise.
clean Using TRUE will clean intermediate files that are created during rendering.
params A list of named parameters that override custom params specified within the
YAML front-matter (e.g. specifying a dataset to read or a date range to con-
fine output to). Pass "ask" to start an application that helps guide parameter
configuration.
knit_meta (This option is reserved for expert use.) Metadata generated by knitr.
envir The environment in which the code chunks are to be evaluated during knitting
(can use new.env() to guarantee an empty new environment).
run_pandoc An option for whether to run pandoc to convert Markdown output.
quiet An option to suppress printing of the pandoc command line.
encoding Ignored. The encoding is always assumed to be UTF-8.

Details
Note that the knitr error option is set to FALSE during rendering (which is different from the knitr
default value of TRUE).
For additional details on rendering R scripts see Compiling R scripts to a notebook.
If no output_format parameter is specified then the output format is read from the YAML front-
matter of the input file. For example, the following YAML would yield a PDF document:

output: pdf_document

Additional format options can also be specified in metadata. For example:

output:
pdf_document:
toc: true
highlight: zenburn

Multiple formats can be specified in metadata. If no output_format is passed to render then the
first one defined will be used:

output:
pdf_document:
toc: true
highlight: zenburn
html_document:
toc: true
theme: united
render 65

Formats specified in metadata can be any one of the built in formats (e.g. html_document, pdf_document)
or a format defined in another package (e.g. pkg::custom_format).
If there is no format defined in the YAML then html_document will be used.

Value

When run_pandoc = TRUE, the compiled document is written into the output file, and the path of
the output file is returned. When run_pandoc = FALSE, the path of the Markdown output file, with
attributes knit_meta (the knitr meta data collected from code chunks) and intermediates (the
intermediate files/directories generated by render()).

R Markdown

R Markdown supports all of the base pandoc markdown features as well as some optional features
for compatibility with GitHub Flavored Markdown (which previous versions of R Markdown were
based on). See rmarkdown_format for details.

See Also

knit, output_format, https://pandoc.org

Examples
## Not run:
library(rmarkdown)

# Render the default (first) format defined in the file


render("input.Rmd")

# Render all formats defined in the file


render("input.Rmd", "all")

# Render a single format, using parameters for \code{html_document} from


# the YAML header parameters.
render("input.Rmd", "html_document")

# Render a single format, ignoring parameters for \code{html_document} in


# the YAML header. Any parameters not passed as arguments to
# \code{html_document()} will be assigned to their default values, regardless
# of anything in the YAML header
render("input.Rmd", html_document(toc = TRUE, toc_depth = 2))

# Render multiple formats


render("input.Rmd", c("html_document", "pdf_document"))

## End(Not run)
66 render_delayed

render_delayed Delay Rendering for an Expression

Description
In a Shiny document, evaluate the given expression after the document has finished rendering,
instead of during render.

Usage
render_delayed(expr)

Arguments
expr The expression to evaluate.

Details
This function is useful inside Shiny documents. It delays the evaluation of its argument until the
document has finished its initial render, so that the document can be viewed before the calculation
is finished.
Any expression that returns HTML can be wrapped in render_delayed.

Value
An object representing the expression.

Note
expr is evaluated in a copy of the environment in which the render_delayed call appears. Con-
sequently, no side effects created by expr are visible in succeeding expressions, nor are changes to
the environment after the call to render_delayed visible to expr.
expr must be an expression that produces HTML.

Examples
## Not run:
# Add the following code to an R Markdown document

div(Sys.time())

render_delayed({
Sys.sleep(3) # simulate an expensive computation
div(Sys.time())
})

div(Sys.time())

## End(Not run)
render_site 67

render_site Render multiple documents as a website

Description
Render all of the R Markdown documents within a directory as a website.

Usage
render_site(
input = ".",
output_format = "all",
envir = parent.frame(),
quiet = FALSE,
encoding = "UTF-8"
)

clean_site(input = ".", preview = FALSE, quiet = FALSE, encoding = "UTF-8")

site_generator(input = ".", output_format = NULL)

site_config(input = ".", encoding = "UTF-8")

default_site_generator(input, ...)

Arguments
input Website directory (or the name of a file within the directory).
output_format R Markdown format to convert to (defaults to "all").
envir The environment in which the code chunks are to be evaluated during knitting
(can use new.env to guarantee an empty new environment).
quiet TRUE to suppress messages and other output.
encoding Ignored. The encoding is always assumed to be UTF-8.
preview Whether to list the files to be removed rather than actually removing them.
... Currently unused.

Details
The render_site function enables you to render a collection of markdown documents within a
directory as a website. There are two requirements for a directory to be rendered as a website:

1. It must contain either an "index.Rmd" or "index.md" file.


2. It must contain a site configuration file ("_site.yml").
68 render_site

The most minimal valid website is an empty "index.Rmd" and an empty "_site.yml". With this
configuration a single empty webpage would be generated via a call to render_site. If you add
additional markdown documents to the directory they will also be rendered. By default a site is
rendered in the following fashion:

1. R Markdown (.Rmd) and plain markdown (.md) files in the root directory are rendered. Note
however that markdown files beginning with "_" are not rendered (this is a convention to
designate files that are included by top level documents).
2. All output and supporting files are copied to a "_site" subdirectory of the website directory
(this is configurable, see discussion below).
3. The following files are not copied to the "_site" sub-directory:
• Files beginning with "." (hidden files).
• Files beginning with "_"
• Files known to contain R source code (e.g. ".R", ".s", ".Rmd"), R data (e.g. ".RData",
".rds"), or configuration data (e.g. ".Rproj", "rsconnect")).
Note that you can override which files are included or excluded via settings in "_site.yml"
(described below).
4. Normally R Markdown renders documents as self-contained HTML. However, render_site
ensures that dependencies (e.g. CSS, JavaScript, images, etc.) remain in external files.
CSS/JavaScript libraries are copied to a "site_libs" sub-directory and plots/images are copied
to "_files" sub-directories.

You can remove the files generated by render_site using the clean_site function.

Value
render_site returns the name of the site output file (relative to the input directory). clean_site
returns the names of the generated files removed during cleaning. site_config returns the con-
tents of _site.yml as an R list. default_site_generator returns the default site generator for R
Markdown websites.

Configuration
A "_site.yml" file can be used to configure the behavior of site generation. Here is an example
configuration file:

name: my-website
output_dir: _site
include: ["demo.R"]
exclude: ["docs.txt", "*.csv"]
navbar:
title: "My Website"
left:
- text: "Home"
href: index.html
- text: "About"
href: about.html
render_site 69

output:
html_document:
toc: true
highlight: textmate

The name field provides a suggested URL path for your website when it is published (by default this
is just the name of the directory containing the site). The output_dir indicates which directory to
copy site content into ("_site" is the default if none is specified). Note that this can be "." to keep
all content within the root website directory alongside the source code.
The include and exclude fields enable you to override the default behavior vis-a-vis what files are
copied into the "_site" directory (wildcards can be used as in the above example).
The navbar field can be used to define a navigation bar for websites based on the html_document
format.
Finally, the output field enables you to specify output options that are common to all documents
within the website (you can also still provide local options within each document that override any
common options).
new_session: true causes each file to be rendered in a new R session. This prevents the mask-
ing problem that arises when different files use functions from different packages (namespaces)
that share a common name, such as here::here and lubridate::here or dplyr::filter and
MASS::filter. The default behaviour of render_site is to use a common R session.
autospin: true causes .R files to be spinned and rendered (as well as .Rmd files). If autospin is
set to false (the default), .R files will not be spinned nor rendered. autospin can also enumerate a
list of .R files to be spinned and rendered.

Custom Site Generation


The behavior of the default site generation function (rmarkdown::default_site) is described
above. It is also possible to define a custom site generator that has alternate behavior. A site
generator is an R function that is bound to by including it in the "site:" field of the "index.Rmd" or
"index.md" file. For example:

title: "My Book"


output: bookdown::gitbook
site: bookdown::bookdown_site

A site generation function should return a list with the following elements:

• name The name for the website (e.g. the parent directory name).
• output_dir The directory where the website output is written to. This path should be relative
to the site directory (e.g. "." or "_site")
• render An R function that can be called to generate the site. The function should accept the
input_file, output_format, envir, and quiet arguments.
• clean An R function that returns relative paths to the files generated by render_site (these
files are the ones which will be removed by the clean_site function.
70 render_supporting_files

Note that the input_file argument will be NULL when the entire site is being generated. It will be
set to a specific file name if a front-end tool is attempting to preview it (e.g. RStudio IDE via the
Knit button).
When quiet = FALSE the render function should also print a line of output using the message
function indicating which output file should be previewed, for example:

if (!quiet)
message("\nOutput created: ", output)

Emitting this line enables front-ends like RStudio to determine which file they should open to
preview the website.
See the source code of the rmarkdown::default_site function for a example of a site generation
function.

render_supporting_files
Render supporting files for an input document

Description

Render (copy) required supporting files for an input document to the _files directory that is asso-
ciated with the document.

Usage

render_supporting_files(from, files_dir, rename_to = NULL)

Arguments

from The directory from which the files should be copied.


files_dir The directory that will receive the copied files.
rename_to An option to rename the source directory after the copy operation is complete.

Value

The relative path to the supporting files. This path is suitable for inclusion in HTMLhref and src
attributes.
resolve_output_format 71

resolve_output_format Resolve the output format for an R Markdown document

Description
Read the YAML metadata (and any common output YAML file) for the document and return an
output format object that can be passed to the render function.

Usage
resolve_output_format(
input,
output_format = NULL,
output_options = NULL,
output_yaml = NULL
)

Arguments
input Input file (Rmd or plain markdown)
output_format Name of output format (or NULL to use the default format for the input file).
output_options List of output options that should override the options specified in metadata.
output_yaml Paths to YAML files specifying output formats and their configurations. The first
existing one is used. If none are found, then the function searches YAML files
specified to the output_yaml top-level parameter in the YAML front matter,
_output.yml or _output.yaml, and then uses the first existing one.

Details
This function is useful for front-end tools that need to modify the default behavior of an output
format.

Value
An R Markdown output format definition that can be passed to render.

rmarkdown_format R Markdown input format definition

Description
Compose a pandoc markdown input definition for R Markdown that can be passed as the from
argument of pandoc_options.
72 rmd_metadata

Usage
rmarkdown_format(extensions = NULL)

from_rmarkdown(implicit_figures = TRUE, extensions = NULL)

Arguments
extensions Markdown extensions to be added or removed from the default definition of R
Markdown.
implicit_figures
Automatically make figures from images (defaults to TRUE).

Details
By default R Markdown is defined as all pandoc markdown extensions with the following tweaks for
backward compatibility with the markdown package (+ features are added, - features are removed):

+autolink_bare_uris
+tex_math_single_backslash

For more on pandoc markdown see the pandoc online documentation.

Value
Pandoc markdown format specification

See Also
output_format, pandoc_options

Examples
## Not run:
rmarkdown_format("-implicit_figures")

## End(Not run)

rmd_metadata R Markdown Metadata

Description
Rmd files include a metadata section (typically located at the top of the file) that can specify (among
other things) the title, author, and date of the document. Metadata adheres to the YAML format and
is delimited by lines containing three dashes (---). Here is an example metadata section:
rtf_document 73

---
title: "Crop Analysis Q3 2013"
author: Martha Smith
date: October 23rd, 2013
---

Note that the title field is quoted. This is because titles often contained embedded colons (:) and
colons followed by a space need to be quoted in YAML.

Details
When title, author, and date metadata is provided it’s used to automatically create a title section
within output documents. If you don’t want this section included in your document then you should
remove the corresponding metadata fields.
When generating PDF and Beamer output there are also a number of other metadata fields that
can be included to customize the appearance and theme of PDF output. For more details see the
documentation for pdf_document and beamer_presentation.

rtf_document Convert to an RTF document

Description
Format for converting from R Markdown to an RTF document.

Usage
rtf_document(
toc = FALSE,
toc_depth = 3,
number_sections = FALSE,
fig_width = 5,
fig_height = 4,
keep_md = FALSE,
md_extensions = NULL,
pandoc_args = NULL
)

Arguments
toc TRUE to include a table of contents in the output
toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
74 run

keep_md Keep the markdown file generated by knitting.


md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details
See the online documentation for additional details on using the rtf_document format.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value
R Markdown output format to pass to render

Examples
## Not run:

library(rmarkdown)

# simple invocation
render("input.Rmd", rtf_document())

# specify table of contents option


render("input.Rmd", rtf_document(toc = TRUE))

## End(Not run)

run Run a Shiny document

Description
Start a Shiny server for the given document, and render it for display.

Usage
run(
file = "index.Rmd",
dir = dirname(file),
default_file = NULL,
auto_reload = TRUE,
shiny_args = NULL,
render_args = NULL
)
run 75

Arguments
file Path to the R Markdown document to launch in a web browser. Defaults to
index.Rmd in the current working directory, but may be NULL to skip launching
a browser.
dir The directory from which to to read input documents. Defaults to the parent
directory of file.
default_file The file to serve at the Shiny server’s root URL. If NULL (the default), a sensible
default is chosen (see Details)
auto_reload If TRUE (the default), automatically reload the Shiny application when the file
currently being viewed is changed on disk.
shiny_args Additional arguments to runApp.
render_args Additional arguments to render.

Details
The run function runs a Shiny document by starting a Shiny server associated with the document.
The shiny_args parameter can be used to configure the server; see the runApp documentation for
details.
Once the server is started, the document will be rendered using render. The server will initiate
a render of the document whenever necessary, so it is not necessary to call run every time the
document changes: if auto_reload is TRUE, saving the document will trigger a render. You can
also manually trigger a render by reloading the document in a Web browser.
The server will render any R Markdown (.Rmd) document in dir; the file argument specifies only
the initial document to be rendered and viewed. You can therefore link to other documents in the
directory using standard Markdown syntax, e.g. [Analysis Page 2](page2.Rmd).
If default_file is not specified, nor is a file specified on the URL, then the default document to
serve at / is chosen from (in order of preference):

• If dir contains only one Rmd, that Rmd.


• The file ‘index.Rmd’, if it exists in dir.
• The first Rmd that has runtime: shiny in its YAML metadata.
• The file ‘index.html’ (or ‘index.htm’), if it exists in dir.

If you wish to share R code between your documents, place it in a file named global.R in dir; it
will be sourced into the global environment.

Value
Invisible NULL.

Note
Unlike render, run does not render the document to a file on disk. In most cases a Web browser will
be started automatically to view the document; see launch.browser in the runApp documentation
for details.
76 shiny_prerendered_clean

When using an external web browser with the server, specify the name of the R Markdown file to
view in the URL (e.g. http://127.0.0.1:1234/foo.Rmd). A URL without a filename will show
the default_file as described above.

Examples
## Not run:
# Run the Shiny document "index.Rmd" in the current directory
rmarkdown::run()

# Run the Shiny document "shiny_doc.Rmd" on port 8241


rmarkdown::run("shiny_doc.Rmd", shiny_args = list(port = 8241))

## End(Not run)

shiny_prerendered_chunk
Add code to a shiny_prerendered context

Description
Programmatic equivalent to including a code chunk with a context in a runtime: shiny_prerendered
document.

Usage
shiny_prerendered_chunk(context, code, singleton = FALSE)

Arguments
context Context name (e.g. "server", "server-start")
code Character vector with code
singleton Collapse multiple identical versions of this chunk into a single chunk.

shiny_prerendered_clean
Clean prerendered content for the specified Rmd input file

Description
Remove the associated html file and supporting _files directory for a shiny_prerendered documet.

Usage
shiny_prerendered_clean(input)

Arguments
input Rmd input file to clean content for
site_resources 77

site_resources Determine website resource files for a directory

Description
Determine which files within a given directory should be copied in order to serve a website from
the directory. Attempts to automatically exclude source, data, hidden, and other files not required
to serve website content.

Usage
site_resources(site_dir, include = NULL, exclude = NULL, recursive = FALSE)

Arguments
site_dir Site directory to analyze
include Additional files to include (glob wildcards supported)
exclude Files to exclude (glob wildcards supported)
recursive TRUE to return a full recursive file listing; FALSE to just provide top-level files
and directories.

Value
Character vector of files and directories to copy

slidy_presentation Convert to a slidy presentation

Description
Format for converting from R Markdown to a slidy presentation.

Usage
slidy_presentation(
number_sections = FALSE,
incremental = FALSE,
slide_level = NULL,
duration = NULL,
footer = NULL,
font_adjustment = 0,
fig_width = 8,
fig_height = 6,
fig_retina = 2,
fig_caption = TRUE,
78 slidy_presentation

dev = "png",
df_print = "default",
self_contained = TRUE,
highlight = "default",
mathjax = "default",
template = "default",
css = NULL,
includes = NULL,
keep_md = FALSE,
lib_dir = NULL,
md_extensions = NULL,
pandoc_args = NULL,
extra_dependencies = NULL,
...
)

Arguments
number_sections
TRUE to number section headings
incremental TRUE to render slide bullets incrementally. Note that if you want to reverse the
default incremental behavior for an individual bullet you can precede it with >.
For example: > - Bullet Text
slide_level The heading level which defines individual slides. By default this is the highest
header level in the hierarchy that is followed immediately by content, and not
another header, somewhere in the document. This default can be overridden by
specifying an explicit slide_level.
duration Duration (in minutes) of the slide deck. This value is used to add a countdown
timer to the slide footer.
footer Footer text (e.g. organization name and/or copyright)
font_adjustment
Increase or decrease the default font size (e.g. -1 or +1). You can also manu-
ally adjust the font size during the presentation using the ’S’ (smaller) and ’B’
(bigger) keys.
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_retina Scaling to perform for retina displays (defaults to 2, which currently works for
all widely used retina displays). Set to NULL to prevent retina scaling. Note that
this will always be NULL when keep_md is specified (this is because fig_retina
relies on outputting HTML directly into the markdown document).
fig_caption TRUE to render figures with captions
dev Graphics device to use for figure output (defaults to pdf)
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
slidy_presentation 79

a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
self_contained Produce a standalone HTML file with no external dependencies, using data:
URIs to incorporate the contents of linked scripts, stylesheets, images, and
videos. Note that even for self contained documents MathJax is still loaded
externally (this is necessary because of its size).
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass
NULL to prevent syntax highlighting.
mathjax Include mathjax. The "default" option uses an https URL from a MathJax CDN.
The "local" option uses a local version of MathJax (which is copied into the out-
put directory). You can pass an alternate URL or pass NULL to exclude MathJax
entirely.
template Pandoc template to use for rendering. Pass "default" to use the rmarkdown pack-
age default template; pass NULL to use pandoc’s built-in template; pass a path to
use a custom template that you’ve created. See the documentation on pandoc
online documentation for details on creating custom templates.
css One or more css files to include
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
keep_md Keep the markdown file generated by knitting.
lib_dir Directory to copy dependent HTML libraries (e.g. jquery, bootstrap, etc.) into.
By default this will be the name of the document with _files appended to it.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc
extra_dependencies
A LaTeX dependency latex_dependency(), a list of LaTeX dependencies, a
character vector of LaTeX package names (e.g. c("framed","hyperref")), or
a named list of LaTeX package options with the names being package names
(e.g. list(hyperef = c("unicode=true","breaklinks=true"),lmodern =
NULL)). It can be used to add custom LaTeX packages to the .tex header.
... Additional function arguments to pass to the base R Markdown HTML output
formatter html_document_base

Details
See the online documentation for additional details on using the slidy_presentation format.
For more information on markdown syntax for presentations see the pandoc online documentation.

Value
R Markdown output format to pass to render
80 tufte_handout

Examples
## Not run:
library(rmarkdown)

# simple invocation
render("pres.Rmd", slidy_presentation())

# specify an option for incremental rendering


render("pres.Rmd", slidy_presentation(incremental = TRUE))

## End(Not run)

tufte_handout Tufte handout format (PDF)

Description
Template for creating a handout according to the style of Edward R. Tufte and Richard Feynman.

Usage
tufte_handout(
fig_width = 4,
fig_height = 2.5,
fig_crop = TRUE,
dev = "pdf",
highlight = "default",
keep_tex = FALSE,
citation_package = c("default", "natbib", "biblatex"),
includes = NULL,
md_extensions = NULL,
pandoc_args = NULL
)

Arguments
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_crop TRUE to automatically apply the pdfcrop utility (if available) to pdf figures
dev Graphics device to use for figure output (defaults to pdf)
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass
NULL to prevent syntax highlighting.
keep_tex Keep the intermediate tex file used in the conversion to PDF
word_document 81

citation_package
The LaTeX package to process citations, natbib or biblatex. Use default if
neither package is to be used, which means citations will be processed via the
command pandoc-citeproc.
includes Named list of additional content to include within the document (typically cre-
ated using the includes function).
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details
See the online documentation for additional details.
Creating Tufte handout output from R Markdown requires that LaTeX be installed.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

word_document Convert to an MS Word document

Description
Format for converting from R Markdown to an MS Word document.

Usage
word_document(
toc = FALSE,
toc_depth = 3,
number_sections = FALSE,
fig_width = 5,
fig_height = 4,
fig_caption = TRUE,
df_print = "default",
highlight = "default",
reference_docx = "default",
keep_md = FALSE,
md_extensions = NULL,
pandoc_args = NULL
)
82 word_document

Arguments

toc TRUE to include a table of contents in the output


toc_depth Depth of headers to include in table of contents
number_sections
TRUE to number section headings
fig_width Default width (in inches) for figures
fig_height Default height (in inches) for figures
fig_caption TRUE to render figures with captions
df_print Method to be used for printing data frames. Valid values include "default",
"kable", "tibble", and "paged". The "default" method uses a corresponding S3
method of print, typically print.data.frame. The "kable" method uses the
knitr::kable function. The "tibble" method uses the tibble package to print
a summary of the data frame. The "paged" method creates a paginated HTML
table (note that this method is only valid for formats that produce HTML). In
addition to the named methods you can also pass an arbitrary function to be
used for printing data frames. You can disable the df_print behavior entirely
by setting the option rmarkdown.df_print to FALSE.
highlight Syntax highlighting style. Supported styles include "default", "tango", "pyg-
ments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass
NULL to prevent syntax highlighting.
reference_docx Use the specified file as a style reference in producing a docx file. For best
results, the reference docx should be a modified version of a docx file produced
using pandoc. Pass "default" to use the rmarkdown default styles.
keep_md Keep the markdown file generated by knitting.
md_extensions Markdown extensions to be added or removed from the default definition or R
Markdown. See the rmarkdown_format for additional details.
pandoc_args Additional command line options to pass to pandoc

Details

See the online documentation for additional details on using the word_document format.
R Markdown documents can have optional metadata that is used to generate a document header
that includes the title, author, and date. For more details see the documentation on R Markdown
metadata.
R Markdown documents also support citations. You can find more information on the markdown
syntax for citations in the Bibliographies and Citations article in the online documentation.

Value

R Markdown output format to pass to render


word_document 83

Examples
## Not run:
library(rmarkdown)

# simple invocation
render("input.Rmd", word_document())

# specify an option for syntax highlighting


render("input.Rmd", word_document(highlight = "zenburn"))

## End(Not run)
Index

∗ datasets html_fragment, 23
metadata, 43 html_notebook, 25
html_notebook_metadata, 27
all_output_formats, 5 html_notebook_output, 26, 27, 27
html_notebook_output_code
beamer_presentation, 4, 5, 73 (html_notebook_output), 27
html_notebook_output_html
clean_site (render_site), 67
(html_notebook_output), 27
compile_notebook, 8
html_notebook_output_img
Compiling R scripts to a notebook, 64
(html_notebook_output), 27
context_document, 9
html_notebook_output_png
default_output_format, 11 (html_notebook_output), 27
default_site_generator (render_site), 67 html_vignette, 28
draft, 12 htmlDependency, 23

find_external_resources, 13 I, 63
find_pandoc, 14 includes, 7, 10, 16, 20, 24, 26, 30, 33, 42, 44,
from_rmarkdown (rmarkdown_format), 71 57, 79, 81
includes_to_pandoc_args (includes), 30
github_document, 15 ioslides_presentation, 31

html-dependencies, 17 knit, 62, 65


html_dependency_bootstrap knit_hooks, 38
(html-dependencies), 17 knit_params_ask, 39
html_dependency_font_awesome knitr spin, 9
(html-dependencies), 17 knitr::kable, 6, 10, 16, 19, 24, 29, 32, 42,
html_dependency_highlightjs 45, 57, 60, 78, 82
(html-dependencies), 17 knitr_options, 37, 38, 39, 45, 46
html_dependency_ionicons knitr_options_html, 38
(html-dependencies), 17 knitr_options_pdf, 39
html_dependency_jquery
(html-dependencies), 17 latex-dependencies, 40
html_dependency_jqueryui latex_dependency, 41
(html-dependencies), 17 latex_dependency_tikz
html_dependency_pagedtable (latex-dependencies), 40
(html-dependencies), 17 latex_document (pdf_document), 56
html_dependency_tocify latex_fragment (pdf_document), 56
(html-dependencies), 17
html_document, 4, 17, 23, 25, 28, 29, 65, 69 md_document, 41
html_document_base, 19, 22, 26, 27, 33, 79 message, 70

84
INDEX 85

metadata, 7, 11, 20, 42, 43, 44, 58, 74, 81, 82 rmarkdown (rmarkdown-package), 4
rmarkdown-package, 4
new.env, 64, 67 rmarkdown_format, 7, 10, 16, 20, 25, 26, 33,
numeric_version, 50 42, 44, 53, 57, 60, 65, 71, 74, 79, 81,
82
odt_document, 43 rmd_metadata, 72
on.exit, 46 rtf_document, 73
opts_chunk, 38 run, 64, 74
opts_hooks, 38 runApp, 40, 75
opts_knit, 38
opts_template, 38 shiny_prerendered_chunk, 76
output_format, 22, 27, 38, 39, 45, 53, 65, 72 shiny_prerendered_clean, 76
output_metadata, 47 site_config (render_site), 67
site_generator (render_site), 67
paged_table, 47 site_resources, 77
pandoc_args, 48 slidy_presentation, 77
pandoc_available, 49
pandoc_citeproc_args (pandoc_args), 48 tufte_handout, 80
pandoc_citeproc_convert, 50
pandoc_convert, 51 word_document, 4, 81
pandoc_exec, 52
pandoc_highlight_args (pandoc_args), 48
pandoc_include_args (pandoc_args), 48
pandoc_latex_engine_args (pandoc_args),
48
pandoc_lua_filter_args (pandoc_args), 48
pandoc_metadata_arg (pandoc_args), 48
pandoc_options, 45, 46, 52, 71, 72
pandoc_path_arg, 48, 54, 59
pandoc_self_contained_html, 54
pandoc_template, 55
pandoc_toc_args (pandoc_args), 48
pandoc_variable_arg (pandoc_args), 48
pandoc_version (pandoc_available), 49
parse_html_notebook, 55
path.expand, 54
pdf_document, 4, 56, 65, 73
pkg_file_lua, 59
powerpoint_presentation, 59
publish_site, 61

relative_to, 62
render, 4, 5, 7–9, 11, 16, 20, 25, 29, 33, 42,
44, 46, 47, 58, 61, 62, 71, 74, 75, 79,
82
render_delayed, 66
render_site, 67
render_supporting_files, 45, 70
resolve_output_format, 71

S-ar putea să vă placă și