Skip to contents

The function WALD() defines the wALD distribution, two-parameter continuous distribution for a gamlss.family object to be used in GAMLSS fitting using the function gamlss().

Usage

WALD(mu.link = "log", sigma.link = "log")

Arguments

defines the mu.link, with "log" link as the default for the mu parameter.

defines the sigma.link, with "log" link as the default for the sigma parameter.

Value

Returns a gamlss.family object which can be used to fit a WALD distribution in the gamlss() function.

Details

The Wald distribution with parameters \(\mu\) and \(sigma\) has density given by

\(\operatorname{f}(x |\mu, \sigma)=\frac{\sigma}{\sqrt{2 \pi x^3}} \exp \left[-\frac{(\sigma-\mu x)^2}{2x}\right ], x>0 \)

References

Heathcote, A. (2004). Fitting Wald and ex-Wald distributions to response time data: An example using functions for the S-PLUS package. Behavior Research Methods, Instruments, & Computers, 36, 678-694.

See also

Author

Sofia Cuartas García, scuartasg@unal.edu.co

Examples

# Example 1
# Generating random values with
# known mu and sigma
require(gamlss)
mu <- 1.5
sigma <- 4.0

y <- rWALD(10000, mu, sigma)

mod1 <- gamlss(y~1, sigma.fo=~1,  family="WALD",
               control=gamlss.control(n.cyc=5000, trace=TRUE))
#> GAMLSS-RS iteration 1: Global Deviance = 27557.93 
#> GAMLSS-RS iteration 2: Global Deviance = 27557.83 
#> GAMLSS-RS iteration 3: Global Deviance = 27557.77 
#> GAMLSS-RS iteration 4: Global Deviance = 27557.74 
#> GAMLSS-RS iteration 5: Global Deviance = 27557.72 
#> GAMLSS-RS iteration 6: Global Deviance = 27557.71 
#> GAMLSS-RS iteration 7: Global Deviance = 27557.7 
#> GAMLSS-RS iteration 8: Global Deviance = 27557.7 
#> GAMLSS-RS iteration 9: Global Deviance = 27557.7 
#> GAMLSS-RS iteration 10: Global Deviance = 27557.7 
#> GAMLSS-RS iteration 11: Global Deviance = 27557.7 

exp(coef(mod1, what="mu"))
#> (Intercept) 
#>    1.518594 
exp(coef(mod1, what="sigma"))
#> (Intercept) 
#>      4.0436 

# Example 2
# Generating random values under some model

# A function to simulate a data set with Y ~ WALD
gendat <- function(n) {
  x1 <- runif(n)
  x2 <- runif(n)
  mu <- exp(0.75 - 0.69 * x1)   # Approx 1.5
  sigma <- exp(0.5 - 0.64 * x2) # Approx 1.20
  y <- rWALD(n, mu, sigma)
  data.frame(y=y, x1=x1, x2=x2)
}

dat <- gendat(n=200)

mod2 <- gamlss(y~x1, sigma.fo=~x2, family=WALD, data=dat, 
               control=gamlss.control(n.cyc=5000, trace=TRUE))
#> GAMLSS-RS iteration 1: Global Deviance = 199.8282 
#> GAMLSS-RS iteration 2: Global Deviance = 199.6176 
#> GAMLSS-RS iteration 3: Global Deviance = 199.5719 
#> GAMLSS-RS iteration 4: Global Deviance = 199.562 
#> GAMLSS-RS iteration 5: Global Deviance = 199.5595 
#> GAMLSS-RS iteration 6: Global Deviance = 199.5588 

summary(mod2)
#> Warning: summary: vcov has failed, option qr is used instead
#> ******************************************************************
#> Family:  c("WALD", "Wald") 
#> 
#> Call:  gamlss(formula = y ~ x1, sigma.formula = ~x2, family = WALD,  
#>     data = dat, control = gamlss.control(n.cyc = 5000, trace = TRUE)) 
#> 
#> Fitting method: RS() 
#> 
#> ------------------------------------------------------------------
#> Mu link function:  log
#> Mu Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  0.81739    0.09694   8.432 7.01e-15 ***
#> x1          -0.75479    0.20361  -3.707 0.000272 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ------------------------------------------------------------------
#> Sigma link function:  log
#> Sigma Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  0.44505    0.06755   6.589 3.92e-10 ***
#> x2          -0.56665    0.11428  -4.959 1.52e-06 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ------------------------------------------------------------------
#> No. of observations in the fit:  200 
#> Degrees of Freedom for the fit:  4
#>       Residual Deg. of Freedom:  196 
#>                       at cycle:  6 
#>  
#> Global Deviance:     199.5588 
#>             AIC:     207.5588 
#>             SBC:     220.752 
#> ******************************************************************