ggplot BART(贝叶斯加性回归树)

时间:2017-04-15 08:20:07

标签: r ggplot2

我想请你帮我解决下面这段代码。我做了一个BART,在我修复种子和初始烧伤和迭代之后,我想制作一个ggplot,但不知怎的,它不起作用。 我使用" beta" = 5,初始烧伤= 1000和MCMC = 5000我修复种子= 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)

我收到以下错误消息,我不明白为什么。

Warning: Ignoring unknown aesthetics: weights
Error in eval(expr, envir, enclos) : object 'pte' not found

我为具有相同变量和内容但具有2500 obs的另一个数据集运行相同的代码。现在,当我使用26000 obs这个数据集时,出现问题。

有人可以理解并告诉我我做错了什么吗?我将非常感激,因为我不明白为什么相同的代码不能使用相同的数据集但不同的数量的obs。

非常感谢

0 个答案:

没有答案