Smooth.LS {CollocInfer}  R Documentation 
ModelBased Smoothing Functions
Description
Perform the inner optimization to estimate coefficients given parameters.
Usage
Smooth.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',control.in,eps=1e6,
posproc=FALSE,poslik=FALSE,discrete=FALSE,names=NULL,
sparse=FALSE)
Smooth.multinorm(fn,data,times,pars,coefs=NULL,basisvals=NULL,var=c(1,0.01),
fd.obj=NULL,more=NULL,quadrature=NULL,in.meth='nlminb',
control.in,eps=1e6,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 'SplineEst'.
The last calls 
control.in 
Control object for inner optimization function. 
eps 
Finite differencing step size, if needed. 
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 discrete or continuoustime system? 
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 routines create lik
and proc
objects and call inneropt
.
Value
A list with elements
coefs 
Optimized coefficients at 
lik 
The 
proc 
The 
res 
The result of the optimization method 
data 
The data used in doing the fitting. 
times 
The vector of times at which the observations were made 
See Also
inneropt
, LS.setup
, multinorm.setup
, SplineCoefsErr
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 = Smooth.LS(make.fhn(),data=FhNdata,times=FhNtimes,pars=spars,coefs=coefs,
basisvals=bbasis,lambda=lambda,in.meth='nlminb')
## Not run:
# Henon system
hpars = c(1.4,0.3) # Parameters
t = 1:200
x = c(1,1) # Create some dataa
X = matrix(0,200+20,2)
X[1,] = x
for(i in 2:(200+20)){ X[i,] = make.Henon()$ode(i,X[i1,],hpars,NULL) }
X = X[20+1:200,]
Y = X + 0.05*matrix(rnorm(200*2),200,2)
basisvals = diag(rep(1,200)) # Basis is just identiy
coefs = matrix(0,200,2)
# For sum of squared errors
lambda = 10000
res1 = Smooth.LS(make.Henon(),data=Y,times=t,pars=hpars,coefs,basisvals=basisvals,
lambda=lambda,in.meth='nlminb',discrete=TRUE)
## End(Not run)
## Not run:
# For multinormal transitions
var = c(1,0.01)
res2 = Smooth.multinorm(make.Henon(),data=Y,t,pars=hpars,coefs,basisvals=NULL,
var=var,in.meth='nlminb',discrete=TRUE)
## End(Not run)