

   PPrroodduuccee MMaarrggiinnaall TTiimmee PPrrooffiilleess ffoorr PPlloottttiinngg

        plot(profile(z, times=NULL, mu=NULL, ccov, plotse=F), nind=1,
             intensity=F, add=FALSE, ylim=c(min(z$pred),max(z$pred)),
             lty=NULL, ylab="Fitted value", xlab="Time", ...)

   AArrgguummeennttss::

          z: An object of class recursive, from `carma',
             `elliptic', `gar', `kalcount', `kalseries',
             `kalsurv', or `nbkal'.

      times: Vector of time points at which profiles are to be
             plotted.

         mu: The location regression as a function of the
             parameters and the times, for the desired covari-
             ate values.

       ccov: Covariate values for the profiles (`carma' only).

     plotse: Plot standard errors (`carma' only).

       nind: Observation number(s) of individual(s) to be plot-
             ted. (Not used if `mu' is supplied.)

   intensity: If z has class, `kalsurv', and this is TRUE, the
             intensity is plotted instead of the time between
             events.

        add: If TRUE, add contour to previous plot instead of
             creating a new one.

     others: Plotting control options.

   VVaalluuee::

        `profile' is used for plotting marginal profiles over
        time for models obtained from Kalman fitting, for given
        fixed values of covariates. See `iprofile' for plotting
        individual profiles.

   AAuutthhoorr((ss))::

        J.K. Lindsey

   SSeeee AAllssoo::

        `carma', `elliptic', `gar', `kalcount', `kalseries',
        `kalsurv', `nbkal' `iprofile', `plot.residuals'.

   EExxaammpplleess::

        library(repeated)
        times <- rep(1:20,2)
        dose <- c(rep(2,20),rep(5,20))
        mu <- function(p) exp(p[1]-p[3])*(dose/(exp(p[1])-exp(p[2]))*
             (exp(-exp(p[2])*times)-exp(-exp(p[1])*times)))
        shape <- function(p) exp(p[1]-p[2])*times*dose*exp(-exp(p[1])*times)
        conc <- matrix(rgamma(40,1,mu(log(c(1,0.3,0.2)))),ncol=20,byrow=T)
        conc[,2:20] <- conc[,2:20]+0.5*(conc[,1:19]-matrix(mu(log(c(1,0.3,0.2))),
             ncol=20,byrow=T)[,1:19])
        conc <- ifelse(conc>0,conc,0.01)
        z <- gar(conc, dist="gamma", times=1:20, mu=mu, shape=shape,
             preg=log(c(1,0.4,0.1)), pdepend=0.5, pshape=log(c(1,0.2)))
        # plot individual profiles and the average profile
        plot(iprofile(z), nind=1:2, pch=c(1,20), lty=3:4)
        plot(profile(z), nind=1:2, lty=1:2, add=T)

