ACE {refreg}R Documentation

Alternating Conditional Expectation (ACE) algorithm

Description

This function implements Alternating Conditional Expectation algorithm (ACE, Hastie and Tibshirani, 1990). This is a bivRegr's inner function for estimating variance, and correlation models.

Usage

ACE(
  y = "y",
  predictor = "~s(x)",
  restriction = "positive",
  eps = 0.01,
  itmax = 10,
  data = data,
  ...
)

Arguments

y

A character defining the response variable.

predictor

The regression predictor, following the mgcv package structure (see example below).

restriction

Type of restriction to be imposed to the response variable, "positive" for variance, and "correlation" for the correlation.

eps

A number defining the allowed estimation error, default = 0.01.

itmax

Maximum number of iterations of the algorithm, default = 10.

data

A data frame containing the response, and predictor variables.

...

Additional mgcv::gam() parameters to be modified by the user.

Value

This function returns a mgcv::gam() fit for a transformed response.

References

Hastie, T. & Tibshirani, J. (1990) Generalized additive models. CRC press. London.

Examples

n <- 100
x <- runif(n, -1, 1)
y <- x^2 + rnorm(n, sd = 0.1)
df <- data.frame(y, x)
plot(df$x, df$y)
m1 <- ACE(
  y = "y", predictor = "~s(x)", restriction = "positive",
  eps = 0.01, itmax = 10, data = df
)$fit
nw <- data.frame(x = seq(-1, 1, 0.1))
abline(h = 0, col = 2)
lines(exp(predict(m1, newdata = nw)) ~ nw$x, col = 3, lwd = 2)
legend("top", legend = c("ACE fit", "Zero"), lty = 1, lwd = 2, col = c(3, 2), bty = "n")

[Package refreg version 0.1.1 Index]