Rev Language Reference


readTrace - Read an MCMC log file.

Reads parameter values from a log file, usually produced as the output of an MCMC or MCMCMC run.

Usage

readTrace(String file, String separator/delimiter, Probability burnin, Natural thinning, Natural nruns)

Arguments

file : String (pass by value)
Name of the file.
separator/delimiter : String (pass by value)
The field separator character. Values on each line of the file are separated by this character. If sep = "" the separator is 'white space', that is one or more spaces, tabs, newlines or carriage returns.
burnin : Probability (pass by value)
The fraction/number of samples to discard as burnin.
Default : 0.25
thinning : Natural (pass by value)
The frequency of samples to read, i.e., we will only used every n-th sample where n is defined by this argument.
Default : 1
nruns : Natural (pass by value)
The number of trace files with the same basename (i.e. the number of filenames with pattern _run_.log)
Default : 1

Return Type

Details

Either a file name or a directory must be provided as argument. If a folder is provided, all the files that contain trees in that directory are read in the same object. When reading individual log files, field is delimited by `separator`. We drop the first `burnin` iterations if `burnin` is an integer greater than or equal to 1, or the fraction `burnin` of iterations if `burnin` is a real number smaller than 1. Then we keep every `n`th entry if the `thinning` is `n`. `trace = readTrace(..., nruns = 1)` returns a `Trace[]` object. `trace = readTrace(..., nruns > 1)` returns a `Trace[][]` object, in which `trace[n]` corresponds to the trace of run `n`.

Example

# read in a single log file as a vector of traces
traces = readTrace("out.log", burnin=0.5)

# read in two log files called 'out_run_1.log', 'out_run_2.log'
traces = readTrace("out.log", burnin=0.5, nruns=2)

See Also