SUBROUTINE NRMK(NK,NT,X,LDX,Y,H,HPRI,LDHPRI,HBPRI,BETA) C*********************************************************************** C In the calling routine a call to INIT must be made prior to calling * C this routine for the first time. * C*********************************************************************** C This routine simulates one draw from the coefficient posterior distribution C arising from a regression model with a normal prior for the coefficients. C Inputs: C NK Dimension of coefficient vector (= number of regressors) C NT Number of observations C X NTxNK matrix of regressors (DESTROYED) C LDX Leading dimension of X C Y NTx1 vector of dependent variables C H Disturbance precision C HPRI NKxNK prior precision matrix (symmetric) C LDHPRI Leading dimension of HPRI C HBPRI [HPRI]x[Coefficient prior mean vector] C Output: C BETA NKx1 Draw from posterior distribution C PDFLG Log posterior p.d.f. at the drawn value. C ... When finished, the upper triangle of the posterior precision is in A1, C the posterior mean is in V2, C and the Choleski decomposition of the posterior variance is in A2. IMPLICIT REAL*8 (A-H,O-Z) PARAMETER(LD=100) C COMMON/CONST/DLOG2,DLGPI,HLG2PI,PI,PII COMMON/SCRA/A1(LD,LD),A2(LD,LD),V1(LD),V2(LD) DIMENSION X(LDX,NK),Y(NT),HPRI(LDHPRI,NK),HBPRI(NK),BETA(NK) C Form upper triangle of posterior precision in A1 and RHS vector in V1. DO 10 I=1,NK V1(I)=HBPRI(I)+H*DDOT(NT,X(1,I),1,Y,1) DO 10 J=I,NK 10 A1(I,J)=HPRI(I,J)+H*DDOT(NT,X(1,I),1,X(1,J),1) C Form upper triangular R: R'R = Precision in A2, and invert. CALL DLFTDS(NK,A1,LD,A2,LD) CALL DLINRT(NK,A2,LD,2,A2,LD) C Form mean vector in V2. DO 30 I=1,NK AA=0.0D0 DO 20 J=I,NK DO 20 L=1,J 20 AA=AA+A2(I,J)*A2(L,J)*V1(L) 30 V2(I)=AA C Form basic shocks in V1. CALL DRNNOA(NK,V1) C PDFLG=-NK*HLG2PI-.5D0*DNRM2(NK,V2,1)**2 C Form final vector as sum of mean and deviation. DO 50 I=1,NK C PDFLG=PDFLG-DLOG(A2(I,I)) AA=0.0D0 DO 40 J=I,NK 40 AA=AA+A2(I,J)*V1(J) 50 BETA(I)=V2(I)+AA RETURN END