Description Usage Arguments Value Examples
Compute the Gauss Markov coefficients for Multivariate Blue
1 | CoeffGM.array(Sigma, X, Xplus = NULL)
|
Sigma |
a (p_1x...x p_P) x (p_1x...x p_P) array |
X |
an (p_1x...x p_P) x (n_1 x ...x n_N) array |
Xplus: |
a general inverse of X (if NULL, it will be computed by the program by Xplus<-MASS::ginv(X2) ) |
the coefficients matrix W such that $WY$ is the best unbiased linear estimator of β where E[Y]=Xβ
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 | beta= matrix(rchisq(12,1),4,3)
dimnames(beta)<-list(m=paste(200501:200504),y=c("e","u","n"))
X<-CPS_X_array(months=list(m=paste(200501:200504)),
vars=list(y=c("e","u","n")),
rgs=list(hrmis=paste(1:8)))
Xplus<-CPS_Xplus_array(months=list(m=paste(200501:200504)),
vars=list(y=c("e","u","n")),
rgs=list(hrmis=paste(1:8)),1/2)
EY<-arrayproduct::"%.%"(
X,beta,
I_A=list(c=integer(0),n=c("m","y","hrmis"),p=c("m2","y2")),
I_B=list(c=integer(0),p=c("m","y"),q=integer(0)))
set.seed(1)
Sigma=rWishart(1,length(EY),diag(length(EY)))
Y<-array(mvrnorm(n = 100,mu = c(EY),Sigma = Sigma[,,1]),c(100,dim(EY)))
dimnames(Y)<-c(list(rep=1:100),dimnames(EY))
Sigma.A<-array(Sigma,c(dim(EY),dim(EY)))
dimnames(Sigma.A)<-rep(dimnames(EY),2);
names(dimnames(Sigma.A))[4:6]<-paste0(names(dimnames(Sigma.A))[4:6],"2")
W<-CoeffGM.array(Sigma.A,X,Xplus)
WY<-arrayproduct::"%.%"(
W,Y,
I_A=list(c=integer(0),n=c("y2","m2"),p=c("m","y","hrmis")),
I_B=list(c=integer(0),p=c("m","y","hrmis"),q=c("rep")))
DY<-arrayproduct::"%.%"(
Xplus,Y,
I_A=list(c=integer(0),n=c("y2","m2"),p=c("m","y","hrmis")),
I_B=list(c=integer(0),p=c("m","y","hrmis"),q=c("rep")))
plot(c(beta),c(apply(DY,1:2,var)),col="red")
plot(c(beta),c(apply(WY,1:2,var)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.