# NOT RUN {
data(resultNest_6p_SSM6p)
x1 <- resultNest_6p_SSM6p$par
data(resultNest_4p_SSM4p)
x2 <- resultNest_4p_SSM4p$par
temperaturesC <- (200:350)/10
s <- ChangeSSM(temperatures=temperaturesC, parameters=x1, initial.parameters=x2)
sY <- plotR(resultNest_6p_SSM6p, ylim=c(0,3), col="black", curves = "ML")
plotR(resultNest_4p_SSM4p, col="red", scaleY=sY, new=FALSE)
plotR(s$par, col="green", scaleY=sY, new=FALSE, curves = "ML")
legend("topleft", legend=c("r function to mimic", "Initial new r function",
"Fitted new r function"), lty=c(1, 1, 1), col=c("black", "red", "green"))
# Other example to fit anchored parameters
data(resultNest_4p_SSM4p)
x0 <- resultNest_4p_SSM4p$par
t <- hist(resultNest_4p_SSM4p, plot=FALSE)
x <- c(3.4, 3.6, 5.4, 5.6, 7.6, 7.5, 3.2)
names(x) <- seq(from=range(t$temperatures)[1], to=range(t$temperatures)[2],
length.out=7)
newx <- ChangeSSM(temperatures = (200:350)/10, parameters = x0,
initial.parameters = x,
control=list(maxit=5000))
# Example on how to generate a set of SSM parameters from anchored parameters
xanchor <- GenerateAnchor(nests=resultNest_4p_SSM4p)
x <- resultNest_4p_SSM4p$par
xanchor["294"] <- 0
xanchor["308"] <- 2.3291035
x <- ChangeSSM(parameters = xanchor,
initial.parameters = x, control=list(maxit=5000))
sY <- plotR(resultNest_4p_SSM4p$par, ylim = c(0,3), curves="ML")
plotR(xprime$par, col="red", scaleY=sY, new=FALSE, curves="ML")
legend("topleft", legend=c("Fitted parameters", "Constrainted parameters"), lty=1,
col=c("black", "red"))
# Weibull model
x <- ChangeSSM(temperatures = (200:350)/10,
parameters = resultNest_4p_SSM4p$par,
initial.parameters = structure(c(73, 300, 26),
.Names = c("k", "lambda", "scale")),
control=list(maxit=1000))
# normal asymmetric model
x <- ChangeSSM(temperatures = (200:350)/10,
parameters = resultNest_4p_SSM4p$par,
initial.parameters = structure(c(3, 10, 8, 32),
.Names = c("Scale", "sdL", "sdH", "Peak")),
control=list(maxit=1000))
# trigonometric model
x <- ChangeSSM(temperatures = (200:350)/10,
parameters = resultNest_4p_SSM4p$par,
initial.parameters = structure(c(3, 20, 40, 32),
.Names = c("Max", "LengthB", "LengthE", "Peak")),
control=list(maxit=1000))
# example with a mcmc object, CI being 2.SD
# Note the symmetric CI
data(resultNest_mcmc_4p_SSM4p)
new_result <- ChangeSSM(resultmcmc = resultNest_mcmc_4p_SSM4p, result = resultNest_4p_SSM4p,
temperatures = seq(from = 20, to = 35, by = 0.1),
outmcmc = "mean-sd",
initial.parameters = NULL)
plotR(new_result, ylim=c(0, 3), curves="ML")
# example with a mcmc object, CI being defined by 2.5%-97.5% quantiles
# Note the asymmetric CI
data(resultNest_mcmc_4p_SSM4p)
new_result <- ChangeSSM(resultmcmc = resultNest_mcmc_4p_SSM4p, result = resultNest_4p_SSM4p,
temperatures = seq(from = 20, to = 35, by = 0.1),
outmcmc = "quantiles",
initial.parameters = NULL)
plotR(new_result, ylim=c(0, 3), curves="ML")
plotR(new_result, ylim=c(0, 3), curves="ML quantiles")
# }
Run the code above in your browser using DataLab