y <- c(104,24,65,76,146,30,50,9,166) # Table 2 (Lang, 2004)
y <- matrix(y,9,1)
# population matrix: 3 strata with 3 observations each
Z <- kronecker(diag(3),matrix(1,3,1))
# the 3rd stratum sample size is fixed
ZF <- kronecker(diag(3),matrix(1,3,1))[,3]
# Let P_ij be the expected number of cross-citations, P_ij=P(A=i,B=j),
# where A = Citing journal and B = Cited journal.
# The Gini concentrations of citations for each of the journals are:
# G_i = sum_j=1_3 (P_ij/P_i+)^2 for i=1,2,3.
Gini.fct <- function(m) {
p <- diag(c(1/(ZG1 <- sum(diag(matrix(c(p[1]/(p[1]+p[2]+p[3]),0,0,
0,p[2]/(p[1]+p[2]+p[3]),0,
0,0,p[3]/(p[1]+p[2]+p[3])),3,3,byrow=TRUE)*
matrix(c(p[1]/(p[1]+p[2]+p[3]),0,0,
0,p[2]/(p[1]+p[2]+p[3]),0,
0,0,p[3]/(p[1]+p[2]+p[3])),3,3,byrow=TRUE)))
G2 <- sum(diag(matrix(c(p[4]/(p[4]+p[5]+p[6]),0,0,
0,p[5]/(p[4]+p[5]+p[6]),0,
0,0,p[6]/(p[4]+p[5]+p[6])),3,3,byrow=TRUE)*
matrix(c(p[4]/(p[4]+p[5]+p[6]),0,0,
0,p[5]/(p[4]+p[5]+p[6]),0,
0,0,p[6]/(p[4]+p[5]+p[6])),3,3,byrow=TRUE)))
G3 <- sum(diag(matrix(c(p[7]/(p[7]+p[8]+p[9]),0,0,
0,p[8]/(p[7]+p[8]+p[9]),0,
0,0,p[9]/(p[7]+p[8]+p[9])),3,3,byrow=TRUE)*
matrix(c(p[7]/(p[7]+p[8]+p[9]),0,0,
0,p[8]/(p[7]+p[8]+p[9]),0,
0,0,p[9]/(p[7]+p[8]+p[9])),3,3,byrow=TRUE)))
c(G1,G2,G3)}
# h_1 = c(G1,G2,G3)-c(0.410,0.455,0.684) = 0
# HYPOTHESIS: no change in Gini concentrations
# from the 1987-1989 observed values
h.fct <- function(m) {G<-Gini.fct(m)
c(G[1],G[2],G[3])-c(0.410,0.455,0.684)}
mod_eq <- mphineq.fit(y,Z,ZF,h.fct=h.fct)
print(mod_eq)
# Example of MPH model subject to inequality constraints
# d_1 = c(G1,G2,G3)-c(0.410,0.455,0.684) >= 0
# HYPOTHESIS: increase in Gini concentrations
# from the 1987-1989 observed values
d.fct <- function(m) {G<-Gini.fct(m)
c(G[1],G[2],G[3])-c(0.410,0.455,0.684)}
mod_ineq <- mphineq.fit(y,Z,ZF,d.fct=d.fct)
print(mod_ineq)
# HYPOTHESES TESTED:
# NB: testA --> H0=(mod_eq) vs H1=(mod_ineq model)
# testB --> H0=(mod_ineq model) vs H1=(sat_mod model)
# sat_mod --> saturated model (Gsq=0)
m <- mod_ineq$m
chibar(m,Z,ZF,d.fct=d.fct,test0=mod_eq$Gsq-mod_ineq$Gsq,
test1=mod_ineq$Gsq,repli=6000,lev=c(3,3))
Run the code above in your browser using DataLab