This worked example, hoping to be helpful, has been requested after a (my)
further enquiry about array manipulation.

I was looking for a command that is equivalent to repmat() in matlab and
that could also be applied to array.

(for Matlab users)
The Matlal code was the following:


1)temp_u=zeros(d,c,T);              <-creation of an array of dimensions d
x c x T full of zeroes
2)temp_u(1,:,:)=m_u;                <-filling the first row of each
'stratum' with the rows of
                                    the matrix 'm_u'
3)temp_u=repmat(temp_u(1,:,:),d,1); <-filling the remaining rows (full of
zeroes) of 'temp_u' with
                                    copies of the corrensponding 1st row

(what's happening if you are not a Matlab users)
(numerical example d=2,c=4,T=4)
1)temp_u=zeros(d,c,T)
 temp_u(:,:,1) =

     0     0     0     0
     0     0     0     0


temp_u(:,:,2) =

     0     0     0     0
     0     0     0     0


temp_u(:,:,3) =

     0     0     0     0
     0     0     0     0


temp_u(:,:,4) =

     0     0     0     0
     0     0     0     0

2)temp_u(1,:,:)=m_u
temp_u(:,:,1) =

    0.9604    0.0156    0.0230    0.0009
         0         0         0         0


temp_u(:,:,2) =

    0.3906    0.2948    0.0981    0.2165
         0         0         0         0


temp_u(:,:,3) =

    0.5390    0.2482    0.1140    0.0988
         0         0         0         0


temp_u(:,:,4) =

    0.4546    0.2641    0.0794    0.2019
         0         0         0         0

3)temp_u=repmat(temp_u(1,:,:),d,1)

temp_u(:,:,1) =

    0.9604    0.0156    0.0230    0.0009
    0.9604    0.0156    0.0230    0.0009


temp_u(:,:,2) =

    0.3906    0.2948    0.0981    0.2165
    0.3906    0.2948    0.0981    0.2165


temp_u(:,:,3) =

    0.5390    0.2482    0.1140    0.0988
    0.5390    0.2482    0.1140    0.0988


temp_u(:,:,4) =

    0.4546    0.2641    0.0794    0.2019
    0.4546    0.2641    0.0794    0.2019


Now, in order to reply this exercise in R I used the following code:

temp_u=array(0,dim=c(1,c,T))
temp_u[1,,]=m_u
temp_u=kronecker(temp_u,matrix(rep(1,d),nr=d))


A special thank to David Winsemius,William Dunlap and Patrick Burns.
I hope I have been helpful.





-------------------------------------------------------------------

Simone Salvadei

Faculty of Economics
Department of Financial and Economic Studies and Quantitative Methods
University of Rome Tor Vergata
e-mail: simone.salva...@uniroma2.it <federico.belo...@uniroma2.it>
url: http://www.economia.uniroma2.it/phd/econometricsempiricaleconomics/
<http://www.econometrics.it/>
-------------------------------------------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to