lms.yjn: LMS Quantile Regression with a Yeo-Johnson Transformation to...

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

View source: R/family.qreg.R

Description

LMS quantile regression with the Yeo-Johnson transformation to normality. This family function is experimental and the LMS-BCN family function is recommended instead.

Usage

1
2
3
4
5
6
7
8
9
lms.yjn(percentiles = c(25, 50, 75), zero = c("lambda", "sigma"),
        llambda = "identitylink", lsigma = "loglink",
        idf.mu = 4, idf.sigma = 2,
        ilambda = 1, isigma = NULL, rule = c(10, 5),
        yoffset = NULL, diagW = FALSE, iters.diagW = 6)
lms.yjn2(percentiles = c(25, 50, 75), zero = c("lambda", "sigma"),
         llambda = "identitylink", lmu = "identitylink", lsigma = "loglink",
         idf.mu = 4, idf.sigma = 2, ilambda = 1.0,
         isigma = NULL, yoffset = NULL, nsimEIM = 250)

Arguments

percentiles

A numerical vector containing values between 0 and 100, which are the quantiles. They will be returned as ‘fitted values’.

zero

See lms.bcn.

llambda, lmu, lsigma

See lms.bcn.

idf.mu, idf.sigma

See lms.bcn.

ilambda, isigma

See lms.bcn.

rule

Number of abscissae used in the Gaussian integration scheme to work out elements of the weight matrices. The values given are the possible choices, with the first value being the default. The larger the value, the more accurate the approximation is likely to be but involving more computational expense.

yoffset

A value to be added to the response y, for the purpose of centering the response before fitting the model to the data. The default value, NULL, means -median(y) is used, so that the response actually used has median zero. The yoffset is saved on the object and used during prediction.

diagW

Logical. This argument is offered because the expected information matrix may not be positive-definite. Using the diagonal elements of this matrix results in a higher chance of it being positive-definite, however convergence will be very slow. If TRUE, then the first iters.diagW iterations will use the diagonal of the expected information matrix. The default is FALSE, meaning faster convergence.

iters.diagW

Integer. Number of iterations in which the diagonal elements of the expected information matrix are used. Only used if diagW = TRUE.

nsimEIM

See CommonVGAMffArguments for more information.

Details

Given a value of the covariate, this function applies a Yeo-Johnson transformation to the response to best obtain normality. The parameters chosen to do this are estimated by maximum likelihood or penalized maximum likelihood. The function lms.yjn2() estimates the expected information matrices using simulation (and is consequently slower) while lms.yjn() uses numerical integration. Try the other if one function fails.

Value

An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Warning

The computations are not simple, therefore convergence may fail. In that case, try different starting values.

The generic function predict, when applied to a lms.yjn fit, does not add back the yoffset value.

As described above, this family function is experimental and the LMS-BCN family function is recommended instead.

Note

The response may contain both positive and negative values. In contrast, the LMS-Box-Cox-normal and LMS-Box-Cox-gamma methods only handle a positive response because the Box-Cox transformation cannot handle negative values.

Some other notes can be found at lms.bcn.

Author(s)

Thomas W. Yee

References

Yeo, I.-K. and Johnson, R. A. (2000). A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954–959.

Yee, T. W. (2004). Quantile regression via vector generalized additive models. Statistics in Medicine, 23, 2295–2315.

Yee, T. W. (2002). An Implementation for Regression Quantile Estimation. Pages 3–14. In: Haerdle, W. and Ronz, B., Proceedings in Computational Statistics COMPSTAT 2002. Heidelberg: Physica-Verlag.

See Also

lms.bcn, lms.bcg, qtplot.lmscreg, deplot.lmscreg, cdf.lmscreg, bmi.nz, amlnormal.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
fit <- vgam(BMI ~ s(age, df = 4), lms.yjn, bmi.nz, trace = TRUE)
head(predict(fit))
head(fitted(fit))
head(bmi.nz)
# Person 1 is near the lower quartile of BMI amongst people his age
head(cdf(fit))

## Not run: 
# Quantile plot
par(bty = "l", mar = c(5, 4, 4, 3) + 0.1, xpd = TRUE)
qtplot(fit, percentiles = c(5, 50, 90, 99), main = "Quantiles",
       xlim = c(15, 90), las = 1, ylab = "BMI", lwd = 2, lcol = 4)

# Density plot
ygrid <- seq(15, 43, len = 100)  # BMI ranges
par(mfrow = c(1, 1), lwd = 2)
(aa <- deplot(fit, x0 = 20, y = ygrid, xlab = "BMI", col = "black",
    main = "Density functions at Age = 20 (black), 42 (red) and 55 (blue)"))
aa <- deplot(fit, x0 = 42, y = ygrid, add = TRUE, llty = 2, col = "red")
aa <- deplot(fit, x0 = 55, y = ygrid, add = TRUE, llty = 4, col = "blue",
             Attach = TRUE)
with(aa@post, deplot)  # Contains density function values; == a@post$deplot

## End(Not run)

Example output

