# NOT RUN {
#--------------------------------------------------------------------------------
# Estimation with one fixed parameter
x <- rnorm(n = 10000, mean = 160, sd = 6)
theta_1 <- maxlogL(x = x, dist = 'dnorm', control = list(trace = 1),
link = list(over = "sd", fun = "log_link"),
fixed = list(mean = 160))
summary(theta_1)
#--------------------------------------------------------------------------------
# Both parameters of normal distribution mapped with logarithmic function
theta_2 <- maxlogL( x = x, dist = "dnorm",
link = list(over = c("mean","sd"),
fun = c("log_link","log_link")) )
summary(theta_2)
#--------------------------------------------------------------------------------
# Parameter estimation in ZIP distribution
library(gamlss.dist)
z <- rZIP(n=10000, mu=6, sigma=0.08)
theta_3 <- maxlogL( x = z, dist='dZIP', start = c(0, 0), lower = c(-Inf, -Inf),
upper = c(Inf, Inf), optimizer = 'optim',
link = list(over=c("mu", "sigma"),
fun = c("log_link", "logit_link")) )
summary(theta_3)
#--------------------------------------------------------------------------------
# }
Run the code above in your browser using DataLab