library(EstimationTools)
#--------------------------------------------------------------------------------
# Example 1: Predictions from a model using a simulated normal distribution
n <- 1000
x <- runif(n = n, -5, 6)
y <- rnorm(n = n, mean = -2 + 3 * x, sd = exp(1 + 0.3* x))
norm_data <- data.frame(y = y, x = x)
# It does not matter the order of distribution parameters
formulas <- list(sd.fo = ~ x, mean.fo = ~ x)
norm_mod <- maxlogLreg(formulas, y_dist = y ~ dnorm, data = norm_data,
link = list(over = "sd", fun = "log_link"))
predict(norm_mod)
#--------------------------------------------------------------------------------
# Example 2: Predictions using new values for covariates
predict(norm_mod, newdata = data.frame(x=0:6))
#--------------------------------------------------------------------------------
# Example 3: Predictions for another parameter
predict(norm_mod, newdata = data.frame(x=0:6), param = "sd",
type = "response")
#--------------------------------------------------------------------------------
# Example 4: Model terms
predict(norm_mod, param = "sd", type = "terms")
#--------------------------------------------------------------------------------
Run the code above in your browser using DataLab