FitMatch | R Documentation |
Estimating hidden states to maximize agreement with the process.
FitMatchOpt(coefs,which,pars,proc,meth='nlminb',control=list())
FitMatchErr(coefs,allcoefs,which,pars,proc,sgn=1)
FitMatchDC(coefs,allcoefs,which,pars,proc,sgn=1)
FitMatchDC2(coefs,allcoefs,which,pars,proc,sgn=1)
FitMatchList(coefs,allcoefs,which,pars,proc,sgn=1)
coefs |
Vector giving the current estimate of the coefficients for the hidden states. |
allcoefs |
Matrix giving the coefficients of all the states including initial values for |
which |
Vector of indices of states to be estimated. |
pars |
Parameters to be used for the processes. |
proc |
|
sgn |
Is the minimizing (1) or maximizing (0)? |
meth |
Optimization function currently one of 'nlminb', 'MaxNR', 'optim' or 'trust'. |
control |
Control object for optimization function. |
These routines allow the values of coefficients for some states to be optimized relative to the others. That is, the
objective defined by proc
is minimized over those states specified in which
leaving the others constant. This
would be typically done, for example, a smooth is taken to estimate some states non-parametrically, but data is not available on all
of them.
A number of optimization routines have been implemented in FitMatchOpt
, some experimentation is advised.
FitMatchOpt |
A list containing
|
FitMatchErr |
The value of the process likelihood at the current estimated states. |
FitMatchDC |
The derivative of |
FitMatchDC2 |
The second derivative of |
FitMatchList |
Returns a list with elements |
ParsMatchErr
, SplineCoefsErr
, inneropt
###############################
#### Some Data #####
###############################
data(FhNdata)
# And parameter estimates
data(FhNest)
###############################
#### 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)
# Initial values for coefficients will be obtained by smoothing
fd.data = FhNdata[,1]
DEfd = smooth.basis(FhNtimes,fd.data,fdPar(bbasis,1,0.5))
coefs = cbind(DEfd$fd$coefs,rep(0,nbasis))
colnames(coefs) = FhNvarnames
#############################################################
### If We Only Observe One State, We Can Re-Smooth Others ###
#############################################################
profile.obj = LS.setup(pars=FhNpars,coefs=coefs,fn=make.fhn(),
basisvals=bbasis,lambda=1000,times=FhNtimes)
lik = profile.obj$lik
proc= profile.obj$proc
# DD = Matrix(diag(1,200),sparse=TRUE)
# tDD = t(DD)
fres = FitMatchOpt(coefs=coefs,which=2,pars=FhNpars,proc)
plot(fd(fres$coefs,bbasis))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.