TABLE OF CONTENTS


fortran/fsmud2 [ Methods ]

NAME

  fsmud2 --- compute squared means and cross-terms

FUNCTION

Compute the sums of mu_rijks * delta_rijks and mu_rijks^2 for every (i,j). See also the R function Smud2.

SYNOPSIS

347       subroutine fsmud2(betahat,index,delta,Z,alphars,as,
348      $ d,ncovs,nr,ns,Smud,Smu2)

INPUTS

    betahat    regression parameters (length p)
    index      d x 6 matrix of indices i,j,k,r,smin,smax 
    delta      length d vector of event indicators (double)
    Z          d x ncovs matrix of covariates (double row vector)
    alphars    nr x ns matrix of baseline hazards (double) 
    d          number of rows of Z
    ncovs      number of covariates
    nr         number of strata
    ns         number of breakpoints
    m          number of clusters
    maxj       largest cluster size

OUTPUTS

    Smud       m x maxj matrix containg sum(mu*delta) for all (i,j)
    Smu2       m x maxj matrix containg sum(mu^2) for all (i,j)

SOURCE

350       integer d,ncovs,nr,ns,nk
351       integer index(d,6)
352       double precision betahat(ncovs)
353       double precision delta(d)
354       double precision Z(d,ncovs)
355       double precision alphars(nr,ns)
356       double precision as(nr,ns)
357       double precision lp, deltat,deltatt,w,mu,power
358       double precision Smud,Smu2
359       integer ind,i,j,k,r,s,smax,smin,maxs
360       
361       parameter(icol=1, jcol=2, kcol=3, ircol=4, ismincol=5, ismaxcol=6)
362 
363       maxs=(ns-1)*95/100
364       do 100 ind=1,d
365 !       call intpr("ind",-1,ind,1)       
366        i=index(ind,icol)
367         j=index(ind,jcol)
368         k=index(ind,kcol)
369         r=index(ind,ircol)
370         smin=index(ind,ismincol)
371         smax=index(ind,ismaxcol)
372         deltat=delta(ind)
373         lp=ddot(ncovs,Z(ind,1),d,betahat,1)
374 !       ignore the last 5% of intervals
375 !        if(smax.GT.maxs) then
376 !            smax=maxs
377 !        endif  
378         do 110 s=smin,smax
379            mu=exp(lp)*alphars(r,s)*(as(r,s+1)-as(r,s))
380            mu=(1.d0-exp(-mu))
381            if(s.EQ.smax) then
382                 deltatt=deltat
383            else
384                 deltatt=0.d0
385            endif
386            Smud=Smud+(mu-deltatt)**2
387            Smu2=Smu2+mu**2
388  110    continue   
389  100  continue
390       end