Profiling Routines {CollocInfer}  R Documentation 
Profile Estimation Functions
Description
These functions are wrappers that create lik and proc functions and run generalized profiling.
Usage
Profile.LS(fn,data,times,pars,coefs=NULL,basisvals=NULL,lambda,
fd.obj=NULL,more=NULL,weights=NULL,quadrature=NULL,
likfn = make.id(), likmore = NULL,
in.meth='nlminb',out.meth='nls',
control.in,control.out,eps=1e6,active=NULL,posproc=FALSE,
poslik=FALSE,discrete=FALSE,names=NULL,sparse=FALSE)
Profile.multinorm(fn,data,times,pars,coefs=NULL,basisvals=NULL,var=c(1,0.01),
fd.obj=NULL,more=NULL,quadrature=NULL,
in.meth='nlminb',out.meth='optim',
control.in,control.out,eps=1e6,active=NULL,
posproc=FALSE,poslik=FALSE,discrete=FALSE,names=NULL,sparse=FALSE)
Arguments
fn 
A function giving the right hand side of a differential/difference equation. The function should have arguments
It should return a matrix of the same dimension of If
These functions take the same arguments as 
data 
Matrix of observed data values. 
times 
Vector observation times for the data. 
pars 
Initial values of parameters to be estimated processes. 
coefs 
Vector giving the current estimate of the coefficients in the spline. 
basisvals 
Values of the collocation basis to be used. This can either be a basis object from the

lambda 
( 
var 
( 
fd.obj 
(Optional) A functional data object; if this is nonnull, 
more 
An object specifying additional arguments to 
weights 
( 
quadrature 
Quadrature points, should contain two elements (if not NULL)

in.meth 
Inner optimization function to be used, currently one of 'nlminb', 'MaxNR', 'optim' or 'house'.
The last calls 
out.meth 
Outer optimization function to be used, depending on the type of method

control.in 
Control object for inner optimization function. 
control.out 
Control object for outer optimization function. 
eps 
Finite differencing step size, if needed. 
active 
Incides indicating which parameters of 
posproc 
Should the state vector be constrained to be positive? If this is the case, the state is represented by
an exponentiated basis expansion in the 
poslik 
Should the state be exponentiated before being compared to the data? When the state is represented
on the log scale ( 
discrete 
Is this a discretetime or a continuoustime system? If discrete, the derivative is instead taken to be the value at the next time point. 
names 
The names of the state variables if not given by the column names of 
sparse 
Should sparse matrices be used for basis values? This option can save memory when

likfn 
Defines a map from the trajectory to the observations. This should be in the same form as

likmore 
A list containing additional inputs to 
Details
These functional all carry out the profiled optimization method of Ramsay et al 2007.
Profile.LS
uses a sum of squared errors criteria for both fit to data and the fit of the derivatives
to a differential equation. Profile.multinorm
uses multivariate normal approximations.
discrete
changes the system to a discretetime difference equation with the right hand side function
giving the transition function.
Note that these all call outeropt
, which creates
temporary files 'curcoefs.tmp' and 'optcoefs.tmp' to update coefficients as pars
evolves. These overwrite
existing files of those names and are deleted before the function terminates.
Value
A list with elements
pars 
Optimized parameters 
coefs 
Optimized coefficients at 
lik 
The 
proc 
The 
data 
The data used in doing the fitting. 
times 
The vector of times at which the observations were made 
See Also
outeropt
, ProfileErr
, ProfileSSE
, LS.setup
, multinorm.setup
Examples
###############################
#### Data #######
###############################
data(FhNdata)
###############################
#### Basis Object #######
###############################
knots = seq(0,20,0.2)
norder = 3
nbasis = length(knots) + norder  2
range = c(0,20)
bbasis = create.bspline.basis(range=range(FhNtimes),nbasis=nbasis,
norder=norder,breaks=knots)
#### Start from preestimated values to speed up optimization
data(FhNest)
spars = FhNestPars
coefs = FhNestCoefs
lambda = 10000
res1 = Profile.LS(make.fhn(),data=FhNdata,times=FhNtimes,pars=spars,coefs=coefs,
basisvals=bbasis,lambda=lambda,in.meth='nlminb',out.meth='nls')
Covar = Profile.covariance(pars=res1$pars,times=FhNtimes,data=FhNdata,
coefs=res1$coefs,lik=res1$lik,proc=res1$proc)
## Not run:
## Alternative, starting from perturbed coefficients  takes too long for
# automatic checks in CRAN
# Initial values for coefficients will be obtained by smoothing
DEfd = smooth.basis(FhNtimes,FhNdata,fdPar(bbasis,1,0.5)) # Smooth to estimate
# coefficients first
coefs = DEfd$fd$coefs
colnames(coefs) = FhNvarnames
###############################
#### Optimization ###
###############################
spars = c(0.25,0.15,2.5) # Perturbed parameters
names(spars)=FhNparnames
lambda = 10000
res1 = Profile.LS(make.fhn(),data=FhNdata,times=FhNtimes,pars=spars,coefs=coefs,
basisvals=bbasis,lambda=lambda,in.meth='nlminb',out.meth='nls')
par(mfrow=c(2,1))
plotfit.fd(FhNdata,FhNtimes,fd(res1$coefs,bbasis))
## End(Not run)
## Not run:
####################################################
### An Explicitly Multivariate Normal Formation ###
####################################################
var = c(1,0.0001)
res2 = Profile.multinorm(make.fhn(),FhNdata,FhNtimes,pars=res1$pars,
res1$coefs,bbasis,var=var,out.meth='nlminb', in.meth='nlminb')
## End(Not run)