I would like to ask you to help me with this code below. I do a BART and after I fix seeds and initial burns-in and iteractions, I would like to produce a ggplot but in somehow, it does not work. I use "beta"=5, initial burns-in=1000 and MCMC=5000 and I fix seeds=17
Xc=X=dat2[,-1] # The first column is the response
Xc$z=factor((1:0)[X$z])
library(BayesTree)
set.seed(17)
bartFit = bart(X,dat2$y,Xc, sigest=NA, sigdf=3, sigquant=.90, k=2.0,
power=5.0, base=.95,binaryOffset=0, ntree=200,
ndpost=4000, nskip=1000, printevery=500, keepevery=1,
keeptrainfits=TRUE,
usequants=FALSE, numcut=100, printcutoffs=0,
verbose=TRUE)
pte=apply(bartFit$yhat.train-bartFit$yhat.test,2,mean)
## This distribution is reported in the following histogram: Posterior
distribution of ATE
ss=dat2$z==1
ggplot()+ geom_histogram(binwidth = 2.0, aes(pte[ss],weights=nw(w[ss])))+
geom_vline(xintercept=0) + labs(x = "PISA Score") + xlim(c=-20,10)
I got the following error message and I do not understand why.
Warning: Ignoring unknown aesthetics: weights
Error in eval(expr, envir, enclos) : object 'pte' not found
I run the same code for another dataset with same variables and content but with 2500 obs. Now, when I do for this dataset with 26000 obs, something goes wrong.
Can someone please understand and tell me what I am doing wrong? It will be very appreciated because I do not understand why same codes do not work with same dataset but different numbers of obs.
Thank you very very much