demo/xreg-ptt.R

## ipeglim/demo/xreg-ptt.R
##
## Prototype of imprecise inference framework in the context of regression model
## 

library(ipeglim)
rm(list=ls())

## log(E(y)) ~ b0 + b1*x1
## default structure of X
xm <- c(0)
xsd <- c(1)

## default structure of B
bm <- c(0,0)
bsd <- c(1,1)
br <- diag(2)
br[1,2] <- br[2,1] <- r1 <- 0
Bmat <- t(diag(bsd))%*%br%*%diag(bsd)
Bmat <- Bmat*1e-2

# parameter specification
bcfs1 <- c(0.5, 0.5)      # 1 quadrant
bcfs2 <- c(-0.5, 0.5)     # 2 quadrant
bcfs3 <- c(-0.5, -0.5)    # 3 quadrant
bcfs4 <- c(0.5, -0.5)     # 4 quadrant

# random variates generation
tmp <- rvg4yx(N=1e2, cf0=bcfs4[1], pars=bcfs4[2], ztrunc=TRUE, xreg=TRUE, kind="mvnorm", mean=xm, sd=xsd, center.X=TRUE)
dat <- tmp$yX
table(dat$y)
xi1 <- c(1,unlist(dat[1,-1]))

m2fit <- model(formula=y~x1, data=dat, ztrunc=TRUE, dist="poisson")
cmfit <- iprior(obj=m2fit, circle=list(x0=0, y0=0, r=1, len=20))

ola <- summary(update(obj=cmfit, method="LA", B=Bmat, xi=xi1))

X11()
plot(ola, # for m0xtms
  main="Shrinkage of Imprecise Prior", 
  sub=list(expression(-1<beta[1]~","~beta[2]<1), cex=1.25),
  xlab=expression(beta[1]),
  ylab=expression(beta[2]))

Try the ipeglim package in your browser

Any scripts or data that you put into this service are public.

ipeglim documentation built on May 2, 2019, 4:31 p.m.