demo/xrc2iqc.R

## ipeglim/demo/xrc2iqc.R
##
## Quality control on the estimates produced from 'LA' by 'MH'.

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

source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/cpef2reg.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/cpef.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/model.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/iprior.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/update_imprecise.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/summary_imprecise.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/print_imprecise.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/plot_imprecise.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/pbox_imprecise.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/qc.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/rvg4yx.R")
source("~/Documents/PhD/ipeglim/pkg/ipeglim/R/extract_MHchain.R")


# seed trial 1-20
set.seed(4) # error found

## case 1. 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

SILENT <- FALSE
ZTRUNC <- TRUE

# random variates generation
tmp <- rvg4yx(N=3e2, cf0=bcfs1[1], pars=bcfs1[2], ztrunc=ZTRUNC, 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=ZTRUNC, dist="poisson")
cmfit <- iprior(obj=m2fit, circle=list(x0=0, y0=0, r=1, len=10))

ola <- update(obj=cmfit, method="LA", B=Bmat, xi=xi1, silent=SILENT)
sla <- summary(ola, HT.est=TRUE, silent=SILENT)
# plot(sla)
print(sla)

ola.qc <- qcLA(x=ola, verbose=TRUE)
sla.qc <- summary(ola.qc, silent=FALSE)
print(sla.qc)

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.