wdm: Wiener diffusion model fit function

Description Usage Arguments Details Examples

View source: R/wdm.R

Description

wdm creates parameter estimates for the four parameters of the Wiener model.

Usage

1
2
3
4
  wdm(data, yvar=c("q", "resp"), alpha=NULL, tau=NULL, beta=NULL,
    delta=NULL, xvar=NULL, start=NULL, fixed=0)
  ## S3 method for class 'wdm'
vcov(object, ..., method="hessian")

Arguments

data

is the data object containing data coming from a (hypothetical) Wiener diffusion process. For further details on the data object, see is.wiener.

yvar

represents an optional vector, that can be used to define the names of the reaction time column. For further details on the data object, see is.wiener.

alpha

optional, can be used to fix the alpha parameter to the given value.

tau

optional, can be used to fix the tau parameter to the given value.

beta

optional, can be used to fix the beta parameter to the given value.

delta

optional, can be used to fix the delta parameter to the given value.

xvar

optional: group factor variable to estimate all unfixed parameters separate for the given groups.

start

an optional vector with the four starting parameter values in the following order: alpha, tau, beta, delta.

fixed

a number indicating how many of the parameters are fixed (not free). This number will be subtracted from the number of free parameters. Defaults to 0.

method

the method to use for estimating the covariance matrix of the parameter estimates. Options are "opg" for outer product of gradients or "hessian" to use the hessian matrix from the estimation routine. Defaults to "hessian".

object

a wdm object file or a list containing a $par vector with the model parameters, a $data data.frame with the data and optionally a $loss function.

...

arguments passed to methods.

Details

The wdm function calls an estimation routine, to estimate the model parameters.

If all but one parameters are fixed, a "Brent (optim)" type algorithm is used. For the estimation of more than one parameter, first a "BFGS (optim)" type algorithm is tried, if unsuccessful, a "Newton type (nlm)" algorithm is tried, if again unsuccessful, a "Nelder-Mead (optim)" algorithm is used.

In case all parameters are set to fixed values, no estimation routine is called, but a wdm object will still be created.

The returned wdm object is basically a list containing the parameter estimates in $coefficients. $hessian contains the numerically differentiated Hessian matrix (if available, else NULL). $data contains the data passed to the wdm function call. $loglik contains the log-likelihood value for the wdm object and its parameter estimates. $estpar contains a vector, that is TRUE if the respective parameter was estimated and FALSE if the respective parameter was set to a fixed value. Additional information is given in other list objects.

The standard R functions coef, vcov, confint, summary can be used with wdm objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## generate random data
dat <- rbind(cbind(rwiener(100, 2,.3,.5,1), group=factor("A", c("A","B"))),
        cbind(rwiener(100,2,.3,.5,-1), group=factor("B", c("A", "B"))))

## fit wdm
wdm1 <- wdm(dat)

## extract parameters
coef(wdm1)

## further models
wdm2 <- wdm(dat, beta=.5)
wdm3 <- wdm(dat, alpha=wdm1$coefficients[1], tau=wdm1$coefficients[2],
            beta=wdm1$coefficients[3], xvar="group")

Example output

     alpha        tau       beta      delta 
1.72761676 0.33341225 0.49027032 0.08092441 

RWiener documentation built on May 5, 2020, 1:05 a.m.

Related to wdm in RWiener...