Description Usage Arguments Value Author(s) See Also Examples

Extract coefficients from a sequence of regression models, such as submodels along a robust or groupwise least angle regression sequence, or sparse least trimmed squares regression models for a grid of values for the penalty parameter.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
## S3 method for class 'seqModel'
coef(object, s = NA, zeros = TRUE, drop = !is.null(s), ...)
## S3 method for class 'tslars'
coef(object, p, ...)
## S3 method for class 'perrySeqModel'
coef(object, ...)
## S3 method for class 'sparseLTS'
coef(
object,
s = NA,
fit = c("reweighted", "raw", "both"),
zeros = TRUE,
drop = !is.null(s),
...
)
``` |

`object` |
the model fit from which to extract coefficients. |

`s` |
for the |

`zeros` |
a logical indicating whether to keep zero coefficients
( |

`drop` |
a logical indicating whether to reduce the dimension to a vector in case of only one submodel. |

`...` |
for the |

`p` |
an integer giving the lag length for which to extract coefficients (the default is to use the optimal lag length). |

`fit` |
a character string specifying which coefficients to extract.
Possible values are |

A numeric vector or matrix containing the requested regression coefficients.

Andreas Alfons

`coef`

, `rlars`

,
`grplars`

, `rgrplars`

, `tslarsP`

,
`rtslarsP`

, `tslars`

, `rtslars`

,
`sparseLTS`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ```
## generate data
# example is not high-dimensional to keep computation time low
library("mvtnorm")
set.seed(1234) # for reproducibility
n <- 100 # number of observations
p <- 25 # number of variables
beta <- rep.int(c(1, 0), c(5, p-5)) # coefficients
sigma <- 0.5 # controls signal-to-noise ratio
epsilon <- 0.1 # contamination level
Sigma <- 0.5^t(sapply(1:p, function(i, j) abs(i-j), 1:p))
x <- rmvnorm(n, sigma=Sigma) # predictor matrix
e <- rnorm(n) # error terms
i <- 1:ceiling(epsilon*n) # observations to be contaminated
e[i] <- e[i] + 5 # vertical outliers
y <- c(x %*% beta + sigma * e) # response
x[i,] <- x[i,] + 5 # bad leverage points
## robust LARS
# fit model
fitRlars <- rlars(x, y, sMax = 10)
# extract coefficients
coef(fitRlars, zeros = FALSE)
coef(fitRlars, s = 1:5, zeros = FALSE)
## sparse LTS over a grid of values for lambda
# fit model
frac <- seq(0.2, 0.05, by = -0.05)
fitSparseLTS <- sparseLTS(x, y, lambda = frac, mode = "fraction")
# extract coefficients
coef(fitSparseLTS, zeros = FALSE)
coef(fitSparseLTS, fit = "both", zeros = FALSE)
coef(fitSparseLTS, s = NULL, zeros = FALSE)
coef(fitSparseLTS, fit = "both", s = NULL, zeros = FALSE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.