ps(runif(10))
ps(runif(10), ps.intervals = 5)
## Not run:
# data("TravelMode", package = "AER") # Need to install "AER" first
# air.df <- subset(TravelMode, mode == "air") # Form 4 smaller data frames
# bus.df <- subset(TravelMode, mode == "bus")
# trn.df <- subset(TravelMode, mode == "train")
# car.df <- subset(TravelMode, mode == "car")
# TravelMode2 <- data.frame(income = air.df$income,
# wait.air = air.df$wait - car.df$wait,
# wait.trn = trn.df$wait - car.df$wait,
# wait.bus = bus.df$wait - car.df$wait,
# gcost.air = air.df$gcost - car.df$gcost,
# gcost.trn = trn.df$gcost - car.df$gcost,
# gcost.bus = bus.df$gcost - car.df$gcost,
# wait = air.df$wait) # Value is unimportant
# TravelMode2$mode <- subset(TravelMode, choice == "yes")$mode # The response
# TravelMode2 <- transform(TravelMode2, incom.air = income, incom.trn = 0,
# incom.bus = 0)
# set.seed(1)
# TravelMode2 <- transform(TravelMode2,
# junkx2 = runif(nrow(TravelMode2)))
#
# tfit2 <-
# vgam(mode ~ ps(gcost.air, gcost.trn, gcost.bus) + ns(junkx2, 4) +
# ps(incom.air, incom.trn, incom.bus) + wait ,
# crit = "coef",
# multinomial(parallel = FALSE ~ 1), data = TravelMode2,
# xij = list(ps(gcost.air, gcost.trn, gcost.bus) ~
# ps(gcost.air, gcost.trn, gcost.bus) +
# ps(gcost.trn, gcost.bus, gcost.air) +
# ps(gcost.bus, gcost.air, gcost.trn),
# ps(incom.air, incom.trn, incom.bus) ~
# ps(incom.air, incom.trn, incom.bus) +
# ps(incom.trn, incom.bus, incom.air) +
# ps(incom.bus, incom.air, incom.trn),
# wait ~ wait.air + wait.trn + wait.bus),
# form2 = ~ ps(gcost.air, gcost.trn, gcost.bus) +
# ps(gcost.trn, gcost.bus, gcost.air) +
# ps(gcost.bus, gcost.air, gcost.trn) +
# wait +
# ps(incom.air, incom.trn, incom.bus) +
# ps(incom.trn, incom.bus, incom.air) +
# ps(incom.bus, incom.air, incom.trn) +
# junkx2 + ns(junkx2, 4) +
# incom.air + incom.trn + incom.bus +
# gcost.air + gcost.trn + gcost.bus +
# wait.air + wait.trn + wait.bus)
# par(mfrow = c(2, 2))
# plot(tfit2, se = TRUE, lcol = "orange", scol = "blue", ylim = c(-4, 4))
# ## End(Not run)
Run the code above in your browser using DataLab