-
Notifications
You must be signed in to change notification settings - Fork 11
/
CausalForest.html
2260 lines (2066 loc) · 286 KB
/
CausalForest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="x-ua-compatible" content="IE=9" >
<title>Simulations Causal Forests</title>
<style type="text/css">
body, td {
font-family: sans-serif;
background-color: white;
font-size: 12px;
margin: 8px;
}
tt, code, pre {
font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
}
h1 {
font-size:2.2em;
}
h2 {
font-size:1.8em;
}
h3 {
font-size:1.4em;
}
h4 {
font-size:1.0em;
}
h5 {
font-size:0.9em;
}
h6 {
font-size:0.8em;
}
a:visited {
color: rgb(50%, 0%, 50%);
}
pre {
margin-top: 0;
max-width: 95%;
border: 1px solid #ccc;
white-space: pre-wrap;
}
pre code {
display: block; padding: 0.5em;
}
code.r, code.cpp {
background-color: #F8F8F8;
}
table, td, th {
border: none;
}
blockquote {
color:#666666;
margin:0;
padding-left: 1em;
border-left: 0.5em #EEE solid;
}
hr {
height: 0px;
border-bottom: none;
border-top-width: thin;
border-top-style: dotted;
border-top-color: #999999;
}
@media print {
* {
background: transparent !important;
color: black !important;
filter:none !important;
-ms-filter: none !important;
}
body {
font-size:12pt;
max-width:100%;
}
a, a:visited {
text-decoration: underline;
}
hr {
visibility: hidden;
page-break-before: always;
}
pre, blockquote {
padding-right: 1em;
page-break-inside: avoid;
}
tr, img {
page-break-inside: avoid;
}
img {
max-width: 100% !important;
}
@page :left {
margin: 15mm 20mm 15mm 10mm;
}
@page :right {
margin: 15mm 10mm 15mm 20mm;
}
p, h2, h3 {
orphans: 3; widows: 3;
}
h2, h3 {
page-break-after: avoid;
}
}
</style>
<!-- Styles for R syntax highlighter -->
<style type="text/css">
pre .operator,
pre .paren {
color: rgb(104, 118, 135)
}
pre .literal {
color: rgb(88, 72, 246)
}
pre .number {
color: rgb(0, 0, 205);
}
pre .comment {
color: rgb(76, 136, 107);
}
pre .keyword {
color: rgb(0, 0, 255);
}
pre .identifier {
color: rgb(0, 0, 0);
}
pre .string {
color: rgb(3, 106, 7);
}
</style>
<!-- R syntax highlighter -->
<script type="text/javascript">
var hljs=new function(){function m(p){return p.replace(/&/gm,"&").replace(/</gm,"<")}function f(r,q,p){return RegExp(q,"m"+(r.cI?"i":"")+(p?"g":""))}function b(r){for(var p=0;p<r.childNodes.length;p++){var q=r.childNodes[p];if(q.nodeName=="CODE"){return q}if(!(q.nodeType==3&&q.nodeValue.match(/\s+/))){break}}}function h(t,s){var p="";for(var r=0;r<t.childNodes.length;r++){if(t.childNodes[r].nodeType==3){var q=t.childNodes[r].nodeValue;if(s){q=q.replace(/\n/g,"")}p+=q}else{if(t.childNodes[r].nodeName=="BR"){p+="\n"}else{p+=h(t.childNodes[r])}}}if(/MSIE [678]/.test(navigator.userAgent)){p=p.replace(/\r/g,"\n")}return p}function a(s){var r=s.className.split(/\s+/);r=r.concat(s.parentNode.className.split(/\s+/));for(var q=0;q<r.length;q++){var p=r[q].replace(/^language-/,"");if(e[p]){return p}}}function c(q){var p=[];(function(s,t){for(var r=0;r<s.childNodes.length;r++){if(s.childNodes[r].nodeType==3){t+=s.childNodes[r].nodeValue.length}else{if(s.childNodes[r].nodeName=="BR"){t+=1}else{if(s.childNodes[r].nodeType==1){p.push({event:"start",offset:t,node:s.childNodes[r]});t=arguments.callee(s.childNodes[r],t);p.push({event:"stop",offset:t,node:s.childNodes[r]})}}}}return t})(q,0);return p}function k(y,w,x){var q=0;var z="";var s=[];function u(){if(y.length&&w.length){if(y[0].offset!=w[0].offset){return(y[0].offset<w[0].offset)?y:w}else{return w[0].event=="start"?y:w}}else{return y.length?y:w}}function t(D){var A="<"+D.nodeName.toLowerCase();for(var B=0;B<D.attributes.length;B++){var C=D.attributes[B];A+=" "+C.nodeName.toLowerCase();if(C.value!==undefined&&C.value!==false&&C.value!==null){A+='="'+m(C.value)+'"'}}return A+">"}while(y.length||w.length){var v=u().splice(0,1)[0];z+=m(x.substr(q,v.offset-q));q=v.offset;if(v.event=="start"){z+=t(v.node);s.push(v.node)}else{if(v.event=="stop"){var p,r=s.length;do{r--;p=s[r];z+=("</"+p.nodeName.toLowerCase()+">")}while(p!=v.node);s.splice(r,1);while(r<s.length){z+=t(s[r]);r++}}}}return z+m(x.substr(q))}function j(){function q(x,y,v){if(x.compiled){return}var u;var s=[];if(x.k){x.lR=f(y,x.l||hljs.IR,true);for(var w in x.k){if(!x.k.hasOwnProperty(w)){continue}if(x.k[w] instanceof Object){u=x.k[w]}else{u=x.k;w="keyword"}for(var r in u){if(!u.hasOwnProperty(r)){continue}x.k[r]=[w,u[r]];s.push(r)}}}if(!v){if(x.bWK){x.b="\\b("+s.join("|")+")\\s"}x.bR=f(y,x.b?x.b:"\\B|\\b");if(!x.e&&!x.eW){x.e="\\B|\\b"}if(x.e){x.eR=f(y,x.e)}}if(x.i){x.iR=f(y,x.i)}if(x.r===undefined){x.r=1}if(!x.c){x.c=[]}x.compiled=true;for(var t=0;t<x.c.length;t++){if(x.c[t]=="self"){x.c[t]=x}q(x.c[t],y,false)}if(x.starts){q(x.starts,y,false)}}for(var p in e){if(!e.hasOwnProperty(p)){continue}q(e[p].dM,e[p],true)}}function d(B,C){if(!j.called){j();j.called=true}function q(r,M){for(var L=0;L<M.c.length;L++){if((M.c[L].bR.exec(r)||[null])[0]==r){return M.c[L]}}}function v(L,r){if(D[L].e&&D[L].eR.test(r)){return 1}if(D[L].eW){var M=v(L-1,r);return M?M+1:0}return 0}function w(r,L){return L.i&&L.iR.test(r)}function K(N,O){var M=[];for(var L=0;L<N.c.length;L++){M.push(N.c[L].b)}var r=D.length-1;do{if(D[r].e){M.push(D[r].e)}r--}while(D[r+1].eW);if(N.i){M.push(N.i)}return f(O,M.join("|"),true)}function p(M,L){var N=D[D.length-1];if(!N.t){N.t=K(N,E)}N.t.lastIndex=L;var r=N.t.exec(M);return r?[M.substr(L,r.index-L),r[0],false]:[M.substr(L),"",true]}function z(N,r){var L=E.cI?r[0].toLowerCase():r[0];var M=N.k[L];if(M&&M instanceof Array){return M}return false}function F(L,P){L=m(L);if(!P.k){return L}var r="";var O=0;P.lR.lastIndex=0;var M=P.lR.exec(L);while(M){r+=L.substr(O,M.index-O);var N=z(P,M);if(N){x+=N[1];r+='<span class="'+N[0]+'">'+M[0]+"</span>"}else{r+=M[0]}O=P.lR.lastIndex;M=P.lR.exec(L)}return r+L.substr(O,L.length-O)}function J(L,M){if(M.sL&&e[M.sL]){var r=d(M.sL,L);x+=r.keyword_count;return r.value}else{return F(L,M)}}function I(M,r){var L=M.cN?'<span class="'+M.cN+'">':"";if(M.rB){y+=L;M.buffer=""}else{if(M.eB){y+=m(r)+L;M.buffer=""}else{y+=L;M.buffer=r}}D.push(M);A+=M.r}function G(N,M,Q){var R=D[D.length-1];if(Q){y+=J(R.buffer+N,R);return false}var P=q(M,R);if(P){y+=J(R.buffer+N,R);I(P,M);return P.rB}var L=v(D.length-1,M);if(L){var O=R.cN?"</span>":"";if(R.rE){y+=J(R.buffer+N,R)+O}else{if(R.eE){y+=J(R.buffer+N,R)+O+m(M)}else{y+=J(R.buffer+N+M,R)+O}}while(L>1){O=D[D.length-2].cN?"</span>":"";y+=O;L--;D.length--}var r=D[D.length-1];D.length--;D[D.length-1].buffer="";if(r.starts){I(r.starts,"")}return R.rE}if(w(M,R)){throw"Illegal"}}var E=e[B];var D=[E.dM];var A=0;var x=0;var y="";try{var s,u=0;E.dM.buffer="";do{s=p(C,u);var t=G(s[0],s[1],s[2]);u+=s[0].length;if(!t){u+=s[1].length}}while(!s[2]);if(D.length>1){throw"Illegal"}return{r:A,keyword_count:x,value:y}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:m(C)}}else{throw H}}}function g(t){var p={keyword_count:0,r:0,value:m(t)};var r=p;for(var q in e){if(!e.hasOwnProperty(q)){continue}var s=d(q,t);s.language=q;if(s.keyword_count+s.r>r.keyword_count+r.r){r=s}if(s.keyword_count+s.r>p.keyword_count+p.r){r=p;p=s}}if(r.language){p.second_best=r}return p}function i(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"<br>")}return r}function n(t,w,r){var x=h(t,r);var v=a(t);var y,s;if(v){y=d(v,x)}else{return}var q=c(t);if(q.length){s=document.createElement("pre");s.innerHTML=y.value;y.value=k(q,c(s),x)}y.value=i(y.value,w,r);var u=t.className;if(!u.match("(\\s|^)(language-)?"+v+"(\\s|$)")){u=u?(u+" "+v):v}if(/MSIE [678]/.test(navigator.userAgent)&&t.tagName=="CODE"&&t.parentNode.tagName=="PRE"){s=t.parentNode;var p=document.createElement("div");p.innerHTML="<pre><code>"+y.value+"</code></pre>";t=p.firstChild.firstChild;p.firstChild.cN=s.cN;s.parentNode.replaceChild(p.firstChild,s)}else{t.innerHTML=y.value}t.className=u;t.result={language:v,kw:y.keyword_count,re:y.r};if(y.second_best){t.second_best={language:y.second_best.language,kw:y.second_best.keyword_count,re:y.second_best.r}}}function o(){if(o.called){return}o.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p<r.length;p++){var q=b(r[p]);if(q){n(q,hljs.tabReplace)}}}function l(){if(window.addEventListener){window.addEventListener("DOMContentLoaded",o,false);window.addEventListener("load",o,false)}else{if(window.attachEvent){window.attachEvent("onload",o)}else{window.onload=o}}}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=n;this.initHighlighting=o;this.initHighlightingOnLoad=l;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="\\b(0[xX][a-fA-F0-9]+|(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.ER="(?![\\s\\S])";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(r,s){var p={};for(var q in r){p[q]=r[q]}if(s){for(var q in s){p[q]=s[q]}}return p}}();hljs.LANGUAGES.cpp=function(){var a={keyword:{"false":1,"int":1,"float":1,"while":1,"private":1,"char":1,"catch":1,"export":1,virtual:1,operator:2,sizeof:2,dynamic_cast:2,typedef:2,const_cast:2,"const":1,struct:1,"for":1,static_cast:2,union:1,namespace:1,unsigned:1,"long":1,"throw":1,"volatile":2,"static":1,"protected":1,bool:1,template:1,mutable:1,"if":1,"public":1,friend:2,"do":1,"return":1,"goto":1,auto:1,"void":2,"enum":1,"else":1,"break":1,"new":1,extern:1,using:1,"true":1,"class":1,asm:1,"case":1,typeid:1,"short":1,reinterpret_cast:2,"default":1,"double":1,register:1,explicit:1,signed:1,typename:1,"try":1,"this":1,"switch":1,"continue":1,wchar_t:1,inline:1,"delete":1,alignof:1,char16_t:1,char32_t:1,constexpr:1,decltype:1,noexcept:1,nullptr:1,static_assert:1,thread_local:1,restrict:1,_Bool:1,complex:1},built_in:{std:1,string:1,cin:1,cout:1,cerr:1,clog:1,stringstream:1,istringstream:1,ostringstream:1,auto_ptr:1,deque:1,list:1,queue:1,stack:1,vector:1,map:1,set:1,bitset:1,multiset:1,multimap:1,unordered_set:1,unordered_map:1,unordered_multiset:1,unordered_multimap:1,array:1,shared_ptr:1}};return{dM:{k:a,i:"</",c:[hljs.CLCM,hljs.CBLCLM,hljs.QSM,{cN:"string",b:"'\\\\?.",e:"'",i:"."},{cN:"number",b:"\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)"},hljs.CNM,{cN:"preprocessor",b:"#",e:"$"},{cN:"stl_container",b:"\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",e:">",k:a,r:10,c:["self"]}]}}}();hljs.LANGUAGES.r={dM:{c:[hljs.HCM,{cN:"number",b:"\\b0[xX][0-9a-fA-F]+[Li]?\\b",e:hljs.IMMEDIATE_RE,r:0},{cN:"number",b:"\\b\\d+(?:[eE][+\\-]?\\d*)?L\\b",e:hljs.IMMEDIATE_RE,r:0},{cN:"number",b:"\\b\\d+\\.(?!\\d)(?:i\\b)?",e:hljs.IMMEDIATE_RE,r:1},{cN:"number",b:"\\b\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",e:hljs.IMMEDIATE_RE,r:0},{cN:"number",b:"\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",e:hljs.IMMEDIATE_RE,r:1},{cN:"keyword",b:"(?:tryCatch|library|setGeneric|setGroupGeneric)\\b",e:hljs.IMMEDIATE_RE,r:10},{cN:"keyword",b:"\\.\\.\\.",e:hljs.IMMEDIATE_RE,r:10},{cN:"keyword",b:"\\.\\.\\d+(?![\\w.])",e:hljs.IMMEDIATE_RE,r:10},{cN:"keyword",b:"\\b(?:function)",e:hljs.IMMEDIATE_RE,r:2},{cN:"keyword",b:"(?:if|in|break|next|repeat|else|for|return|switch|while|try|stop|warning|require|attach|detach|source|setMethod|setClass)\\b",e:hljs.IMMEDIATE_RE,r:1},{cN:"literal",b:"(?:NA|NA_integer_|NA_real_|NA_character_|NA_complex_)\\b",e:hljs.IMMEDIATE_RE,r:10},{cN:"literal",b:"(?:NULL|TRUE|FALSE|T|F|Inf|NaN)\\b",e:hljs.IMMEDIATE_RE,r:1},{cN:"identifier",b:"[a-zA-Z.][a-zA-Z0-9._]*\\b",e:hljs.IMMEDIATE_RE,r:0},{cN:"operator",b:"<\\-(?!\\s*\\d)",e:hljs.IMMEDIATE_RE,r:2},{cN:"operator",b:"\\->|<\\-",e:hljs.IMMEDIATE_RE,r:1},{cN:"operator",b:"%%|~",e:hljs.IMMEDIATE_RE},{cN:"operator",b:">=|<=|==|!=|\\|\\||&&|=|\\+|\\-|\\*|/|\\^|>|<|!|&|\\||\\$|:",e:hljs.IMMEDIATE_RE,r:0},{cN:"operator",b:"%",e:"%",i:"\\n",r:1},{cN:"identifier",b:"`",e:"`",r:0},{cN:"string",b:'"',e:'"',c:[hljs.BE],r:0},{cN:"string",b:"'",e:"'",c:[hljs.BE],r:0},{cN:"paren",b:"[[({\\])}]",e:hljs.IMMEDIATE_RE,r:0}]}};
hljs.initHighlightingOnLoad();
</script>
<!-- MathJax scripts -->
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<h2>Simulations Causal Forests</h2>
<p>#Variables
smsa66 lived in smsa in 1966 ?</p>
<p>smsa76 lived in smsa in 1976 ?</p>
<p>age76 age in 1976</p>
<p>daded dads education (imputed avg if missing)</p>
<p>south66 lived in south in 1966 ?</p>
<p>south76 lived in south in 1976 ?</p>
<p>lwage76 log wage in 1976 (outliers trimmed)</p>
<p>famed mom-dad education class (1-9)</p>
<p>black black ?</p>
<p>wage76 wage in 1976 (raw, cents per hour)</p>
<p>enroll76 enrolled in 1976 ?</p>
<p>kww the kww score</p>
<p>iqscore a normed IQ score</p>
<p>mar76 married in 1976 ?</p>
<p>libcrd14 library card in home at age 14 ?</p>
<p>exp76 experience in 1976</p>
<pre><code class="r">Schooling$high <- 1*(Schooling$wage76 > quantile(Schooling$wage76,0.8))
### train/test sample
set.seed(1789)
ind <- sample(2, nrow(Schooling), replace=TRUE,prob=c(0.7,0.3))
trainData <- Schooling[ind==1,]
testData <-Schooling[ind==2, ]
formula1 <- wage76~ iqscore + black + exp76+ age76
Tree1 <- ctree(formula1, trainData )
Tree1 <- tree(formula1, trainData )
summary(Tree1)
</code></pre>
<pre><code>##
## Regression tree:
## tree(formula = formula1, data = trainData)
## Number of terminal nodes: 7
## Residual mean deviance: 59100 = 85750000 / 1451
## Distribution of residuals:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -642.90 -159.00 -33.55 0.00 121.70 1637.00
</code></pre>
<pre><code class="r">plot(Tree1)
text(Tree1, pretty=0)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAkFBMVEUAAAAAADoAAGYAOmYAOpAAZmYAZpAAZrY6AAA6ADo6AGY6OmY6OpA6kLY6kNtmAABmADpmAGZmOgBmOjpmOpBmZjpmZmZmtv+QOgCQOjqQOmaQZgCQkDqQtpCQ29uQ2/+2ZgC2Zjq225C2/7a2/9u2///bkDrb25Db/7bb/9vb////tmb/25D//7b//9v///+fUz2OAAAACXBIWXMAAAsSAAALEgHS3X78AAAQnElEQVR4nO2di3rjthFG6d1t7Gw29nqzjeykjZS2Vhvrwvd/uwIgMIRkGOKIMjnj+c+XrGyZEH/yCBdKBNm0wCTN3AHAPEC8USDeKBBvFIg3CsQbBeKNAvFGgXijQLxRIN4oEG8UiDcKxBsF4o0C8UaBeKNAvFEg3igQbxSINwrEGwXijQLxRoF4o0C8USDeKBBvFIg3CsQbBeKNAvFGgXijQLxRIN4oEG8UiDcKxBsF4o0C8UaBeKNAvFEg3igQbxSINwrEGwXijQLxRoF4o0C8USDeKBBvFIg3CsQbBeKNAvFGgXijSBa/bjyLdv/QXC2P/ra98X9JS8SFPzzNkFIpksV7Np+e29UiPOTsvi7b7Y/LtIRjtZghnWKkiO9qcLu7az7+svQPXe31gnf3TwcLesOb6za69ks49o/HbQKoIkR8qMGfn9rVbbtxzbp7WHu14d/tl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4o0C8RNxdOGBfu7e9mbYFC4qEWZxxVdrD2cBMoD4CckuPEBz9/xk1fWQu5pRiXWcodxfKOGcu6JB/HRkFx7o5+4dTO2oFU4ltj99W6RXO3glHhA/HdmFB/q5e0PFpxL7xz8eFunV2vZwFiADiJ+M/MID/dy90NQPMJdKrG/3QTxdKCGfBcgA4icjv/BAVs/d4O7nAVeX6At24lO/PrTFOAbiJyO/8MDB3L1B/XQs0Q3nb/sLJRy+0nAgfioOLzxAc/e8tEHz66lEqPH9JWhWaOplc3jhgX7u3qZpBh2N0T2Ng/j+Qgln3usY4o0C8UaBeKNAvFEg3igQbxSIBxMA8UaBeKNA/HzEM33iVbvcb/F8DuYZQHHxvtSgM4AgfjbimT7x6tv+E19/kVb2GUDhqwX30JcadAYQxM9G/Po2Xplz478WCtfjZJ4BFBa/f+pLDTsDCOJn4+WJAPF7Ht4ZQLHG96WGnQEE8bMRz/Tpr8DqL87a8s8A6sYIfalhZwBB/Hx0Z/pQVd3d3ebPny4eWww3MPC3LqJSw1oMiJ8V1x+nq2/TTUfi86fLdmf6ZNds7koNOwMI4mcjnukTr77de2eeARRrfFZq0BlAED8f8Uyfro+OM3HOOANo06SbeblSg88AgnijQLxRIN4oEG8UiDcKxBsF4o0C8UaBeKNAvFEg3igQbxSINwrEGwXijQLxRoF4o0C8USDeKBBvFIg3CsQbBeKNAvFGgXijQLxRIN4oEG8UiDcKxBsF4o0C8UaBeKNAvFEg3igQbxSINwrEGwXijQLxRoF4o0C8USDeKBBvFIg3CsQbBeKNAvFGgXijQLxRIN4oEG8UiDcKxBsF4o0C8UaBeKNAvFEg3igQbxSINwrEGwXijQLxRoF4o0C8USDeKBBvFIg3CsQbBeKNAvFG+T+TqDjwP0ZdcAAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-2"/></p>
<h1>crossvalidation error</h1>
<pre><code class="r">cv.Tree1 <- cv.tree(Tree1)
## plot cross validation error cv.Tree1$dev as a function of size
plot(cv.Tree1$size,cv.Tree1$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ejf59OP25TD6vBG/+u33z8/7Uc37j93Mz9Xt/7675mA383q7rJsnfm0eAF0YEuLdkPnl3/8xO8xZ2Il3czjm02ay4f5j95fXu3858W4C6/bLZll3wLwtMw4kxO+a9sXU/ff2/43jbzMneP/xtuTczabaT1FovllMN8dlxoGG+CbQt034fp7RUbyb3fxptv84/GWz/v7z7sE9pGP73app/F82x2XGgYb4nc6nH/vZaUfxuxA+RrL7cnm9/v6ym4O4vHrZftNkBmOKdoeEeNfHbwUuDtNh38S7jtvNd9x/HNr/bVb/bea+2InfdRBvy4wDCfFNVr97yM7RefPP7g+Hj7e0rzmPn++z+r+a53dP35YZBxriA1l/H09kd4F4URAvCuJFQbwoiBcF8aIgXhTEi4J4URAvCuJFQbwoiBcF8aIgXhTEi4J4Uf4Pfhi/7rsDaMoAAAAASUVORK5CYII=" alt="plot of chunk unnamed-chunk-3"/></p>
<pre><code class="r">prune.Tree1 <- prune.tree(Tree1, best=5)
</code></pre>
<pre><code class="r">plot(prune.Tree1)
text(prune.Tree1, pretty=0)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAhFBMVEUAAAAAADoAAGYAOmYAOpAAZmYAZpAAZrY6AAA6ADo6AGY6OmY6OpA6kLY6kNtmAABmADpmAGZmOgBmOjpmOpBmZjpmZmZmtv+QOgCQOjqQOmaQZgCQkDqQtpCQ29uQ2/+2ZgC2/7a2///bkDrb/7bb/9vb////tmb/25D//7b//9v///+naZClAAAACXBIWXMAAAsSAAALEgHS3X78AAAM1UlEQVR4nO2dDVvbOBZGTdsdmA5DSqe7wHR3kyG7JMH///+t7rX8kRTYUMeJbt5znmf4cI3nRQdJdhRJVQ2SVKcOAKcB8aIgXhTEi4J4URAvCuJFQbwoiBcF8aIgXhTEi4J4URAvCuJFQbwoiBcF8aIgXhTEi4J4URAvCuJFQbwoiBcF8aIgXhTEi4J4URAvCuJFQbwoiBcF8aIgXhTEi4J4URAvCuJFQ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8fB5QtzL194nOunYI6fe4n4jqPf1V/Mn+/t0e0/X/7+wtzLl57j+4Gq0XMvEd9xsqJ45c0FvHJ3JBAvSvi5ee9LM9FvCT8w+R/WhGfDCBAvCuJLIY9/NnPz2kHRerLlZhFfCs34Zzs3r67bGXkTrUaG+ELIr5r28zPyY9VUC08ivhDy+GcvPr/HYarlZhFfCHn8M8/N619HmWq5WcQXQlvV27l5W3PuJ+jnEV8Igzl43t37oGgL4s+YZvwzz83rW/eplptFfCnk8c88N69fa3ii5WYRLwriRUG8KIgXBfGiIF4UxIuCeFEQLwriRUG8KIgXBfGiIF4UxIuCeFEQLwriRUG8KIgXBfGiIF4UxIuCeFEQDwWAeFEQLwripyNvfL+Z+dy89F1ebiEfH83WGj6Dq7Z7m7wJ4icjL65j69UumyWqbcmF7vj4/0Few8dm+24t5dPubfImiJ+Mdv/zW99MZmXrrBx0U+ThGj63j4OlfG73aU4QPxlZxcBznol9IPF5DZ9c4/urdnubvAniJyMvrtMvMv98fzM4Pvr67R4mzT1Ef9Vub5M3Qfx0NIvrdFVxM7sZHh9/+dyipBsH28qou+p+LQriJyX1t7mP7zcZycfHX7tZw6dvUfJVB2v7vAHiJyMvrmMNfPrUe28X3RlNs4ZPrvGDqy5o6k9Lu7iO98F5rVzfWqaqDvE0N1jDx/r25qp2/XZvkzdBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kX5HwYwfPCvMI71AAAAAElFTkSuQmCC" alt="plot of chunk unnamed-chunk-4"/></p>
<pre><code class="r">test_predict <- predict(prune.Tree1, newdata= testData)
plot(test_predict, testData$w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PqF2hBIPsjvTIZh4EhfMeFDYxoNC8aBQPChs40Fhrx4UigeF4kGheFAoHhSKB4XiQaF4UHyKJzHjT7wPQm0PfByKB41D8aBxKB40DsWDxqF40DgUDxonNvEkEBQPCsWDQvGgUDwoFA8KxYNC8aBQPCgUD0oc4q/b4mFXlpe34vHYvbjnUF+ZsvEepzw/F1/e/f89NnHiEL/flKfH43W7KQ9PZfPiiRBxLt925SFEnLeNcZwoxF++v7cv56/vzYunUJUT73HOL0cVJEycbzujOFGIP7/8Rx3qm7+jefETSqWE9zhNxnuP0w+gFycO8c8b9UdUR2G15c2Ll0j1ev3HubW23uPUh/qHnVGcOMRbfHL1UDvHf8aff9qVpy/v/v+eqnP3zx8JZ/zlX+ZtlR771zJAX6LJvRB9FuO+RBTiVa+++rxet6+33umrr1799YdKCO9xmoz3HqfuSzyZ/T1xiK/axCDj3uZI6D3OqQgyL6HifAqQ4DieBIfiQaF4UCgeFIoHheJBoXhQKB4UigeF4kGheFAoHhSKB4XiQaF4UCgeFIoHheJBoXhQKB4UIPGjS4+XrkW+bjfdIv6uj14Jip9H3YUoXTY5cMTXl3A313Gfio//r8u+/1bfvPePX7q3q5e//1JnfPV/D79/LJsJOOLrpN3X9xyoe06ql48svrw9HtU9T8+bsllEvZwKJV7l/enxT2Z8sqi7jG43STf3VXwWv1F32dT53SxSfTZubfxtKR7q00WJfyvqe1zOz/XvD/Hqk7BvD+xqkbqsfkfdi0jxKdPcV9hwejz2xbcZ//ElDcz4PGja+Mr46Xbz+udD/VP3xm2Rfht//vpfik+W67busqu7GfeqV1+/cSu6fPt3d+xvFrluP/fqdx/LZgKQ+Dt4++aVeMEWX3XyFA+/UzwBgeJBoXhQKB4UigeF4kGheFAoHhSKB4XiQaF4UCgeFIoHheJBoXhQKB6U/wO84P97Caf+NwAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-5"/></p>
<pre><code class="r">mean((test_predict - testData$wage76)^2)
</code></pre>
<pre><code>## [1] 59304.88
</code></pre>
<h3>Forests</h3>
<pre><code class="r">RF1 <- cforest(formula1, trainData, controls=cforest_control( mtry=4,mincriterion = 0) )
test_predict <- predict(RF1 ,newdata = testData, type = "response")
</code></pre>
<pre><code class="r">plot(test_predict, testData$wage76)
abline(0,1)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAgVBMVEUAAAAAADoAAGYAOjoAOmYAOpAAZrY6AAA6ADo6AGY6OmY6OpA6ZrY6kNtmAABmADpmAGZmOgBmOpBmZjpmtv+QOgCQOjqQOmaQZgCQkDqQtpCQ27aQ29uQ2/+2ZgC225C2/7a2///bkDrb25Db/7bb////tmb/25D//7b//9v////erms+AAAACXBIWXMAAAsSAAALEgHS3X78AAAb4klEQVR4nO2dDWPcuI2Gme0l6TZ1snuN0+t1nV7c2hPz///AG82IBECCFCmREmeAd9d2RvwUHwIgObLHWJVImaM7oDpGCl6oFLxQKXihUvBCpeCFSsELlYIXKgUvVApeqBS8UCl4oVLwQqXghUrBC5WCFyoFL1QKXqgUvFApeKFS8EKl4IVKwQuVghcqBS9UCl6oFLxQKXihUvBCpeCFSsELlYIXKgUvVApeqBS8UCl4oVLwQqXghUrBC5WCFyoFL1QKXqgUvFApeKFS8EKl4IVKwQuVghcqBS9UCl6oFLxQKXihUvBCpeCFSsELlYIXKgUvVApeqLaAN6qR1RH8hrKq3lLwQqXghUrBC5WCFyoFL1QKXqgUvFApeKLFg427kYLHMvYmu71GCh5LwRcmdyt7kBR8YfJZp4+XI/9ffqwou4fqorbG+LJka98ev15+vr5/qS67hwTZcJ22gv/52w/ys6bsHlLwCanFC9XmGP/z8z3FeDnSVb1QKXihuvvtnIrXvS/uVAnd+3ZOlZBavFDd/XZOxUtX9ULVAXzh72qoDpVu54RKF3dCpds5oVKLFyrdzgmVbueESsELVYvt3LsnXdzdnFos7t4eHxT8ranNdu77BwV/Y2q0nXv+068K/qbUYDv3MP14jvdzCn5k6apeqBS8UCl4oV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8/DEFtfj70Bzjz8Rfr7/Pjl39B3/hmoXG+NOv/1LwN6u3x8uSffoFx+/m+ldl/Kr+y9+875+zvD3iVf0T5L0TCQKfUY8/lDG4ZIM/L/ImvfunglcJkYIXKgUvVApeqBS8UCl4oVLwQqXghUrBC5WCFyoFL1QKXqgUvFApeKFS8EKl4IXq/wFaMX+PflGu9gAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-7"/></p>
<pre><code class="r">mean((test_predict - testData$wage76)^2)
</code></pre>
<pre><code>## [1] 50505.29
</code></pre>
<pre><code class="r">varimp(RF1 )
</code></pre>
<pre><code>## iqscore black exp76 age76
## 1462.498 4197.515 10680.731 36815.135
</code></pre>
<h4>classification tree</h4>
<pre><code class="r">formula1 <- high~ iqscore + black + exp76+ age76
Tree1 <- ctree(formula1, trainData )
# Tree1 <- tree(formula1, trainData )
</code></pre>
<pre><code class="r"># summary(Tree1)
plot(Tree1)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAn1BMVEUAAAAAADoAAGYAOmYAOpAAZmYAZpAAZrY6AAA6ADo6AGY6OgA6OmY6OpA6ZrY6kJA6kLY6kNtmAABmADpmAGZmOgBmOjpmOpBmZjpmZmZmtv+QOgCQOjqQOmaQZgCQkDqQtpCQ27aQ29uQ2/+2ZgC2Zjq2tma2/7a2/9u2///T09PbkDrb/7bb/9vb////nTr/tmb/25D//7b//9v////NsCFIAAAACXBIWXMAAAsSAAALEgHS3X78AAAcP0lEQVR4nO1di5bbuJFl20667Y2TVU87npGdmclK2d1ebRxJzf//thAgQIAkSLwK77pnzkhWExdVdQmQeHc9okl0qQ1ApAEK3yhQ+EaBwjeKCoXvFkhtT56oMCzd7j8RIyoMCwpvggrDgsKboMKwoPAmqDAszKXbp1f5n4g5KgzL6NK1e4fC76DCsFCXzg+/Y4nfQ4VhwareBJWFReqxmYTHThwVagoJE1hV4lH7JaqJh5B2o6pH7WeoIxgzUb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IA4rAZHcrYDrh0/3l1+7Xgvjn0KIA6rwZGc7YAQfh9mwpfCgT13DjnUwIHCO+RQAwcK75BDDRwovEMONXCg8BJmO+m5DdJAcOxTAHHYbiyYrR0g7Xh5Jz2y78ZGyrAcGgogDtuNBbO1A0B4aZcdks95cW+Z3eH+HBoKIA6rTYdytgNA+Pl8ffHNcXTOlWOLApbDalRM6YqPHY6jc0oOcaWr8LPdtEhH4VbKsBwaCiAOq1GxnO0ALvH3ZydHITg0FEAcdiUtYztAn/F0ed52yrAcGgogDquZLznbAfJWP+2k5+ooBIeGAojDamPBnO2Aa8cPd9c48OvyVg/BsU8BxGEzKpa1HRDC78NM+FI4sOfOIYcaOFB4hxxq4EDhHXKogQOFd8ihBg4UXgnno0lgOZyPBNFzWAU8ZztAhZ8t11qnjMWhpADisAl41naACi8v15qlZAMLkTiUFCRl58/BBzj87fDjsBFeE1IA4ecDQmIYyCLgEByL7b3EiBYYh1k81K7kwtGbcRiJ5n4YESiH+yFADXGAVvXuGxyCcrhvLNgQR5xnfFyOzWcrcqgoQN7qDwBv9d4cSgrk2KLAdnxTHLDCK1MKIEc+HJ0hh7uRiKKBwjcKFL5RoPCNAoVvFCh8o0DhGwUK3yhQ+EaBwjcKFL5RoPCNAoVvFCh8o0DhGwUK3yhQ+EaBwjcKFL5RoPCNAoVvFCh8o0DhGwUK3yhQ+EaBwjcKFL5RoPCNAoVvFCh8o0DhGwUK3yhQ+EaBwjcKFL5RoPCN4t/e1DKB1ZYToQAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-10"/></p>
<pre><code class="r"># text(Tree1, pretty=0)
</code></pre>
<pre><code class="r">train_predict <- predict(Tree1, trainData, type="response")
</code></pre>
<h2>in-sample confusion matrix</h2>
<pre><code class="r">table(train_predict>0.5,trainData$high)
</code></pre>
<pre><code>##
## 0 1
## FALSE 1699 428
</code></pre>
<pre><code class="r">mean( (train_predict>0.5) != trainData$high )*100
</code></pre>
<pre><code>## [1] 20.12224
</code></pre>
<pre><code class="r">test_predict <- predict(Tree1, testData, type="response")
table(test_predict>0.5,testData$high)
</code></pre>
<pre><code>##
## 0 1
## FALSE 727 156
</code></pre>
<pre><code class="r">mean( (test_predict>0.5) != testData$high )*100
</code></pre>
<pre><code>## [1] 17.66704
</code></pre>
<h2>Causal Forest</h2>
<p>Generate feature data: \( X \sim \mathcal{N}(0, I_{p\times p}) \)</p>
<pre><code class="r">n = 2000; p = 10
X = matrix(rnorm(n*p), n, p)
out_len = 101
X.test = matrix(0, out_len , p)
X.test[,1] = seq(-2, 2, length.out = out_len )
</code></pre>
<p>Then we simulate the treatement variable, with propensity score \( p(X) = 0.5 \), and the outcome variable
\[ Y = \tau(X) D + X_2 + X_3 \wedge 0 + \varepsilon, \quad \varepsilon \sim \mathcal{N}(0,1), \]
\[ \tau(X) = X_1 \vee 0 \]</p>
<pre><code class="r"># Perform treatment effect estimation.
D = rbinom(n, 1, 0.5)
Y = pmax(X[,1], 0) * D + X[,2] + pmin(X[,3], 0) + rnorm(n)
dataTrain <- as.data.frame(cbind(X,Y,D))
formula1 = paste( paste(colnames(dataTrain)[11], "~ "),paste(colnames(dataTrain)[1:10],collapse="+"))
# tau.forest = causalForest(formula1, data=as.matrix(dataTrain), treatment = dataTrain$D,
# split.Rule="CT", split.Honest=T, split.Bucket=F, bucketNum = 5,
# bucketMax = 100, cv.option="CT", cv.Honest=T, minsize = 2L,
# split.alpha = 0.5, cv.alpha = 0.5,
# sample.size.total = floor(nrow(dataTrain) / 2), sample.size.train.frac = .5,
# mtry = ceiling(ncol(dataTrain)/3), nodesize = 3, num.trees= 5,ncolx=p,ncov_sample=p)
ind <- sample(1:n,floor(n/2),replace=F)
# honestTree <- honest.causalTree(formula1, data=dataTrain[ind ,], treatment = dataTrain$D[ind ],
# est_data = dataTrain[-ind, ],
# est_treatment = dataTrain$D[-ind ],
# split.Rule = "CT", split.Honest = T,
# HonestSampleSize = nrow(dataTrain[-ind, ]),
# split.Bucket = T, cv.option = "CT")
#
# honestTree$cptable
</code></pre>
<pre><code class="r"># opcp <- honestTree$cptable[,1][which.min(honestTree$cptable[,4])]
# opTree <- prune(honestTree, opcp)
</code></pre>
<pre><code class="r"># rpart.plot(opTree)
</code></pre>
<pre><code class="r"># out <- matrix(0,1,out_len )
# #### Forest
# s=floor(0.7*n)
# ntree=300
#
# for(b in 1:ntree){
# ind <- sample(1:n,s,replace=F)
# dataTrain <- as.data.frame(cbind(X,Y,D))[ind,]
# ind <- sample(1:s,floor(s/2),replace=F)
# honestTree <- honest.causalTree(formula1, data=dataTrain[ind ,], treatment = dataTrain$D[ind ],
# est_data = dataTrain[-ind, ],
# est_treatment = dataTrain$D[-ind ],
# split.Rule = "CT", split.Honest = T,
# HonestSampleSize = nrow(dataTrain[-ind, ]),
# split.Bucket = T, cv.option = "CT")
# opcp <- honestTree$cptable[,1][which.min(honestTree$cptable[,4])]
# opTree <- prune(honestTree, opcp)
# out <- out + predict(opTree, newdata=as.data.frame(X.test))
# }
# out <- out /ntree
</code></pre>
<pre><code class="r"># plot(X.test[,1],out, ylim = range(out, 0, 2), xlab = "x", ylab = "tau", type = "l")
# lines(X.test[,1], pmax(0, X.test[,1]), col = 2, lty = 2)
</code></pre>
<pre><code class="r">library(grf)
# cfpredtest <- predict(cf, newdata=dataTest, type="vector")
tau.forest_2 = causal_forest(X, Y, D, precompute.nuisance = FALSE)
tau.hat_2 = predict(tau.forest_2, X.test)
tau.forest = causal_forest(X, Y, D)
tau.hat = predict(tau.forest, X.test)
variable_importance(tau.forest)
</code></pre>
<pre><code>## [,1]
## [1,] 0.70329348
## [2,] 0.02798928
## [3,] 0.02597512
## [4,] 0.03096732
## [5,] 0.02857355
## [6,] 0.04540747
## [7,] 0.04276017
## [8,] 0.04374960
## [9,] 0.02601756
## [10,] 0.02526645
</code></pre>
<p>Estimate the conditional average treatment effect on the full sample (CATE).</p>
<pre><code class="r">plot(X.test[,1], tau.hat$predictions, ylim = range(tau.hat$predictions, 0, 2), xlab = "x", ylab = "tau", type = "l")
lines(X.test[,1], tau.hat_2$predictions, col = 4, lty = 2)
lines(X.test[,1], pmax(0, X.test[,1]), col = 2, lty = 2)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAbFBMVEUAAAAAADoAAGYAAP8AOjoAOpAAZrY6AAA6ADo6AGY6OpA6ZrY6kNtmAABmADpmAGZmZmZmtv+QOgCQOjqQOmaQtpCQ29uQ2/+2ZgC2/7a2///bkDrb/9vb////AAD/tmb/25D//7b//9v///8vBkxzAAAACXBIWXMAAAsSAAALEgHS3X78AAAMWklEQVR4nO2di3abOhZA6ZxpOs1t2knunZtMM7Gd8P//OOFpbIMN6MGRzt6rC2E7EnB2hYRsUFGCSYqtdwC2AfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRnERX4BmAop3yAuhQbxREG8UZ/GHb3WL8Y/fK/LCdriK/3h6rNP917fFeWFDXMW///p9ki7JCxtCjTeKcxv//kAbnyL06o2CeKP4Ej/o3M0cFIS47E5fUuONsDvTgXgTFMXu/J0bGW4WefhWfHnmOl43xfmJ3s91/MfTD8RrZsyEn5G7lzvEKyaE+Hbk7vWf3xGvlVERHkbuflTJ6+XQHeKVcNGxq9+8kcdlew55wR+1dxE5e/dGJpcNOuQFf+wq7RfvIj53Rk/0iM+eCe+Iz51PCzLx/o1sLpuErZnyjvi8qU70Mv7JjYwuG3XIC36Y9I74rJn2jvicOf8OfgjiM6aQK5/dyOqyWYe84APEG0WufIb4bNkh3iS7q2d6xGfL7roAxGfK7oYAxOcL4m1ytYlHfL7I1U8RnyP1jy/k6p8gPkNmeEd8hjQ/tpLrf4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yvPqz45dH3Jv61vnsjqHyu4ydZHn1G7oyCeKMg3iiINwrijYJ4oyDeKIg3CuKNgnijIN4oiDcK4o2CeKMg3iiINwrijYJ4oyDeKIg3CuKNgnijIL7hJfjv6pWB+Ib3X/+9nDU5ZxDf8lqEveNTG4hvCftQB30gvuXl36aaeMS3HO7/96epKo/4muoZOPvAd03qAvFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFH+D9P/5zfGCCwYAAAAAElFTkSuQmCC" alt="plot of chunk unnamed-chunk-21"/></p>
<pre><code class="r"># Estimate the conditional average treatment effect on the full sample (CATE).
estimate_average_effect(tau.forest, target.sample = "all")
</code></pre>
<pre><code>## Error in estimate_average_effect(tau.forest, target.sample = "all"): impossible de trouver la fonction "estimate_average_effect"
</code></pre>
<pre><code class="r"># Estimate the conditional average treatment effect on the treated sample (CATT).
# Here, we don't expect much difference between the CATE and the CATT, since
# treatment assignment was randomized.
estimate_average_effect(tau.forest, target.sample = "treated")
</code></pre>
<pre><code>## Error in estimate_average_effect(tau.forest, target.sample = "treated"): impossible de trouver la fonction "estimate_average_effect"
</code></pre>
<pre><code class="r"># Add confidence intervals for heterogeneous treatment effects
tau.forest = causal_forest(X, Y, D, num.trees = 4000)
tau.hat = predict(tau.forest, X.test, estimate.variance = TRUE)
sigma.hat = sqrt(tau.hat$variance.estimates)
</code></pre>
<pre><code class="r">plot(X.test[,1], tau.hat$predictions, ylim = range(tau.hat$predictions + 1.96 * sigma.hat, tau.hat$predictions - 1.96 * sigma.hat, 0, 2), xlab = "x", ylab = "tau", type = "l")
lines(X.test[,1], tau.hat$predictions + 1.96 * sigma.hat, col = 1, lty = 2)
lines(X.test[,1], tau.hat$predictions - 1.96 * sigma.hat, col = 1, lty = 2)
lines(X.test[,1], pmax(0, X.test[,1]), col = 2, lty = 1)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAA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ttv6T494fvgrWNUQxdv/5G5eIDoy8i/qnrbvv+kZb3Q/20+DlCoy/Zq9ft06uGTv0cr9+rD4y+mHh975qh64+Tur16XfHh0RcT/7x/ekNVPtfxk4RHn5E7oyDeKIg3CuKNgnijIN4oiDcK4o2CeKMg3iiINwrijYJ4oyDeKIg3CuKNgnijIN4oiDcK4o2CeKMg3iiIP/CkPq++MBB/4O3nf34qP9RYFog/8tzpPvFZGog/opvUoTwQf+TpX6ZO8Yg/sr3731+mmjzi9/Q5cF6Vn5osC8QbBfFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8Ub5P5cFcsGj3IM7AAAAAElFTkSuQmCC" alt="plot of chunk unnamed-chunk-23"/></p>
<p>Add confidence intervals for heterogeneous treatment effects; growing more trees is now recommended.</p>
<pre><code class="r">tau.forest = causal_forest(X, Y, D, num.trees = 4000)
tau.hat = predict(tau.forest, X.test, estimate.variance = TRUE)
sigma.hat = sqrt(tau.hat$variance.estimates)
</code></pre>
<pre><code class="r">plot(X.test[,1], tau.hat$predictions, ylim = range(tau.hat$predictions +
1.96 * sigma.hat, tau.hat$predictions - 1.96 * sigma.hat, 0, 2),
xlab = "x", ylab = "tau", type = "l")
lines(X.test[,1], tau.hat$predictions + 1.96 * sigma.hat, col = 1, lty = 2)
lines(X.test[,1], tau.hat$predictions - 1.96 * sigma.hat, col = 1, lty = 2)
lines(X.test[,1], pmax(0, X.test[,1]), col = 2, lty = 1)
</code></pre>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAMAAABy/YdMAAAAaVBMVEUAAAAAADoAAGYAOjoAOpAAZrY6AAA6ADo6AGY6OpA6ZrY6kNtmAABmADpmAGZmZmZmtv+QOgCQOjqQOmaQtpCQ29uQ2/+2ZgC2/7a2///bkDrb/9vb////AAD/tmb/25D//7b//9v///+iu78+AAAACXBIWXMAAAsSAAALEgHS3X78AAANeklEQVR4nO2di3qcuhVGcVunceK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KNgnijIN4oiDcK4o2CeKMg3iiINwrijYJ4oyDeKIg3CuKNgnijIN4oiDcK4o2CeKMg3iiINwrijYL4Ay/q/eoLA/EH3r//57vyS41lgfgjr53uG5+lgfgjuoM6lAfij7z8y9QpHvFHtg//+8tUlUf8nn4MnDfltybLAvFGQbxREG8UxBsF8UZBvFEQbxTEGwXxRkG8URBvFMQbBfFGQbxREG8UxBsF8UZBvFH+Dx1Ic3kE6o4PAAAAAElFTkSuQmCC" alt="plot of chunk unnamed-chunk-25"/></p>
<h4>Another example</h4>
<h2>Case 1: without confounding factoers (p(x)=0)</h2>
<p>Generate data: \( X \sim \mathcal{N}(0, I_{d\times d}) \), treatement variable, with propensity score \( p(X) = 0.5 \), and the outcome variable
\[ Y = \tau(X) (D-0.5) + \varepsilon, \quad \varepsilon \sim \mathcal{N}(0,1), \]
with \[ \tau(X) = \zeta(X_1) \zeta(X_2), \quad \zeta(x) = 1 + \dfrac{1}{1+e^{-20(x-1/3)}} . \]</p>
<pre><code class="r">### Without confounding factors (p(x) =constant)
# Generate data.
n = 10000; p = 3
X = matrix(runif(n*p), n, p)
X.test =matrix(runif(n*p), n, p)
# Perform treatment effect estimation.
D = rbinom(n, 1, 0.5)
zeta1 <- function(x){
return(1+ 1/(1+ exp(-20*(x-1/3))))
}
Y = (D-0.5)*(zeta1(X[,1]) *zeta1(X[,2])) + rnorm(n)
truth = (zeta1(X.test[,1]) *zeta1(X.test[,2]))
##### with CausalForest package
ntree=500
forest = causalForest(X, Y, D, num.trees = ntree, sample.size = n / 10)
</code></pre>
<pre><code>## [1] "Building trees ..."
## [1] "Tree 1"
## [1] "Tree 2"
## [1] "Tree 3"
## [1] "Tree 4"
## [1] "Tree 5"
## [1] "Tree 6"
## [1] "Tree 7"
## [1] "Tree 8"
## [1] "Tree 9"
## [1] "Tree 10"
## [1] "Tree 11"
## [1] "Tree 12"
## [1] "Tree 13"
## [1] "Tree 14"
## [1] "Tree 15"
## [1] "Tree 16"
## [1] "Tree 17"
## [1] "Tree 18"
## [1] "Tree 19"
## [1] "Tree 20"
## [1] "Tree 21"
## [1] "Tree 22"
## [1] "Tree 23"
## [1] "Tree 24"
## [1] "Tree 25"
## [1] "Tree 26"
## [1] "Tree 27"
## [1] "Tree 28"
## [1] "Tree 29"
## [1] "Tree 30"
## [1] "Tree 31"
## [1] "Tree 32"
## [1] "Tree 33"
## [1] "Tree 34"
## [1] "Tree 35"
## [1] "Tree 36"
## [1] "Tree 37"
## [1] "Tree 38"
## [1] "Tree 39"
## [1] "Tree 40"
## [1] "Tree 41"
## [1] "Tree 42"
## [1] "Tree 43"
## [1] "Tree 44"
## [1] "Tree 45"
## [1] "Tree 46"
## [1] "Tree 47"
## [1] "Tree 48"
## [1] "Tree 49"
## [1] "Tree 50"
## [1] "Tree 51"
## [1] "Tree 52"
## [1] "Tree 53"
## [1] "Tree 54"
## [1] "Tree 55"
## [1] "Tree 56"
## [1] "Tree 57"
## [1] "Tree 58"
## [1] "Tree 59"
## [1] "Tree 60"
## [1] "Tree 61"
## [1] "Tree 62"
## [1] "Tree 63"
## [1] "Tree 64"
## [1] "Tree 65"
## [1] "Tree 66"
## [1] "Tree 67"
## [1] "Tree 68"
## [1] "Tree 69"
## [1] "Tree 70"
## [1] "Tree 71"
## [1] "Tree 72"
## [1] "Tree 73"
## [1] "Tree 74"
## [1] "Tree 75"
## [1] "Tree 76"
## [1] "Tree 77"
## [1] "Tree 78"
## [1] "Tree 79"
## [1] "Tree 80"
## [1] "Tree 81"
## [1] "Tree 82"
## [1] "Tree 83"
## [1] "Tree 84"
## [1] "Tree 85"
## [1] "Tree 86"
## [1] "Tree 87"
## [1] "Tree 88"
## [1] "Tree 89"
## [1] "Tree 90"
## [1] "Tree 91"
## [1] "Tree 92"
## [1] "Tree 93"
## [1] "Tree 94"
## [1] "Tree 95"
## [1] "Tree 96"
## [1] "Tree 97"
## [1] "Tree 98"
## [1] "Tree 99"
## [1] "Tree 100"
## [1] "Tree 101"
## [1] "Tree 102"
## [1] "Tree 103"
## [1] "Tree 104"
## [1] "Tree 105"
## [1] "Tree 106"
## [1] "Tree 107"
## [1] "Tree 108"
## [1] "Tree 109"
## [1] "Tree 110"
## [1] "Tree 111"
## [1] "Tree 112"
## [1] "Tree 113"
## [1] "Tree 114"
## [1] "Tree 115"
## [1] "Tree 116"
## [1] "Tree 117"
## [1] "Tree 118"
## [1] "Tree 119"
## [1] "Tree 120"
## [1] "Tree 121"
## [1] "Tree 122"
## [1] "Tree 123"
## [1] "Tree 124"
## [1] "Tree 125"
## [1] "Tree 126"
## [1] "Tree 127"
## [1] "Tree 128"
## [1] "Tree 129"
## [1] "Tree 130"
## [1] "Tree 131"
## [1] "Tree 132"
## [1] "Tree 133"
## [1] "Tree 134"
## [1] "Tree 135"
## [1] "Tree 136"
## [1] "Tree 137"
## [1] "Tree 138"
## [1] "Tree 139"
## [1] "Tree 140"
## [1] "Tree 141"
## [1] "Tree 142"
## [1] "Tree 143"
## [1] "Tree 144"
## [1] "Tree 145"
## [1] "Tree 146"
## [1] "Tree 147"
## [1] "Tree 148"
## [1] "Tree 149"
## [1] "Tree 150"
## [1] "Tree 151"
## [1] "Tree 152"
## [1] "Tree 153"
## [1] "Tree 154"
## [1] "Tree 155"
## [1] "Tree 156"
## [1] "Tree 157"
## [1] "Tree 158"
## [1] "Tree 159"
## [1] "Tree 160"
## [1] "Tree 161"
## [1] "Tree 162"
## [1] "Tree 163"
## [1] "Tree 164"
## [1] "Tree 165"
## [1] "Tree 166"
## [1] "Tree 167"
## [1] "Tree 168"
## [1] "Tree 169"
## [1] "Tree 170"
## [1] "Tree 171"
## [1] "Tree 172"
## [1] "Tree 173"
## [1] "Tree 174"
## [1] "Tree 175"
## [1] "Tree 176"
## [1] "Tree 177"
## [1] "Tree 178"
## [1] "Tree 179"
## [1] "Tree 180"
## [1] "Tree 181"
## [1] "Tree 182"
## [1] "Tree 183"
## [1] "Tree 184"
## [1] "Tree 185"
## [1] "Tree 186"
## [1] "Tree 187"
## [1] "Tree 188"
## [1] "Tree 189"
## [1] "Tree 190"
## [1] "Tree 191"
## [1] "Tree 192"
## [1] "Tree 193"
## [1] "Tree 194"
## [1] "Tree 195"
## [1] "Tree 196"
## [1] "Tree 197"
## [1] "Tree 198"
## [1] "Tree 199"
## [1] "Tree 200"
## [1] "Tree 201"
## [1] "Tree 202"
## [1] "Tree 203"
## [1] "Tree 204"
## [1] "Tree 205"
## [1] "Tree 206"
## [1] "Tree 207"
## [1] "Tree 208"
## [1] "Tree 209"
## [1] "Tree 210"
## [1] "Tree 211"
## [1] "Tree 212"
## [1] "Tree 213"
## [1] "Tree 214"
## [1] "Tree 215"
## [1] "Tree 216"
## [1] "Tree 217"
## [1] "Tree 218"
## [1] "Tree 219"
## [1] "Tree 220"
## [1] "Tree 221"
## [1] "Tree 222"
## [1] "Tree 223"
## [1] "Tree 224"
## [1] "Tree 225"
## [1] "Tree 226"
## [1] "Tree 227"
## [1] "Tree 228"
## [1] "Tree 229"
## [1] "Tree 230"
## [1] "Tree 231"
## [1] "Tree 232"
## [1] "Tree 233"
## [1] "Tree 234"
## [1] "Tree 235"
## [1] "Tree 236"
## [1] "Tree 237"
## [1] "Tree 238"
## [1] "Tree 239"
## [1] "Tree 240"
## [1] "Tree 241"
## [1] "Tree 242"
## [1] "Tree 243"
## [1] "Tree 244"
## [1] "Tree 245"
## [1] "Tree 246"
## [1] "Tree 247"
## [1] "Tree 248"
## [1] "Tree 249"
## [1] "Tree 250"
## [1] "Tree 251"
## [1] "Tree 252"
## [1] "Tree 253"
## [1] "Tree 254"
## [1] "Tree 255"
## [1] "Tree 256"
## [1] "Tree 257"
## [1] "Tree 258"
## [1] "Tree 259"
## [1] "Tree 260"
## [1] "Tree 261"
## [1] "Tree 262"
## [1] "Tree 263"
## [1] "Tree 264"
## [1] "Tree 265"
## [1] "Tree 266"
## [1] "Tree 267"
## [1] "Tree 268"
## [1] "Tree 269"
## [1] "Tree 270"
## [1] "Tree 271"
## [1] "Tree 272"
## [1] "Tree 273"
## [1] "Tree 274"
## [1] "Tree 275"
## [1] "Tree 276"
## [1] "Tree 277"
## [1] "Tree 278"
## [1] "Tree 279"
## [1] "Tree 280"
## [1] "Tree 281"
## [1] "Tree 282"
## [1] "Tree 283"
## [1] "Tree 284"
## [1] "Tree 285"
## [1] "Tree 286"
## [1] "Tree 287"
## [1] "Tree 288"
## [1] "Tree 289"
## [1] "Tree 290"
## [1] "Tree 291"
## [1] "Tree 292"
## [1] "Tree 293"
## [1] "Tree 294"
## [1] "Tree 295"
## [1] "Tree 296"
## [1] "Tree 297"
## [1] "Tree 298"
## [1] "Tree 299"
## [1] "Tree 300"
## [1] "Tree 301"
## [1] "Tree 302"
## [1] "Tree 303"
## [1] "Tree 304"
## [1] "Tree 305"
## [1] "Tree 306"
## [1] "Tree 307"
## [1] "Tree 308"
## [1] "Tree 309"
## [1] "Tree 310"
## [1] "Tree 311"
## [1] "Tree 312"
## [1] "Tree 313"
## [1] "Tree 314"
## [1] "Tree 315"
## [1] "Tree 316"
## [1] "Tree 317"
## [1] "Tree 318"
## [1] "Tree 319"
## [1] "Tree 320"
## [1] "Tree 321"
## [1] "Tree 322"
## [1] "Tree 323"
## [1] "Tree 324"
## [1] "Tree 325"
## [1] "Tree 326"
## [1] "Tree 327"
## [1] "Tree 328"
## [1] "Tree 329"
## [1] "Tree 330"
## [1] "Tree 331"
## [1] "Tree 332"
## [1] "Tree 333"
## [1] "Tree 334"
## [1] "Tree 335"
## [1] "Tree 336"
## [1] "Tree 337"
## [1] "Tree 338"
## [1] "Tree 339"
## [1] "Tree 340"
## [1] "Tree 341"
## [1] "Tree 342"
## [1] "Tree 343"
## [1] "Tree 344"
## [1] "Tree 345"
## [1] "Tree 346"
## [1] "Tree 347"
## [1] "Tree 348"
## [1] "Tree 349"
## [1] "Tree 350"
## [1] "Tree 351"
## [1] "Tree 352"
## [1] "Tree 353"
## [1] "Tree 354"
## [1] "Tree 355"
## [1] "Tree 356"
## [1] "Tree 357"
## [1] "Tree 358"
## [1] "Tree 359"
## [1] "Tree 360"
## [1] "Tree 361"
## [1] "Tree 362"
## [1] "Tree 363"
## [1] "Tree 364"
## [1] "Tree 365"
## [1] "Tree 366"
## [1] "Tree 367"
## [1] "Tree 368"
## [1] "Tree 369"
## [1] "Tree 370"
## [1] "Tree 371"
## [1] "Tree 372"
## [1] "Tree 373"
## [1] "Tree 374"
## [1] "Tree 375"
## [1] "Tree 376"
## [1] "Tree 377"
## [1] "Tree 378"
## [1] "Tree 379"
## [1] "Tree 380"
## [1] "Tree 381"
## [1] "Tree 382"
## [1] "Tree 383"
## [1] "Tree 384"
## [1] "Tree 385"
## [1] "Tree 386"
## [1] "Tree 387"
## [1] "Tree 388"
## [1] "Tree 389"
## [1] "Tree 390"
## [1] "Tree 391"
## [1] "Tree 392"
## [1] "Tree 393"
## [1] "Tree 394"
## [1] "Tree 395"
## [1] "Tree 396"
## [1] "Tree 397"
## [1] "Tree 398"
## [1] "Tree 399"
## [1] "Tree 400"
## [1] "Tree 401"
## [1] "Tree 402"
## [1] "Tree 403"
## [1] "Tree 404"
## [1] "Tree 405"
## [1] "Tree 406"
## [1] "Tree 407"
## [1] "Tree 408"
## [1] "Tree 409"
## [1] "Tree 410"
## [1] "Tree 411"
## [1] "Tree 412"
## [1] "Tree 413"
## [1] "Tree 414"
## [1] "Tree 415"
## [1] "Tree 416"
## [1] "Tree 417"
## [1] "Tree 418"
## [1] "Tree 419"
## [1] "Tree 420"
## [1] "Tree 421"
## [1] "Tree 422"
## [1] "Tree 423"
## [1] "Tree 424"
## [1] "Tree 425"
## [1] "Tree 426"
## [1] "Tree 427"
## [1] "Tree 428"
## [1] "Tree 429"
## [1] "Tree 430"
## [1] "Tree 431"
## [1] "Tree 432"
## [1] "Tree 433"
## [1] "Tree 434"
## [1] "Tree 435"
## [1] "Tree 436"
## [1] "Tree 437"
## [1] "Tree 438"
## [1] "Tree 439"
## [1] "Tree 440"
## [1] "Tree 441"
## [1] "Tree 442"
## [1] "Tree 443"
## [1] "Tree 444"
## [1] "Tree 445"
## [1] "Tree 446"
## [1] "Tree 447"
## [1] "Tree 448"
## [1] "Tree 449"
## [1] "Tree 450"
## [1] "Tree 451"
## [1] "Tree 452"
## [1] "Tree 453"
## [1] "Tree 454"
## [1] "Tree 455"
## [1] "Tree 456"
## [1] "Tree 457"
## [1] "Tree 458"
## [1] "Tree 459"
## [1] "Tree 460"
## [1] "Tree 461"
## [1] "Tree 462"
## [1] "Tree 463"
## [1] "Tree 464"
## [1] "Tree 465"