[R-sig-Epi] APC models with covariates

BXC (Bendix Carstensen) bxc at steno.dk
Thu Jul 24 19:25:47 CEST 2014


Unfortunately this is not implemented in the apc.fit function.

The whole machinery relies on a projection of the columns of model matrix:

Suppose you have natural spline effects for A, P and C=P-A, all of length N, say, and you want to center around the reference cohort c0:

mA <- Ns(  A,knots=a.kn)
mP <- Ns(P  ,knots=p.kn)
mC <- Ns(P-A,knots=c.kn)
mr <- Ns(rep(c0,N),knots=c.kn)

The you would fit

Mod <-
glm( D ~ ma + detrend( mP, P ),
            + detrend( mC-mr, P-A )
            + I(P-A-c0)
            + <covariates>,
     offset=log(Y), family=Poisson )

the "detrend" function (also from the Epi package) projects the columns of say mP on the orthogonal compliment to (1,P). You can supply you own inner product for the projection if you wish.

The effects of the two de-trended terms will be 0 on average with 0 average slope. But the detrend() is data dependent, so extracting the effects must be done using the original matrix:

P.pt <- sort(unique(P))
cP <- detrend(mP,P)[match(P.pt,P),]
P.eff <- ci.exp( Mod, subset="mP", ctr.mat=cP )
matplot( P.pt, P.eff, <etc> )

A bit of wrangling...
I would not know how to implement this fort of thing, but if someone writes the help-page for what you need, I'd happily write the code to do it.
But it must a specification of the function call AND of the output structures.

All the best,
Bendix

> -----Original Message-----
> From: r-sig-epi-bounces at r-project.org [mailto:r-sig-epi-bounces at r-
> project.org] On Behalf Of Gustaf Rydevik
> Sent: 24. juli 2014 17:29
> To: r-sig-epi at r-project.org
> Subject: [R-sig-Epi] APC models with covariates
> 
> Dear all,
> 
> Is it possible to use the Epi package to fit APC models with additional
> covariates? I've used other approaches, but really enjoy the convenience
> functions for visualisation in Epi, and so it would be great if it was
> possible to stay in the same package.
> 
> Best regards,
> Gustaf
> 
> --
> Gustaf Rydevik, M.Sci.
> tel: +44(0)74 253 760 42
> address:25/6 Brunswick Road, EH7 5GY Edinburgh skype:gustaf_rydevik
> 
> _______________________________________________
> R-sig-Epi at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-epi



More information about the R-sig-Epi mailing list