Mcustomize: Customized Model

Description Usage Arguments Details Examples

Description

This function is a private function that returns the basic statistics of a customized model. It is only used in conjunction with boundary or independent sampling method.

Usage

1
Mcustomize(y, fit, cov)

Arguments

y

response variables.

fit

a list of maximum likelihood estiamtors for the parameters, design(X) matrix and expression of likelihood function.

cov

a covariance matrix of the parameters.

Details

fit must be a list. It can be done by list function. The names must exactly be “MLE”, “X” and “lik”. lik in fit must be the expression class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
##########################################################
################-----BoundarySampling-----################
##########################################################
library(MASS)
data(data.poisson)
Device <- data.poisson$Device
DataPlan <- data.poisson$DataPlan
y <- data.poisson$y
fit.glm <- glm(y ~ (Device+DataPlan), family=poisson)
X <- model.matrix(fit.glm)
MLE <- fit.glm$coef
cov <- vcov(fit.glm)
lik <- expression(MLE %*% t(X) %*% y - sum(exp(MLE %*% t(X)))-sum(lgamma(y+1)))
fit <- list(MLE=MLE,X=X,lik=lik)
target <- "level"
targetvalue <- c(0.5,0.9)
########################################################
out_b <- boundary("Mcustomize",y,fit,target,targetvalue,cov=cov)
########################################################
out_b$diag    # out_b$diag is equivalent to out_b$diagnosis
out_b$bound[1:20,]    # out_b$bound is equivalent to out_b$boundary.sample
out_b$num    # out_b$num is equivalent to out_b$numWald.interval
out_b$sim    # out_b$sim is equivalent to out_b$simWald.interval
out_b$convnum   # out_b$convnum is equivalent to out_b$convnumWald
out_b$convsim   # out_b$convsim is equivalent to out_b$convsimWald
########################################################
par(mfrow=c(2,2))
plot(out_b$bound[,6],out_b$bound[,7],xlab=expression(beta[Def]),ylab=expression(beta[Vic]),cex=0.5)
points(out_b$MLE[2],out_b$MLE[3],pch=16,col="red",cex=1.5)
plot(out_b$bound[,7],out_b$bound[,8],xlab=expression(beta[Vic]),ylab=expression(beta[Pen]),cex=0.5)
points(out_b$MLE[3],out_b$MLE[4],pch=16,col="red",cex=1.5)
plot(out_b$bound[,6],out_b$bound[,8],xlab=expression(beta[Def]),ylab=expression(beta[Def*Vic]),cex=0.5)
points(out_b$MLE[2],out_b$MLE[4],pch=16,col="red",cex=1.5)
plot(out_b$bound[,5],out_b$bound[,8],xlab=expression(beta[Def*Pen]),ylab=expression(beta[Vic*Pen]),cex=0.5)
points(out_b$MLE[1],out_b$MLE[4],pch=16,col="red",cex=1.5)

## End(Not run)

ppham27/setsim documentation built on May 25, 2019, 11:25 a.m.