Dear folks,

I have been struggling to create what I fondly imagined would be a
straightforward adaptation of the package's example to my own dataset, which
looks at incidence of depression following the birth of initial and up to 3
subsequent children (4 children in all, with all subjects having a first
child).  I've regarded these as equivalent to tooth eruption and subsequent
caries in the tandmobile example the package gives.  As near as I can make
out, the sole difference (mutatis mutandis) is that my data has precise
dates of birth of children and onset of depression, rather than the data
being interval-censored as in the tandmobile dataset.

I've set up survreg3 as follows

sample.childmdd <- bayessurvreg3(
        formula=Surv(childtime+.01,childevent)~nchild+cluster(id),
        random=~1,

formula2=Surv(mddtime+.01,mddevent)~nchild+blustatus+well.before+earlydep+cluster(id),
        random2=~1,
        onlyX=FALSE,
        dir="chaindir.childmdd", nsimul=nsimul.childmdd,
        prior=prior.gspl.child, prior2=prior.gspl.mdd,
        prior.beta=prior.beta.child, prior.beta2=prior.beta.mdd,
        prior.b=prior.b.child, prior.b2=prior.b.mdd,
        init=init.child, init2=init.mdd,
        store=list(a=TRUE, a2=TRUE, a.b=TRUE, a.b2=TRUE),
        data=dataset3long)

This seems to run quite happily (the +.01 is needed to avoid zeros)

However, the code to obtain the predictions

pred.mdd <- list()
for (k in 1:4){    ## loop over children
    cat("Performing CHILD ", child[k], "\n", sep="")
    pred.mdd[[k]] <- list()

    for (ii in 1:length(start[[k]])){    ## loop over sets of
covariates
        cat("Performing the covariate set number ", ii, "\n", sep="")
        pdata.now <- pred.data[start[[k]][ii]:end[[k]][ii], ]
        nr <- nrow(pdata.now)
        pred.mdd[[k]][[ii]] <-
                predictive2(Surv(rep(1, nr), rep(1, nr)) ~
Child+blustatus+well.before+earlydep+cluster(Idnr), random=~1,
                        grid=pred.grid, data=pdata.now,
                        Gspline=list(dim=1, K=15), quantile=quants,
                        skip=skip, by=1, nwrite=nwrite, only.aver=FALSE,
                        predict=list(density=TRUE, Surv=TRUE, hazard=TRUE),
                        dir="chaindir.childmdd", extens="_2",
extens.random="_b2", version=3)
    }
}

which seems to correspond, gives the error message

Error in predictive2(Surv(rep(1, nr), rep(1, nr)) ~ Child + blustatus +  :
                Your formula indicates that there are 6 regression
parameters in the model however the file beta.sim contains 7 columns

I can see that an additional chain might be expected, related to the first
(child only) survival equation in survreg3, but predictive2 doesn't require
an additional survival equation, and I'm completely unable to spot the
difference between my version and the working example.

If someone could rescue me I'd be very happy.

Best wishes and many thanks in advance.

David Foreman
Consultant and Visiting Professor in Child and Adolescent Psychiatry

        [[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