Skip to content

Commit 22b8141

Browse files
change ctcrw parameter 'gamma' to 'beta'
1 parent 136eaba commit 22b8141

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

R/getDM.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ getDM<-function(data,DM,dist,nbStates,parNames,bounds,Par,zeroInflation,oneInfla
9999
}
100100
for(j in DMnames){
101101
if(grepl("langevin\\(",j)) {
102-
if(!TMB) stop("Langevin models cannot be specified using DM formulas; they must be manually specified as a DM matrix")
102+
if(!TMB) stop('Langevin models cannot be specified using DM formulas; they must be manually specified as a DM matrix (unless TMB is used)')
103103
if(!(dist[[i]] %in% rwdists)) stop("langevin() special formula can only be used for normal random walk data stream distributions")
104104
if(!grepl("mean",j))
105105
stop("langevin() special formula can only be used for the means of normal random walk data stream distributions")

R/momentuHMM_utils.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ convertCTCRW <- function(distname,par,nbStates,data){
344344
for(i in 1:nbStates){
345345
mvnpar[i,] <- data[[paste0(distname,".x_tm1")]] + par[i,]^dtm1 * crw(data[[paste0(distname,".x_tm1")]],dt=data$dt)
346346
mvnpar[nbStates+i,] <- data[[paste0(distname,".y_tm1")]] + par[i,]^dtm1 * crw(data[[paste0(distname,".y_tm1")]],dt=data$dt)
347-
sigma <- (-log(par[i,])*par[nbStates+i,]^2)/(2*log(par[i,])^2)
348-
mvnpar[2*nbStates+i,] <- mvnpar[3*nbStates+i,] <- sqrt(sigma-par[i,]^data$dt * sigma * par[i,]^data$dt)
347+
var <- (-log(par[i,])*par[nbStates+i,]^2)/(2*log(par[i,])^2)
348+
mvnpar[2*nbStates+i,] <- mvnpar[3*nbStates+i,] <- sqrt(var-par[i,]^data$dt * var * par[i,]^data$dt)
349349
}
350350
return(mvnpar)
351351
}

R/parDef.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ parDef <- function(dist,nbStates,estAngleMean,zeroInflation,oneInflation,DM,user
7878
parSize[[i]] <- 2
7979
tmpbounds <- matrix(c(rep(c(0,1),nbStates),rep(c(0,Inf),nbStates)),
8080
ncol=2,byrow=TRUE)
81-
parNames[[i]]<-c("gamma","sigma")
81+
parNames[[i]]<-c("beta","sigma")
8282
},
8383
"ctds"={
8484
parSize[[i]] <- dimCat-1

src/TMB/include/dist_def.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ class CTCRW : public Dist<Type> {
14181418
// Multivariate Probability density function
14191419
Type pdf(const vector<Type>& x, const vector<Type>& par, const Type& delta_t, const bool& logpdf) {
14201420
int dim = 2;
1421-
Type gamma = par(0);
1421+
Type beta = par(0);
14221422
Type sigma = par(1);
14231423
Type x_tm1 = x(2);
14241424
Type y_tm1 = x(3);
@@ -1429,10 +1429,10 @@ class CTCRW : public Dist<Type> {
14291429

14301430
vector<Type> mean(dim);
14311431
matrix<Type> Sigma(dim, dim);
1432-
mean(0) = x_tm1 + delta_t * exp(log(gamma) * delta_tm1) * (x_tm1-x_tm2)/delta_tm1;
1433-
mean(1) = y_tm1 + delta_t * exp(log(gamma) * delta_tm1) * (y_tm1-y_tm2)/delta_tm1;
1434-
Type var = (-log(gamma)*sigma*sigma)/(Type(2.)*log(gamma)*log(gamma));
1435-
Type sigma2 = var - exp(log(gamma) * delta_t) * var * exp(log(gamma) * delta_t);
1432+
mean(0) = x_tm1 + delta_t * exp(log(beta) * delta_tm1) * (x_tm1-x_tm2)/delta_tm1;
1433+
mean(1) = y_tm1 + delta_t * exp(log(beta) * delta_tm1) * (y_tm1-y_tm2)/delta_tm1;
1434+
Type var = (-log(beta)*sigma*sigma)/(Type(2.)*log(beta)*log(beta));
1435+
Type sigma2 = var - exp(log(beta) * delta_t) * var * exp(log(beta) * delta_t);
14361436
Sigma(0,0) = delta_t * sigma2;
14371437
Sigma(1,1) = delta_t * sigma2;
14381438
Sigma(1,0) = 0.;

vignettes/momentuHMM.Rnw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ If circular-circular regression is specified for the mean of angular distributio
267267
& & $\verb|mean.y|\in{\rm I\!R}$ & identity \tabularnewline
268268
& & $\verb|sd.x|>0$ & $\log$ \tabularnewline & & $\verb|sd.y|>0$ & $\log$ \tabularnewline
269269
& & $\verb|corr.xy|\in(-1,1)$ & logit \tabularnewline
270-
\rowcolor{Gray} Continuous-time correlated random walk (``\verb|ctcrw|'')& ${\mathbf z_t}\in{\rm I\!R}^2$ & $\verb|gamma|>0$ & $\log$ \tabularnewline
270+
\rowcolor{Gray} Continuous-time correlated random walk (``\verb|ctcrw|'')& ${\mathbf z_t}\in{\rm I\!R}^2$ & $\verb|beta|>0$ & $\log$ \tabularnewline
271271
\rowcolor{Gray} & & $\verb|sigma|>0$ & $\log$ \tabularnewline
272272
Trivariate normal (``\verb|mvnorm3|'')& ${\mathbf z_t}\in{\rm I\!R}^3$ & $\verb|mean.x|\in{\rm I\!R}$ & identity \tabularnewline
273273
& & $\verb|mean.y|\in{\rm I\!R}$ & identity \tabularnewline

vignettes/momentuHMM.pdf

7 Bytes
Binary file not shown.

vignettes/momentuHMM.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ \section{momentuHMM overview}
313313
& & $\verb|mean.y|\in{\rm I\!R}$ & identity \tabularnewline
314314
& & $\verb|sd.x|>0$ & $\log$ \tabularnewline & & $\verb|sd.y|>0$ & $\log$ \tabularnewline
315315
& & $\verb|corr.xy|\in(-1,1)$ & logit \tabularnewline
316-
\rowcolor{Gray} Continuous-time correlated random walk (``\verb|ctcrw|'')& ${\mathbf z_t}\in{\rm I\!R}^2$ & $\verb|gamma|>0$ & $\log$ \tabularnewline
316+
\rowcolor{Gray} Continuous-time correlated random walk (``\verb|ctcrw|'')& ${\mathbf z_t}\in{\rm I\!R}^2$ & $\verb|beta|>0$ & $\log$ \tabularnewline
317317
\rowcolor{Gray} & & $\verb|sigma|>0$ & $\log$ \tabularnewline
318318
Trivariate normal (``\verb|mvnorm3|'')& ${\mathbf z_t}\in{\rm I\!R}^3$ & $\verb|mean.x|\in{\rm I\!R}$ & identity \tabularnewline
319319
& & $\verb|mean.y|\in{\rm I\!R}$ & identity \tabularnewline

0 commit comments

Comments
 (0)