fit.SATcurve: fit SAT curves

Description Usage Arguments Details Value See Also Examples

Description

A function to fit curve to d primes obtained from MR-SAT experiment.

Usage

1
2
3
4
5
6
fit.SATcurve(data, par.cond, 
             fix.asym = FALSE,
             params = get.param(par.cond, auto.asym=fix.asym, data=data),
             opt = c("acp" ,"nlminb", "nlm", "optim"), 
             multi.opt = FALSE,
             rep=1, quiet=TRUE, maxit=500, strict=TRUE, trace=FALSE)

Arguments

data

data frame contining columns named dprime, lags, and condition (as in the output of get.dprime), or character specifying the location of dat file (see read.dat for detail of the file format)

par.cond

a list specifying the configuraiton of parameters per condition. Should contain three named elements: asym, rate, and incp. See 'Details'.

fix.asym

a logical specifying whether asymptote parameters of the model should be fixed to the starting values supplied in the params argument.

params

a data frame specifying parameters, containing columns named start, lower, and upper. Defalt to get.param(par.cond), see get.param. It can also be a character vector specifying the location of 'par' file (see read.param for detail of the file format).

opt

charaster or a character vector indication the optimizer to be used. If length(opt) > 1 and multi.opt=TRUE, all of the specified methods will be used in the specified order. If length(opt) > 1 and multi.opt=FALSE, the first element of opt will be used.

multi.opt

logical, specifying wheather to fit the data using multiple optimizer.

rep

numeric, representing number of times the optimazation process is repeated. If multi.opt = TRUE, each optimizer specified in opt is run as many times as rep.

quiet

logical. Default to TRUE. If FALSE, a progress bar is printed.

maxit

The maximun number of iteration. Defaults to 500.

strict

logical. Only relevant if method="acp". See 'Details' of acp

trace

logical. Only relevant if method="acp". See 'Details' of acp

Details

The argument par.cond specifies whether or not and how certain parameter(s) are shared across conditions (which are specified in condition column of data). The argument par.cond can take either list or matrix, as long as it meets following specification. If it is a list, then it should be a named list containing following elements: asym, rate, and incp. Each element of the list must be of same length, being equal either to length(condition) or to length(levels(condition)) (or length(unique(condition)) if condition is not a factor). If it is a matrix, then it should have asym, rate, and incp as its columns, and rows should represent different condiitons.

As an example, there are three elements in par (i.e., length(par) = 3), and there are three conditions so that the three conditions share all of λ (asymptote), β (rate) and δ (intercept). In this case, par.cond should be specified as list(asym=c(1,1,1), rate=c(1,1,1), incp=c(1,1,1)).

As another example, there are six elements in par, consisting of three λ (asymptote; one for each condition) , two β (rate; one for condition 1 and anothor for condition 2 and 3), and one δ (intercept; for all the conditions). Here, par.cond = list(asym=c(1,2,3), rate=c(1,2,2), incp=c(1,1,1))

Value

fit

a list of object returned from the optimizer (if multiple optimizers were used, the one that returned the smallest RMSE), with a few additinal information

SSE

Sum of Squared Error of the model.

MSE

Mean Squared Error of the model. A object of class logLik.

RMSE

Root Mean Squared Error of the model.

logLik

Log likelihood of the model. A object of class logLik.

R2

R squared of the model

adjR2

adjusted R squared of the model

data

same as the argument data

par.cond

same as the argument par.cond

rep.out

If rep>1, the data.frame containing the parameters and fit statistics obtained from each repeated fitting of the data. If rep=1, NULL

See Also

acp, optim, nlminb, nlm

Examples

 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
31
32
33
34
35
36
37
#load data
data(Auditory_demo)

#need to define the scale.list
exp1.signal <- list(noint = c(1,3), 
                obrel = c(5,8), 
                obrelsub = c(11, 14))

exp1.noise <- list(noint = c(2,4), 
               obrel = c(6, 7, 9, 10), 
               obrelsub = c(12, 13, 15, 16))


# tag bins
s01.bins <- get.bins(Auditory_demo, auditory=TRUE, window = "fixed")

#calculate dprimes
s01.dp<- get.dprime(s01.bins$bins, 
  signal.list = exp1.signal, noise.list = exp1.noise, is.index = TRUE,
  binmax=14)

# specify par.cond
my.pc <- list(asym=c(1,2,3), rate=c(1,2,2), incp=c(1,1,1))

# fit the data
s01.fit <- fit.SATcurve(s01.dp, par.cond = my.pc)

#plot the data and fitter curves
plot(s01.fit)

#to calculate AIC and BIC, do
AIC(s01.fit)
BIC(s01.fit)

#you may also calculate AIC analogue using MSE
# as suggested by Burnham and Anderson (1998)
AIC(s01.fit$MSE)

matsukik/mrsat documentation built on May 21, 2019, 12:57 p.m.