intMarkovOrd: intMarkovOrd

intMarkovOrdR Documentation

intMarkovOrd

Description

Compute 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 matching y). If length 1 this value is used for all subjects, otherwise it is a vector of length n.

absorb

vector of absorbing states, a subset of y (numeric, character, or factor matching y). 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 g such as regression coefficients for previous states and for general time trends. Name the elements of extra for more informative output.

g

a user-specified function of three or more arguments which in order are yprev - the value of y at the previous time, the current time t, the gap between the previous time and the current time, an optional (usually named) covariate vector X, and optional arguments such as a regression coefficient value to simulate from. The function needs to allow yprev to be a vector and yprev must not include any absorbing states. The g function returns the linear predictor for the proportional odds model aside from intercepts. The returned value must be a matrix with row names taken from yprev. 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 to intercepts. The different columns are used for y-specific contributions to the linear predictor (aside from intercepts) 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. If extra is specified, target must be a matrix where row names are character versions of t and columns represent occupancy probabilities corresponding to values of y at the time given in the row.

t

target times. Can have more than one element only if extra is 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 ftarget function must have two arguments: intercepts and extra.

onlycrit

set to TRUE to 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 extra parameters, returning TRUE if that vector meets the constrains and FALSE otherwise

printsop

set to TRUE to 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 that intMarkovOrd normally sends to nlm are not used.

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.

Value

list containing two vectors named intercepts and extra unless oncrit=TRUE in which case the best achieved sum of absolute errors is returned

Author(s)

Frank Harrell

See Also

https://hbiostat.org/R/Hmisc/markov/


Hmisc documentation built on June 22, 2024, 12:19 p.m.