mspathCalculator-class {mspath} | R Documentation |
This calculator calculates the likelihood and related
quantities for a multi-state path model with possible non-Markov
properties. Alternately, it can generated a simulated data set.
Though you can use a calculator directly, it is usually more
convenient to invoke mspath
. If you use it, you must
follow the rules about the proper sequence in which to invoke
different methods, and you must always use the possibly updated
calculator object that many methods return.
Create objects of this class by calling mspathCalculator
or mspathCalculatorFromArgs
.
args
:list
of arguments to the C function call. As such,
they must be in the correct order, with all necessary
as.xxx
's performed.manager
:C++
object that
performs the calculations. Object of class "externalptr"
.
Much of the state of the mspathCalculator
is really in this
C++
object. The persistence of information between calls
permits faster calculations, but raises the possibility for
errors. Do not do anything with the manager
. do.what
:"integer"
with the code for the
desired operation. This will be interpreted by the C++
routines, and is subject to being changed as a side-effect of
user-level operations. subset
:"integer"
of the ID's of cases for
which the likelihood should be evaluated. The restriction to
integers makes the interface with C
easier. If this vector
is empty, it means analyze all cases.results
:"numeric"
holding the
results of the calculation. In the future, it may hold other
types. If there has not been a calculation with the current
calculator values, this slot will have length 0. See
results
for details.signature(calc = "mspathCalculator",
value = "numeric")
:
value
is a vector of the ID's (which will be converted to
integer
) of the active subset. They should be a subset of
the cases in the calculator; ID's that are not will be ignored.
To reset to using all cases, do activeCases(calc) <- integer()
.signature(calc = "mspathCalculator", value =
"numeric")
:
Sets the parameter values, but does not perform any calculations. Calculation:
signature(calc = "mspathCalculator", params = "ANY",
activeCases = "ANY", do.what = "ANY")
:
Perform the requested calculation, return calc
with the
desired results. The other arguments are optional; if set, they
will set the corresponding values in calc
before the
calculation. The returned calculator will have those new values. signature(calc = "mspathCalculator")
:
Return a matrix
with each row being an individual case and
each column some quantity that might be related to the amount of
computation required for the case. See estimateWork
for details.signature(object="mspathCalculator")
:
Return a data.frame
of simulated observations based on the
actual observations and the model. See the discussion in
mspath
for details. This method uses R's random
number generator; the caller must set that up appropriately before
the simulation.Analysis:
signature(calc = "mspathCalculator")
:
If a subset of the cases are active, returns an "integer" vector
of the ID's of the active cases. Otherwise, return an empty vector. signature(calc = "mspathCalculator")
:
Compute a single number giving the best estimate of likely
effort. This is useful for gauging the relative times of
different subsets; the absolute values have no particular
meaning. In particular, they are not in seconds. signature(calc = "mspathCalculator")
:
Returns -2 times the computed log-likelihood. The value is only
meaningful if you have previously requested a computation. signature(calc = "mspathCalculator")
:
count the number of cases currently under analysis, restricted to
the active subset if any.signature(calc = "mspathCalculator")
:
The number of cases in the calculator. This counts all cases, not
just the active subset. Each case consists of one or more
consecutive records with the same ID.signature(x = "mspathCalculator")
: Number of
invalid nodes generated. signature(x = "mspathCalculator")
: Number of unique
good nodes on these paths. Note that nodes may be shared between
paths, and some "good" nodes turn out not to be on any good paths.
Expected likelihood computation time is roughly proportional to this number. signature(x = "mspathCalculator")
: Total number
of nodes in all the good paths. goodPathNodes/goodPaths is the
average path length. goodNodes/goodPathNodes estimates the
speedup from sharing nodes between paths vs a naive implementation
that treats each path independently. signature(x = "mspathCalculator")
: Number of complete
good paths on which to compute a likelihood. signature(calc = "mspathCalculator")
:
Returns the results of the calculations. You must have requested
calculations first for this to be meaningful. Currently it is a
numeric vector, but that may change. See results
for details. Cleanup:
signature(calc = "mspathCalculator")
:
Call this when you are all done with the computations and this
calculator. This ensures proper cleanup of the C++
objects. Internal:
signature(calc = "mspathCalculator",
effort = "numeric", chunks = "numeric")
:
for internal use only. signature(calc = "mspathCalculator",
chunks = "numeric")
:
for internal use only.
Ordinarily one creates a calculator and then asks it to evaluate
the likelihoods of different parameter sets, finally extracting the
results.
calc <- mspathCalculator(...)
calc <- calculate(calc, params)
ll <- minus2loglik(calc)
done(calc)
Ross Boylan
Creation:
mspathCalculator
,
mspathCalculatorFromArgs
.
Setup:
params<-
,
estimateWork
.
Calculation:
calculate
,
estimateWork
.
Analysis:
minus2loglik
,
effort
,
results
.
Cleanup:
done
.