You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we are fitting a normal BART model using a dbarts sampler and we know the true residual variance is equal to one. When I specify resid.prior = fixed(1), it seems like the sampler is respecting my wishes. But when I interrogate the state of the sampler after running there is a sigma$\ne 1$. Can someone explain what exactly is happening here?
I actually do have a problem where I will need to be able to do this. The above solution appears to be working despite the sigma inside sampler$state, but I just want to confirm. If this actually is not working, I will need to find some other way around it.
Reproducible example:
# Fixed sigma reprex
# Simulate Data
set.seed(1)
n <- 100
p <- 5
x <- t(replicate(n, runif(p, 0, 1)))
f <- function(x){
10*sin(pi*x[,1]*x[,2]) + 20*(x[,3] - .5)^2 + 10*x[,4] + 5*x[,5]
}
y <- rnorm(n, f(x), 1)
# Create dbarts sampler object
library(dbarts)
control <- dbartsControl(n.trees = 100, n.samples = 1000, n.burn = 0,
n.chains = 1, keepTrees = TRUE, keepTrainingFits = TRUE,
updateState = TRUE, verbose = FALSE)
sampler <- dbarts(x, y, control = control, resid.prior = fixed(1), sigma = 1)
sigma <- numeric(1000)
for(k in seq_len(1000)){
samples <- sampler$run(0, 1)
sigma[k] <- samples$sigma
}
# Print sigma stored in state
print(sampler$state[[1]]@sigma)
# Plot sigma values
plot(sigma)
Thanks!
The text was updated successfully, but these errors were encountered:
Suppose we are fitting a normal BART model using a$\ne 1$ . Can someone explain what exactly is happening here?
dbarts
sampler and we know the true residual variance is equal to one. When I specifyresid.prior = fixed(1)
, it seems like the sampler is respecting my wishes. But when I interrogate the state of the sampler after running there is asigma
I actually do have a problem where I will need to be able to do this. The above solution appears to be working despite the
sigma
insidesampler$state
, but I just want to confirm. If this actually is not working, I will need to find some other way around it.Reproducible example:
Thanks!
The text was updated successfully, but these errors were encountered: