Skip to content

Commit

Permalink
More small changes with prior specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsjohnson committed Jan 24, 2015
1 parent 636f4a2 commit de2e210
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
3 changes: 2 additions & 1 deletion R/crwPostIS.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
} else {
colnames(out$sim) <- apply(expand.grid(c("mu","nu"), c("x","y")), 1, paste, collapse=".")
}
isw <- ifelse(is.null(object.sim$thetaSampList) & fullPost==TRUE, out$ll - object.sim$loglik - dens, 0)
ln.prior = ifelse(!is.null(object.sim$prior), object.sim$prior(par[eInd]), 0)
isw <- ifelse(is.null(object.sim$thetaSampList) & fullPost==TRUE, out$ll - object.sim$loglik - dens, 0) + ln.prior
samp <- list(alpha.sim=out$sim,
predType=object.sim$predType, Time=object.sim$Time,
loglik=out$lly+out$llx, par=par, log.isw = isw)
Expand Down
3 changes: 2 additions & 1 deletion R/crwSamplePar.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ crwSamplePar <- function(object.sim, method="IS", size=1000, df=Inf, grid.eps=1,
par[eInd] <- parMLE[eInd] + eps
if(df==Inf) dens <- dmvnorm(eps, sigma=scale*Cmat, log=TRUE) - dmvnorm(0.0*eps, sigma=scale*Cmat, log=TRUE)
else dens <- dmvt(eps, sigma=scale*Cmat, df=df, log=TRUE) - dmvt(0.0*eps, sigma=scale*Cmat, df=df, log=TRUE)
ln.prior = ifelse(!is.null(prior), prior(par[eInd]), 0)
n2ll.val <- crwN2ll(par[eInd], fixPar, y, noObs, delta, a,
P, mov.mf, err.mfX, err.mfY, rho=rho, activity=activity,
n.errX, n.errY, n.mov, driftMod, prior, need.hess=FALSE,
constr=list(lower=lower, upper=upper)) + prior(par[is.na(fixPar)])
constr=list(lower=lower, upper=upper)) + ln.prior
thetaMat[i,] <- c(-n2ll.val/2 - dens, -n2ll.val/2, dens, par)
}
thetaMat[size,] <- c(object.sim$loglik, object.sim$loglik, 0, object.sim$par)
Expand Down
18 changes: 6 additions & 12 deletions man/crwMLE.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ are vectors the same length as theta giving the box constraints for the
parameters}

\item{prior}{A function returning the log-density function of the parameter
prior specification}
prior distribution. THIS MUST BE A FUNCTION OF ONLY THE FREE PARAMETERS. Any
fixed parameters should not be included.}

\item{need.hess}{A logical value which decides whether or not to evaluate
the Hessian for parameter standard errors}
Expand Down Expand Up @@ -156,17 +157,10 @@ longitude mdoel.
The \code{inital.state} is a list with the following elemets (with the exact
names):

\code{a1.y} A vector with initial state values for the \dQuote{latitude}
coordinate. It have 2 elemets (location at time 1, velocity at time 1) for
non-drift models and 3 elemets for drift models (location at time 1,
velocity at time 1, drift velocity at time 1) for driftmodels,

\code{P1.y} Covarince matrix for the state at time 1 (measure of uncertainty
for your inital state) \code{a1.y},

\code{a1.x} Same as \code{a1.y}, but in the \dQuote{longitude} coordinate,

\code{P1.x} Same as \code{P1.y}, but in the \dQuote{longitude} coordinate.
\code{a} A vector with initial state values. It has 4 elemets (x location at time 1, x velocity at time 1, y location at time 1,
y velocity at time 1) for
non-drift models and 6 elemets for drift models (x location at time 1,
x velocity at time 1, x drift velocity at time 1, etc...).

\code{theta} and \code{fixPar} are vectors with the appropriate number or
parameters. \code{theta} contains only those paraemters which are to be
Expand Down

0 comments on commit de2e210

Please sign in to comment.