intMarkovOrd
intMarkovOrd.RdCompute Parameters for Proportional Odds Markov Model
Usage
intMarkovOrd(
y,
times,
initial,
absorb = NULL,
intercepts,
extra = NULL,
g,
target,
t,
ftarget = NULL,
onlycrit = FALSE,
constraints = NULL,
printsop = FALSE,
...
)Arguments
- y
vector of possible y values in order (numeric, character, factor)
- times
vector of measurement times
- initial
initial value of
y(baseline state; numeric, character, or factor matchingy). If length 1 this value is used for all subjects, otherwise it is a vector of lengthn.- absorb
vector of absorbing states, a subset of
y(numeric, character, or factor matchingy). The default is no absorbing states. Observations are truncated when an absorbing state is simulated.- intercepts
vector of initial guesses for the intercepts
- extra
an optional vector of intial guesses for other parameters passed to
gsuch as regression coefficients for previous states and for general time trends. Name the elements ofextrafor more informative output.- g
a user-specified function of three or more arguments which in order are
yprev- the value ofyat the previous time, the current timet, thegapbetween the previous time and the current time, an optional (usually named) covariate vectorX, and optional arguments such as a regression coefficient value to simulate from. The function needs to allowyprevto be a vector andyprevmust not include any absorbing states. Thegfunction returns the linear predictor for the proportional odds model aside fromintercepts. The returned value must be a matrix with row names taken fromyprev. If the model is a proportional odds model, the returned value must be one column. If it is a partial proportional odds model, the value must have one column for each distinct value of the response variable Y after the first one, with the levels of Y used as optional column names. So columns correspond tointercepts. The different columns are used fory-specific contributions to the linear predictor (aside fromintercepts) for a partial or constrained partial proportional odds model. Parameters for partial proportional odds effects may be included in the ... arguments.- target
vector of target state occupancy probabilities at time
t. Ifextrais specified,targetmust be a matrix where row names are character versions oftand columns represent occupancy probabilities corresponding to values ofyat the time given in the row.- t
target times. Can have more than one element only if
extrais given.- ftarget
an optional function defining constraints that relate to transition probabilities. The function returns a penalty which is a sum of absolute differences in probabilities from target probabilities over possibly multiple targets. The
ftargetfunction must have two arguments:interceptsandextra.- onlycrit
set to
TRUEto only return the achieved objective criterion and not print anything- constraints
a function of two arguments: the vector of current intercept values and the vector of
extraparameters, returningTRUEif that vector meets the constrains andFALSEotherwise- printsop
set to
TRUEto print solved-for state occupancy probabilities for groups 1 and 2 and log odds ratios corresponding to them- ...
optional arguments to pass to
stats::nlm(). If this is specified, the arguments thatintMarkovOrdnormally sends tonlmare not used.
Value
list containing two vectors named intercepts and extra unless oncrit=TRUE in which case the best achieved sum of absolute errors is returned
Details
Given a vector intercepts of initial guesses at the intercepts in a Markov proportional odds model, and a vector extra if there are other parameters, solves for the intercepts and extra vectors that yields a set of occupancy probabilities at time t that equal, as closely as possible, a vector of target values.