# simdat: Simulated Example In rbart: Bayesian Trees for Conditional Mean and Variance

## Description

Simulated data with nonlinear mean and heteroskedasticity.

## Usage

 `1` ```data("simdat") ```

## Format

`x`

simulated train x values

`y`

simulated train y values

`xp`

simulated test xp values

`yp`

simulated test yp values

`fx`

true f evaluated on train x

`sx`

true s evaluated on train x

`fxp`

true f evaluated on test xp

`sxp`

true s evaluated on test xp

## Details

The simulated data in simdat was generated using the code:

##simulate data
set.seed(99)

# train data
n=500 #train data sample size
p=1 #just one x
x = matrix(sort(runif(n*p)),ncol=p) #iid uniform x values
fx = 4*(x[,1]^2) #quadratric function f
sx = .2*exp(2*x[,1]) # exponential function s
y = fx + sx*rnorm(n) # y = f(x) + s(x) Z

#test data (the p added to the variable names is for predict)
np=1000 #test data sample size
xp = matrix(sort(runif(np*p)),ncol=p)
fxp = 4*(xp[,1]^2)
sxp = .2*exp(2*xp[,1])
yp = fxp + sxp*rnorm(np)

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```data(simdat) ## plot x vs y with f(x) and f(x) +/- 2s(x) for train and test simulated data ##train plot(simdat\$x,simdat\$y,xlab="x",ylab="y") ##test points(simdat\$xp,simdat\$yp,col="red",pch=2) lines(simdat\$xp,simdat\$fxp,col="blue",lwd=2) lines(simdat\$xp,simdat\$fxp+2*simdat\$sxp,col="blue",lwd=2,lty=2) lines(simdat\$xp,simdat\$fxp-2*simdat\$sxp,col="blue",lwd=2,lty=2) legend("topleft",legend=c("train","test"),pch=c(1,2),col=c("black","red")) ```

rbart documentation built on Aug. 1, 2019, 5:04 p.m.