# [R] RE

nmi13 nmi13 at ext.canterbury.ac.nz
Wed Aug 2 08:43:01 CEST 2006

```Hi any,

Can some please detail me the createX command in bayesm package?

To make things easy for you to help me, let me put forward my problem

Suppose I have 3 covariates (say X matrix) and my Y has 3 categories say
(1,2,3). Now from the CreateX I understand that the data matrix say 'Xa' must
be of dimension n* (naxp), where 'na' is the number of variables and 'p' is
the number of categories that Y has and 'n' is the number of observations. Now
the Xa matrix will have 9 columns if I give na=3 and p=3, and 6 columns if I
give na =2 and p=3. I understand this part. In order to create Xa with a
dimension of n*9 or n*6 we have to create Xa as cbind(Xa,-Xa) and now when I
get the design matrix say XD then I have 5 or 4 variables, which will be same
as the beta matrix that  I intend to get, I get this, but my question is when
I get the XD matrix as explained below the covariate matrix (X) which
initially had  3 columns now changed to a  9 rows and one column and two
additional variables X4 and X5 as explained belwo which I guess for the beta,
what is the role of these variables in the 'rmnlIndepMetrop'analysis.
example
x1<-runif(3,-1,1)
x2<-runif(3,0,1)
x3<-runif(3,10,50)
X<-cbind(x1,x2,x3)
X
x1        x2       x3
[1,] -0.9701396 0.4084203 41.31097
[2,]  0.3844539 0.4791997 36.85861
[3,]  0.2732056 0.5433642 13.14610

Xa<-cbind(X,-X)
XD<-createX(p=3,na=2,nd=NULL,Xa=Xa,Xd=NULL)
XD
[,1] [,2]       [,3]        [,4]
[1,]    1    0 -0.9701396   0.9701396
[2,]    0    1  0.4084203  -0.4084203
[3,]    0    0 41.3109655 -41.3109655
[4,]    1    0  0.3844539  -0.3844539
[5,]    0    1  0.4791997  -0.4791997
[6,]    0    0 36.8586070 -36.8586070
[7,]    1    0  0.2732056  -0.2732056
[8,]    0    1  0.5433642  -0.5433642
[9,]    0    0 13.1461040 -13.1461040
Xa<-cbind(X,-X,X^2) (is this a correct way)
XD<-createX(p=3,na=3,nd=NULL,Xa=Xa,Xd=NULL)
XD
[,1] [,2]       [,3]        [,4]         [,5]
[1,]    1    0 -0.9701396   0.9701396    0.9411709
[2,]    0    1  0.4084203  -0.4084203    0.1668071
[3,]    0    0 41.3109655 -41.3109655 1706.5958746
[4,]    1    0  0.3844539  -0.3844539    0.1478048
[5,]    0    1  0.4791997  -0.4791997    0.2296324
[6,]    0    0 36.8586070 -36.8586070 1358.5569127
[7,]    1    0  0.2732056  -0.2732056    0.0746413
[8,]    0    1  0.5433642  -0.5433642    0.2952447
[9,]    0    0 13.1461040 -13.1461040  172.8200512

In the above example my X matrix as you can see has 3 columns with 3
observations, which now in XD are 9 observations in 3rd column, I don't know
how col 4 and col 5 of XD play a role in computing the llmnl and
rmnlIndepMetrop.

Thanks for all your help and time.

Regards,
Murthy.

```