powerlink: Power Link Function

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

View source: R/linksold.R View source: R/links.q

Description

Computes the power transformation, including its inverse and the first two derivatives.

Usage

1
2
powerlink(theta, power = 1, inverse = FALSE, deriv = 0,
          short = TRUE, tag = FALSE)

Arguments

theta

Numeric or character. See below for further details.

power

This denotes the power or exponent.

inverse, deriv, short, tag

Details at Links.

Details

The power link function raises a parameter by a certain value of power. Care is needed because it is very easy to get numerical problems, e.g., if power=0.5 and theta is negative.

Value

For powerlink with deriv = 0, then theta raised to the power of power. And if inverse = TRUE then theta raised to the power of 1/power.

For deriv = 1, then the function returns d theta / d eta as a function of theta if inverse = FALSE, else if inverse = TRUE then it returns the reciprocal.

Note

Numerical problems may occur for certain combinations of theta and power. Consequently this link function should be used with caution.

Author(s)

Thomas W. Yee

See Also

Links, loglink.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
powerlink("a", power = 2, short = FALSE, tag = TRUE)
powerlink(x <- 1:5)
powerlink(x, power = 2)
max(abs(powerlink(powerlink(x, power = 2),
                  power = 2, inverse = TRUE) - x))  # Should be 0
powerlink(x <- (-5):5, power = 0.5)  # Has NAs

# 1/2 = 0.5
pdata <- data.frame(y = rbeta(n = 1000, shape1 = 2^2, shape2 = 3^2))
fit <- vglm(y ~ 1, betaR(lshape1 = powerlink(power = 0.5), i1 = 3,
                         lshape2 = powerlink(power = 0.5), i2 = 7), data = pdata)
t(coef(fit, matrix = TRUE))
Coef(fit)  # Useful for intercept-only models
vcov(fit, untransform = TRUE)

Example output

Loading required package: stats4
Loading required package: splines
[1] "Power link: a^(2)"
[1] 1 2 3 4 5
[1]  1  4  9 16 25
[1] 0
 [1]      NaN      NaN      NaN      NaN      NaN 0.000000 1.000000 1.414214
 [9] 1.732051 2.000000 2.236068
                               (Intercept)
powerlink(shape1, power = 0.5)    1.989788
powerlink(shape2, power = 0.5)    3.021689
  shape1   shape2 
3.959256 9.130606 
           shape1     shape2
shape1 0.02910633 0.06356669
shape2 0.06356669 0.16633633

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