dat
is the super-class of other classes representing models and data, so
that other model/data classes (e.g., kin
and spec
for kinetic and spectral
models respectively) also have the slots defined here. Slots whose
description are marked with *** may
be specified in the ...
argument of the initModel
function.
Objects from the class
can be created by calls of the form new("dat", ...)
or
dat(...)
, but
most are most often made by invoking another function such as
readData
or initModel
.
thetascal
:*** Object of class "vector"
vector of values to scale the parameter vector with.
weightpar
:*** Object of class "list"
list of vectors
c(first_x, last_x, first_x2, last_x2, weight)
,
where each vector is of length 5 and
specifies an interval in which to weight the data.
first_x: first(absolute, not an index) x
to weight
last_x: last (absolute, not an index) x
to weight
first_x2: first (absolute, not an index) x2
to weight
last_x2: last (absolute, not an index) x2
to weight
weight: numeric by which to weight data
Note that if vector elements 1-4 are NA
(not a number), the firstmost
point of the data is taken for elements 1 and 3, and the lastmost points
are taken for 2 and 4.
For example, weightpar = list(c(40, 1500, 400, 600, .9),
c(NA, NA, 700, 800, .1))
will weight data between times 40 and 1500
picoseconds and 700 and 800 wavelengths by .9, and will weight data at
all times between wavelength 700 and 800 by .1.
Note also that for single photon counting data
weightpar = list(poisson = TRUE)
will apply poisson weighting to all
non-zero elements of the data.
mod_type
:*** Object of class "character"
character string defining the model type, e.g.,
"kin"
or "spec"
fixed
:*** Object of class "list"
list of lists or vectors giving the parameter values
to fix (at their starting values) during optimization.
free
:*** Object of class "list"
list of lists or vectors giving the parameter values
to free during optimization; if this list is present then all parameters
not specified in it are fixed, e.g., free = list(irfpar = 2)
will fix
every parameter at its starting value except for the 2nd irfpar
. If
fix = list(none=TRUE)
(or if the element none
has length
greater than 0) then all parameters in the model are fixed. Note that this
option only should be applied to multiexperiment models in which at least one
parameter applying to some other dataset is optimized (nls
always must
have at least one parameter to optimize).
constrained
:*** Object of class "list"
list whose elements
are lists containing a character vector what
, a vector ind
, and
either (but not both) a character vector low
and high
.
what
should specify the parameter type to constrain. ind
should give the index of the parameter to be constrained, e.g., 1
if
indexing into a vector, and c(1,2)
if indexing into a list.
low
gives a number that the parameter should always remain lower
than and high
gives a number that the parameter should always remain
higher than (so that low
bounds the parameter value from above and
high
bounds the parameter value from below). It is not now possible to
specify both low
and high
for a single parameter value. An
example of a complete constrained
specification is
constrained = list(list(what = "kinpar", ind = 2, low = .3),
list(what = "parmu", ind = c(1,1), high = .002))
clp0
:*** Object of class "list"
list of lists with elements low
, high
and
comp
, specifying the least value in x2
to constrain
to zero, the greatest value in x2
to
constrain to zero, and the component to which to apply the zero constraint,
respectively. e.g., clp0 = list(list(low=400, high = 600, comp=2),
list(low = 600, high = 650, comp=4))
applies zero constraints to the spectra
associated with components 2 and 4.
autoclp0
:*** Object of class "list"
that has two
elements; oldRes
,
the output of fitModel
and an index ind
representing the
index of the dataset to use in oldRes
; ind
defaults to
one. The clp that are negative in oldRes
are constrained to
zero in the new model; this is primarily useful when fitting a model,
finding some negative clp, and constraining them to zero by fitting
again with this option. See also the help page for opt
for
other ways to constrain the clp to non-negativity.
clpequspec
:*** Object of class "list"
list of lists each of which has elements to,
from, low, high
, and optional element dataset
to specify the dataset
from which to get the reference clp (that is, a spectrum for kinetic
models). to
is the component to be fixed in relation to some other
component; from is the reference component. low
and high
are the
least and greatest absolute values of the clp
vector to constrain.
e.g.,
clpequspec = list(list(low = 400, high = 600, to = 1, from = 2))
will constrain the first component to equality to the second component
between wavelengths 400 and 600. Note that equality constraints are
actually constraints to a linear relationship. For each of the equality
constraints specified as a list in the clpequspec
list, specify a
starting value parameterizing this linear relation in the vector
clpequ
; if true equality is desired then fix the corresponding
parameter in clpequ
to 1. Note that if multiple components are
constrained, the from
in the sublists should be increasing order,
(i.e., (list(to=2, from=1, low=100, high=10000),
list(to=3, from=1, low=10000, high=100))
, not list(to=3, from=1, low=10000, high=100),
list(to=2, from=1, low=10000, high=100)
)
clpequ
:***Object of class "vector"
describes the
parameters governing the clp equality constraints specified in clpequspec
prelspec
:*** Object of class "list"
list of lists to specify the functional
relationship between parameters, each of which has elements
what1character string describing the parameter type to relate,
e.g., "kinpar"
what2the parameter type on which the relation is based; usually
the same as what1
ind1index into what1
ind2index into what2
relcharacter string, optional argument to specify functional relation type, by default linear
e.g.,
prelspec = list(list(what1 = "kinpar", what2 = "kinpar", ind1 = 1,
ind2 = 5))
relates the 1st element of kinpar
to the 5th element of
kinpar
. The starting values parameterizing the relationship are
given in the prel
vector
positivepar
:*** Object of class "vector"
containing
character strings of those parameter vectors to constrain to positivity,
e.g., positivepar=c("kinpar")
weight
:Object of class "logical"
TRUE
when the specification in
weightpar
is to be applied and FALSE
otherwise
psi.df
:Object of class "matrix"
dataset from 1 experiment
psi.weight
:Object of class "matrix"
weighted dataset from 1 experiment
x
:Object of class "vector"
time or other independent
variable.
nt
:Object of class "integer"
length x
x2
:Object of class "vector"
vector of points in
2nd independent dimension, such as wavelengths of wavenumbers
nl
:Object of class "integer"
length x2
C2
:Object of class "matrix"
concentration matrix for
simulated data
E2
:Object of class "matrix"
matrix of spectra for
simulated data
sigma
:Object of class "numeric"
noise level in
simulated data
parnames
:Object of class "vector"
vector of
parameter names, used internally
simdata
:Object of class "logical"
logical that is TRUE
if the data is simulated,
FALSE
otherwise; will determine whether values in C2
and
E2
are plotted with results
weightM
:Object of class "matrix"
weights
weightsmooth
:Object of class "list"
type of smoothing to apply with weighting; not currently
used
makeps
:Object of class "character"
specifies the prefix of files written to
postscript
lclp0
:Object of class "logical"
TRUE
if specification in clp0
is to be applied and FALSE
otherwise
lclpequ
:Object of class "logical"
TRUE
if specification in clpequspec
is to be applied and FALSE
otherwise
title
:Object of class "character"
displayed on output plots
mhist
:Object of class "list"
list describing fitting history
datCall
:Object of class "list"
list of calls to functions
dscal
:Object of class "list"
dscalspec
:Object of class "list"
dummy
:Object of class "list"
containing dummy parameters
drel
:Object of class "vector"
vector of starting parameters for dataset scaling relations
scalx
:Object of class "numeric"
numeric by which to scale the x
axis in plotting
vector of starting values for the relations described in prelspec
fvecind
:Object of class "vector"
vector containing indices of fixed parameters
pvecind
:Object of class "vector"
used internally to
store indices of related parameters.
iter
:Object of class "numeric"
describing the
number of iterations that is run; this is sometimes
stored after fitting, but has not effect as an argument to
initModel
clpCon
:Object of class "list"
used internally to enforce constraints on the clp
ncomp
:Object of class "numeric"
describing the number of components in a model
clpdep
:Object of class "logical"
describing whether a model is dependent on the index
of x2
inten
:Object of class "matrix"
for use with FLIM data; represents the number of photons
per pixel measured over the course of all
times $t$ represented by the dataset. See the help for the readData
function for more information.
datafile
:Object of class "character"
containing the name of a datafile associated with the psi.df
clpType
:Object of class "character"
that is "nt" if the model has clp in the "x" dimension and "nl" otherwise
(so that, e.g., if mod\_type = "kin"
, then clpType = "nl"
).
Katharine M. Mullen, Ivo H. M. van Stokkum, Joris J. Snellenburg, Sergey P. Laptenok
kin-class
, spec-class
# simulate data
C <- matrix(nrow = 51, ncol = 2)
k <- c(.5, 1)
t <- seq(0, 2, by = 2/50)
C[, 1] <- exp( - k[1] * t)
C[, 2] <- exp( - k[2] * t)
E <- matrix(nrow = 51, ncol = 2)
wavenum <- seq(18000, 28000, by=200)
location <- c(25000, 20000)
delta <- c(5000, 7000)
amp <- c(1, 2)
E[, 1] <- amp[1] * exp( - log(2) * (2 * (wavenum - location[1])/delta[1])^2)
E[, 2] <- amp[2] * exp( - log(2) * (2 * (wavenum - location[2])/delta[2])^2)
sigma <- .001
Psi_q <- C %*% t(E) + sigma * rnorm(nrow(C) * nrow(E))
# initialize an object of class dat
Psi_q_data <- dat(psi.df = Psi_q, x = t, nt = length(t),
x2 = wavenum, nl = length(wavenum))
# initialize an object of class dat via initModel
# this dat object is also a kin object
kinetic_model <- initModel(mod_type = "kin", seqmod = FALSE,
kinpar = c(.1, 2))
Run the code above in your browser using DataLab