| Lognormal | R Documentation |
This function is implemented to variable of interest (y) that assumed to be a Lognormal Distribution. The range of data is (y > 0
Lognormal(
formula,
iter.update = 3,
iter.mcmc = 10000,
coef,
var.coef,
thin = 2,
burn.in = 2000,
tau.u = 1,
data
)
formula |
Formula that describe the fitted model |
iter.update |
Number of updates with default |
iter.mcmc |
Number of total iterations per chain with default |
coef |
a vector contains prior initial value of Coefficient of Regression Model for fixed effect with default vector of |
var.coef |
a vector contains prior initial value of variance of Coefficient of Regression Model with default vector of |
thin |
Thinning rate, must be a positive integer with default |
burn.in |
Number of iterations to discard at the beginning with default |
tau.u |
Prior initial value of inverse of Variance of area random effect with default |
data |
The data frame |
This function returns a list of the following objects:
Est |
A vector with the values of Small Area mean Estimates using Hierarchical bayesian method |
refVar |
Estimated random effect variances |
coefficient |
A dataframe with the estimated model coefficient |
plot |
Trace, Dencity, Autocorrelation Function Plot of MCMC samples |
## Data Generation
set.seed(123)
m <- 30
x1 <- runif(m, 0, 1)
x2 <- runif(m, 1, 2)
x3 <- runif(m, 2, 3)
b0 <- b1 <- b2 <- b3 <- 0.5
u <- rnorm(m, 0, 1)
mu <- b0 + b1 * x1 + b2 * x2 + b3 * x3 + u
sig <- 1
y <- rlnorm(m, mu, sig)
E <- exp(mu + 1 / 2 * sig^2)
vardir <- exp(2 * mu + sig^2) * (exp(sig^2) - 1)
dataLognormal <- as.data.frame(cbind(y, x1, x2, x3, vardir))
dataLognormalNs <- dataLognormal
dataLognormalNs$y[c(3, 14, 22, 29, 30)] <- NA
dataLognormalNs$vardir[c(3, 14, 22, 29, 30)] <- NA
## Compute Fitted Model
## y ~ x1 +x2 +x3
## For data without any nonsampled area
formula <- y ~ x1 + x2 + x3
v <- c(1, 1, 1, 1)
c <- c(0, 0, 0, 0)
## Using parameter coef and var.coef
saeHBLognormal <- Lognormal(formula, coef = c, var.coef = v, iter.update = 10, data = dataLognormal)
saeHBLognormal$Est # Small Area mean Estimates
saeHBLognormal$refVar # Random effect variance
saeHBLognormal$coefficient # coefficient
# Load Library 'coda' to execute the plot
# autocorr.plot(saeHBLognormal$plot[[3]]) is used to generate ACF Plot
# plot(saeHBLognormal$plot[[3]]) is used to generate Density and trace plot
## Do not using parameter coef and var.coef
saeHBLognormal <- Lognormal(formula, data = dataLognormal)
## For data with nonsampled area use dataLognormalNs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.