Description Usage Arguments Details References Examples
logLik.wdm computes the log-likelihood.
deviance.wdm computes the deviance.
AIC.wdm computes the AIC.
BIC.wdm computes the BIC.
1 2 3 4 5 6 7 8 |
object |
a wdm object file or a list containing a |
... |
optional arguments |
The $par vector with the (four) parameter values should be in the following
order: alpha, tau, beta, delta.
The $data data.frame with data needs a reaction time column and a
accuracy/response column.
The $loss function defaults to NULL, which means that the default
computation is done by using the default formula.
If not NULL, this can be a function to replace the default
computation in the code and use a custom function
instead. The custom function takes two arguments: the parameter vector
and the data.frame with the data.
These functions can be very useful in combination with the optim funcion, to estimate parameters manually. Check the examples below to see how to use the provided generic functions in a manual estimation routine.
Wabersich, D., & Vandekerckhove, J. (2014). The RWiener package: An R package providing distribution functions for the Wiener diffusion model. The R Journal, 6(1), 49-56.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## generate random data
dat <- rwiener(100,3,.25,.5,0.8)
## fit wdm
wdm1 <- wdm(dat, alpha=3, tau=.25, beta=0.5)
## compute likelihood, AIC, BIC, deviance
logLik(wdm1)
AIC(wdm1)
BIC(wdm1)
deviance(wdm1)
## Not run:
## estimate parameters by calling optim manually
## first define necessary wrapper function
nll <- function(x, data) {
object <- wdm(data, alpha=x[1], tau=x[2], beta=x[3], delta=x[4])
-logLik(object)
}
## call estimation routine
onm <- optim(c(1,.1,.1,1),nll,data=dat, method="Nelder-Mead")
est <- optim(onm$par,nll,data=dat, method="BFGS",hessian=TRUE)
est$par # parameter estimates
## use the obtained parameter estimates to create wdm object
wdm2 <- wdm(dat, alpha=est$par[1], tau=est$par[2], beta=est$par[3],
delta=est$par[4])
## now the generic functions can be used again
logLik(wdm2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.