Loading required package: stats4
Loading required package: splines
VGAM  s.vam  loop  1 :  loglikelihood = -1361.2243
VGAM  s.vam  loop  2 :  loglikelihood = -1357.5289
VGAM  s.vam  loop  3 :  loglikelihood = -1357.3829
VGAM  s.vam  loop  4 :  loglikelihood = -1357.3542
VGAM  s.vam  loop  5 :  loglikelihood = -1357.3539
VGAM  s.vam  loop  6 :  loglikelihood = -1357.3519
VGAM  s.vam  loop  7 :  loglikelihood = -1357.3521
VGAM  s.vam  loop  8 :  loglikelihood = -1357.3519
VGAM  s.vam  loop  9 :  loglikelihood = -1357.3519
     lambda          mu loge(sigma)
1 0.8078551 -0.77249525    1.422234
2 0.8078551 -0.05619456    1.422234
3 0.8078551  0.42445223    1.422234
4 0.8078551 -0.50654859    1.422234
5 0.8078551  0.90505962    1.422234
6 0.8078551 -0.07976647    1.422234
       25%      50%      75%
1 23.07743 25.37026 28.41762
2 23.63333 26.04344 29.34193
3 24.01604 26.53978 29.98527
4 23.28199 25.61305 28.75568
5 24.40811 27.07187 30.64528
6 23.61477 26.02016 29.31084
       age      BMI
1 31.52966 22.77107
2 39.38045 27.70033
3 43.38940 28.18127
4 34.84894 25.08380
5 53.81990 26.46388
6 39.17002 36.19648
        1         2         3         4         5         6 
0.2201431 0.6410319 0.6331574 0.4435149 0.4470689 0.9646218 

Call:
vgam(formula = BMI ~ s(age, df = 4), family = lms.yjn, data = bmi.nz, 
    trace = TRUE)


Degrees of Freedom: 2100 Total; 2093.02 Residual
Log-likelihood: -1357.352 
$newdata
  age
1  55

$y
  [1] 15.00000 15.28283 15.56566 15.84848 16.13131 16.41414 16.69697 16.97980
  [9] 17.26263 17.54545 17.82828 18.11111 18.39394 18.67677 18.95960 19.24242
 [17] 19.52525 19.80808 20.09091 20.37374 20.65657 20.93939 21.22222 21.50505
 [25] 21.78788 22.07071 22.35354 22.63636 22.91919 23.20202 23.48485 23.76768
 [33] 24.05051 24.33333 24.61616 24.89899 25.18182 25.46465 25.74747 26.03030
 [41] 26.31313 26.59596 26.87879 27.16162 27.44444 27.72727 28.01010 28.29293
 [49] 28.57576 28.85859 29.14141 29.42424 29.70707 29.98990 30.27273 30.55556
 [57] 30.83838 31.12121 31.40404 31.68687 31.96970 32.25253 32.53535 32.81818
 [65] 33.10101 33.38384 33.66667 33.94949 34.23232 34.51515 34.79798 35.08081
 [73] 35.36364 35.64646 35.92929 36.21212 36.49495 36.77778 37.06061 37.34343
 [81] 37.62626 37.90909 38.19192 38.47475 38.75758 39.04040 39.32323 39.60606
 [89] 39.88889 40.17172 40.45455 40.73737 41.02020 41.30303 41.58586 41.86869
 [97] 42.15152 42.43434 42.71717 43.00000

$density
  [1] 6.016473e-05 9.202496e-05 1.387899e-04 2.064205e-04 3.027921e-04
  [6] 4.381150e-04 6.253736e-04 8.807553e-04 1.224031e-03 1.678840e-03
 [11] 2.272816e-03 3.037506e-03 4.008004e-03 5.222258e-03 6.720005e-03
 [16] 8.541311e-03 1.072474e-02 1.330516e-02 1.631133e-02 1.976335e-02
 [21] 2.367005e-02 2.802671e-02 3.281301e-02 3.799162e-02 4.350753e-02
 [26] 4.928807e-02 5.524401e-02 6.127141e-02 6.725434e-02 7.306824e-02
 [31] 7.858378e-02 8.367078e-02 8.820199e-02 9.205626e-02 9.512061e-02
 [36] 9.729036e-02 9.846654e-02 9.854819e-02 9.741528e-02 9.489061e-02
 [41] 9.146529e-02 8.860400e-02 8.606953e-02 8.370040e-02 8.140916e-02
 [46] 7.914642e-02 7.688418e-02 7.460723e-02 7.230839e-02 6.998567e-02
 [51] 6.764047e-02 6.527650e-02 6.289890e-02 6.051377e-02 5.812775e-02
 [56] 5.574772e-02 5.338061e-02 5.103322e-02 4.871211e-02 4.642352e-02
 [61] 4.417327e-02 4.196673e-02 3.980880e-02 3.770387e-02 3.565582e-02
 [66] 3.366801e-02 3.174329e-02 2.988402e-02 2.809207e-02 2.636884e-02
 [71] 2.471532e-02 2.313205e-02 2.161920e-02 2.017659e-02 1.880370e-02
 [76] 1.749972e-02 1.626356e-02 1.509391e-02 1.398922e-02 1.294780e-02
 [81] 1.196777e-02 1.104712e-02 1.018377e-02 9.375515e-03 8.620116e-03
 [86] 7.915282e-03 7.258699e-03 6.648048e-03 6.081016e-03 5.555312e-03
 [91] 5.068678e-03 4.618897e-03 4.203807e-03 3.821302e-03 3.469346e-03
 [96] 3.145969e-03 2.849281e-03 2.577468e-03 2.328795e-03 2.101612e-03

VGAM documentation built on Jan. 16, 2021, 5:21 p.m.