To load the Bayz R-models, use one of the following once in every new R session to load the R-models, and to set BAYZHOME so that R can find bayz:
source("http://www.bayz.biz/Rbayz.R") # to load from the bayz website directly source("~/bin/Rbayz.R") # if you have downloaded Rbayz.R, see Download page BAYZHOME <- "~/bin/" # set location where R can find bayz
Adapt the locations in the last two steps dependent on the bayz installation in your computer.
Running one of the Bayz R-models typically uses an R-statement like:
resxxx <- bayz.xxx(data=d, geno=g, covar=c, resp=y, fixmod=f, ranmod=r, ..., chain=c(t,b,s))The available models and explanation of their arguments is given in detail on the page Models Overview. For a particular model, not all arguments shown above may be used, or additional argument may apply. The bayz models return a table with all parameter estimates for the particular analysis. Usually, you would like to store that result for further use, as shown above in the resxxx object.
The data sets lay-out for use of Rbayz models is more restrictive than for use of bayz outside R. See the page on Data sets on how to prepare the data sets for Rbayz.
The output from Rbayz models is a table with parameter estimates in the form of posterior means and posterior standard deviations for all model parameters (and for residuals). You can simply look at this table, for instance:
> mmres <- bayz.mm(data=phen, resp="BW", fixmod="fac.sex+fac.batch", chain=c(1000,100,20)) > tail(mmres) parameter label post.mean post.stdev 610 resid.BW row610 -0.607020 0.368190 611 resid.BW row611 7.702980 0.368190 612 resid.BW row612 2.392980 0.368190 613 var.resid.BW var.resid.BW 15.345800 0.865291 614 mean.BW mean.BW 41.030000 0.252699 615 fac.sex.BW 1 0.000000 0.000000 616 fac.sex.BW 2 -7.786510 0.311478 617 fac.batch.BW 1 0.000000 0.000000 618 fac.batch.BW 2 0.973247 0.341200 619 fac.batch.BW 3 3.017000 0.321880However, the table is usually quite big. A convenient function to summarise the output is bayz.summ(); this shows the estimates for parameters with up to 20 levels and typically pulls out variances, means, low-level factors and single regressions. Bayz.summ also lists the number of estimates available for all parameters not shown:
> bayz.summ(mmres) parameter label post.mean post.stdev 613 var.resid.BW var.resid.BW 15.345800 0.865291 614 mean.BW mean.BW 41.030000 0.252699 615 fac.sex.BW 1 0.000000 0.000000 616 fac.sex.BW 2 -7.786510 0.311478 617 fac.batch.BW 1 0.000000 0.000000 618 fac.batch.BW 2 0.973247 0.341200 619 fac.batch.BW 3 3.017000 0.321880 Also in the output: NrEstimates resid.BW 612Note how bayz.summ() reports that there is also 'resid.BW' in the output with 612 levels/estimates. These estimates are not shown because it exceeds the maximum of 20 levels/estimates reported by bayz.summ(). A second convenient function is bayz.extrac(). This function pulls out a 'clean' table for only one parameter, for instance only the batch-effects from the above model:
> bayz.extract(mmres,"fac.batch.BW") parameter label post.mean post.stdev 617 fac.batch.BW 1 0.000000 0.00000 618 fac.batch.BW 2 0.973247 0.34120 619 fac.batch.BW 3 3.017000 0.32188Another typical use of bayz.extract() is to pull out tables of estimates for parameters not shown in bayz.summ(), because they are too big. This can apply to residuals, breeding values, SNP-effects, nested regression, etc.
While bayz has been running, it has stored MCMC samples from the model. It is possible to retrieve these samples to compute some other posterior statistics than the posterior mean and posterior standard deviation, to compute convergence diagnostics, DIC, etc. To retrieve samples follow the instruction under Output Summaries - Summaries with R.