# NOT RUN {
###########################
# Probit Regression Model #
###########################
# Simulate data
set.seed(1)
n <- 100
x <- runif(n)
y <- log(1 + 10*x) + rnorm(n, sd = 1)
# Number of cosine basis functions
nbasis <- 50
# Fit the model with default priors and mcmc parameters
fout <- gbsar(y = y, x = x, family = binomial(link = "probit"),
nbasis = nbasis, shape = 'IncreasingConcave')
# Summary
print(fout)
# fitted values
fit=fitted(fout)
# Plot
plot(fit,'topleft',ask=TRUE)
######################################
# Logistic Additive Regression Model #
######################################
# Wage-Union data
data(wage.union); attach(wage.union)
race[race==1 | race==2]=0
race[race==3]=1
y <- union
w <- cbind(race,sex,south)
x <- cbind(wage,education,age)
# mcmc parameters
mcmc <- list(blow0 = 10000,
blow = 10000,
nskip = 10,
smcmc = 1000,
ndisp = 1000,
maxmodmet = 10)
foutGBSAR <- gbsar(y = y, w = w, x = x, family = 'binomial',
link = 'logit', nbasis = 50, mcmc = mcmc,
shape = c('Free','Decreasing','Increasing'))
# fitted values
fitGBSAR <- fitted(foutGBSAR)
# Plot
plot(fitGBSAR, ask = TRUE)
# }
Run the code above in your browser using DataLab