Skip to content

Commit

Permalink
Update Optimalgo.Rmd
Browse files Browse the repository at this point in the history
  • Loading branch information
dutangc committed Jun 10, 2024
1 parent 94ce42b commit 1fcf4f9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vignettes/Optimalgo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ grlnlbeta <- fitdistrplus:::grlnlbeta
n <- 200
x <- rbeta(n, 3, 3/4)
grlnlbeta(c(3, 4), x) #test
hist(x, prob=TRUE)
hist(x, prob=TRUE, xlim=0:1)
lines(density(x), col="red")
curve(dbeta(x, 3, 3/4), col="green", add=TRUE)
legend("topleft", lty=1, col=c("red","green"), legend=c("empirical", "theoretical"), bty="n")
Expand Down Expand Up @@ -275,9 +275,9 @@ kable(expopt[, grep("G-", colnames(expopt))], digits=3,

Using `llsurface`, we plot the log-likehood surface around the true value (green) and the fitted parameters (red).
```{r, fig.width=4, fig.height=4}
llsurface(min.arg=c(0.1, 0.1), max.arg=c(7, 3),
llsurface(min.arg=c(0.1, 0.1), max.arg=c(7, 3), xlim=c(.1,7),
plot.arg=c("shape1", "shape2"), nlev=25,
plot.np=50, data=x, distr="beta", back.col = FALSE)
lseq=50, data=x, distr="beta", back.col = FALSE)
points(unconstropt[1,"BFGS"], unconstropt[2,"BFGS"], pch="+", col="red")
points(3, 3/4, pch="x", col="green")
```
Expand Down Expand Up @@ -353,7 +353,7 @@ n <- 200
trueval <- c("size"=10, "prob"=3/4, "mu"=10/3)
x <- rnbinom(n, trueval["size"], trueval["prob"])
hist(x, prob=TRUE, ylim=c(0, .3))
hist(x, prob=TRUE, ylim=c(0, .3), xlim=c(0, 10))
lines(density(x), col="red")
points(min(x):max(x), dnbinom(min(x):max(x), trueval["size"], trueval["prob"]),
col = "green")
Expand Down Expand Up @@ -432,9 +432,9 @@ kable(expopt[, grep("G-", colnames(expopt))], digits=3,

Using `llsurface`, we plot the log-likehood surface around the true value (green) and the fitted parameters (red).
```{r, fig.width=4, fig.height=4}
llsurface(min.arg = c(5, 0.3), max.arg = c(15, 1),
llsurface(min.arg = c(5, 0.3), max.arg = c(15, 1), xlim=c(5, 15),
plot.arg = c("size", "prob"), nlev = 25,
plot.np = 50, data = x, distr = "nbinom", back.col = FALSE)
lseq = 50, data = x, distr = "nbinom", back.col = FALSE)
points(unconstropt["fitted size", "BFGS"], unconstropt["fitted prob", "BFGS"],
pch = "+", col = "red")
points(trueval["size"], trueval["prob"], pch = "x", col = "green")
Expand All @@ -445,7 +445,7 @@ We can simulate bootstrap replicates using the `bootdist` function.
b1 <- bootdist(fitdist(x, "nbinom", method = "mle", optim.method = "BFGS"),
niter = 100, parallel = "snow", ncpus = 2)
summary(b1)
plot(b1, trueval=trueval)
plot(b1, trueval=trueval)
```


Expand Down

0 comments on commit 1fcf4f9

Please sign in to comment.