set.seed(2020)
n=200 # length of the sample
nv<-3 # number of explanatory variables
p<-nv+1 # nv + intercept
m<-4 # dimension of Y
q0=p*m
X<-array(0,c(q0,m,n))
for(i in 1:n) {
aux=rep(1,p)
aux[2:p]<-rMN(1,mu=rnorm(nv),Sigma=diag(nv))
mi=matrix(0,q0,m)
for (j in 1:m) mi[((j-1)*p+1):(j*p),j]=aux
X[,,i]<-mi
} #Simulated matrix covariates
betas<-matrix(rnorm(q0),ncol=1) ## True betas
Sigmas <- clusterGeneration::genPositiveDefMat(m,rangeVar=c(1,3),
lambdaLow=1, ratioLambda=3)$Sigma ##True Sigma
lambda<-rnorm(m) ##True lambda
y=matrix(0,n,m)
for(i in 1:n) {
mui<-t(X[,,i])%*%betas
y[i,]<-rMSN(n=1,c(mui),Sigmas,lambda)}
# \donttest{
fit.MSN=estimate.MSN(y,X) ##Estimate parameters for MSN model
fit.MSN ## Output of estimate.MSN
summary(fit.MSN)
fit.MSN$se ##Estimated standard errors by the estimate.MSN function
##Estimated standard errors by minus the square root of
##the diagonal from the observed FI matrix of the MSN model
sqrt(diag(solve(-FI.MSN(fit.MSN$coefficients, y, X))))# }
Run the code above in your browser using DataLab