# Example: Inverse Gaussian (IG) distribution with weights
# Set the seed to reproduce example.
set.seed(123)
# Set the sample size
n <- 50
# Assign weights
weights <- rep(1.5,n)
# Set mean and shape parameters for IG distribution.
mio <- 2
lambda <- 2
# Generate a random sample from IG distribution with weighted shape.
sim_data <- statmod::rinvgauss(n, mean = mio, shape = lambda * weights)
# Compute MLE of parameters, score matrix, and pit values.
theta_hat <- inversegaussianMLE(obs = sim_data, w = weights)
ScoreMatrix <- inversegaussianScore(obs = sim_data, w = weights, mle = theta_hat)
pitvalues <- inversegaussianPIT(obs = sim_data , w = weights, mle = theta_hat)
# Apply the goodness-of-fit test.
testYourModel(x = sim_data, pit = pitvalues, score = ScoreMatrix)
Run the code above in your browser using DataLab