#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2003-05-19 10:41 PDT by <hastie@rgmiller>.
# Source directory was `/vol5/hastie/docs/brad/LARS'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   2312 -rw-rw-r-- .Data/.Help/coef.lars
#   1397 -rw-rw-r-- .Data/.Help/cv.lars
#   2078 -rw-rw-r-- .Data/.Help/lars
#   1714 -rw-rw-r-- .Data/.Help/plot.lars
#   2312 -rw-rw-r-- .Data/.Help/predict.lars
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh3707955; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= .Data/.Help/coef.lars ==============
if test ! -d '.Data'; then
  $echo 'x -' 'creating directory' '.Data'
  mkdir '.Data'
fi
if test ! -d '.Data/.Help'; then
  $echo 'x -' 'creating directory' '.Data/.Help'
  mkdir '.Data/.Help'
fi
if test -f '.Data/.Help/coef.lars' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.Data/.Help/coef.lars' '(file already exists)'
else
  $echo 'x -' extracting '.Data/.Help/coef.lars' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.Data/.Help/coef.lars' &&
X.BG
X.FN predict.lars, coef.lars
X.TL
Make predictions or extract coefficients from a fitted lars model
X.DN
While lars() produces the entire path of solutions, predict.lars
allows one to extract a prediction at a particular point along the path.
X.CS
predict.lars(object, newx, s, type=c("fit", "coefficients"), mode=c("step", "fraction", "norm"))
coef.lars(object, s,  mode=c("step", "fraction", "norm"))
X.RA
X.AG object
A fitted lars object
X.AG newx
If type="fit", then newx should be the x values at which the fit is
required. If type="coefficients", then newx can be omitted.
X.AG s
a value, or vector of values, indexing the path. Its values depends on the mode= argument. By
default (mode="step"), s should take on values between 0 and p (e.g.,
a step of 1.3 means .3 of the way between step 1 and 2.
(number of variables).
X.OA
X.AG type
If type="fit", predict returns the fitted values. If
type="coefficients", predict returns the coefficients.
Abbreviations allowed.
X.AG mode
Mode="step" means the s= argument indexes the lars step number, and
the coefficients will be returned corresponding to the values
corresponding to step s. If mode="fraction", then s should be a number
between 0 and 1, and it refers to the ratio of the L1 norm of the
coefficient vector, relative to the norm at the full LS solution.
Mode="norm" means s refers to the L1 norm of the coefficient vector.
Abbreviations allowed.
X.RT
Either a vector/matrix of fitted values, or a vector/matrix of coefficients.
X.DT
LARS is described in detail in Efron, Hastie, Johnstone and Tibshirani
(2002). With the "lasso" option, it computes the complete lasso
solution simultaneously for ALL values of the shrinkage parameter in
the same computational cost as a least squares fit.
X.SH REFERENCES
Efron, Hastie, Johnstone and Tibshirani (2002)
Hastie, Tibshirani and Friedman (2002) Elements of Statistical
Learning, Springer, NY.
X.SA
print, plot, coef, predict, lars
X.EX
object <- lars(x,y,type=lasso)
### make predictions at the values in xtest, at each of the steps
produced in object
fits <- predict.lars(object, xtest, type="fit")
### extract the coefficient vector with L1 norm=4.1
coef3 <- coef(object, s=4.1, mode="norm")
### or
coef3<-predict(object, s=4.1, type="coef", mode="norm")
X.KW Lasso, Least Angle Regression, Forward Stagewise
X.WR
SHAR_EOF
  (set 20 03 05 12 21 38 27 '.Data/.Help/coef.lars'; eval "$shar_touch") &&
  chmod 0664 '.Data/.Help/coef.lars' ||
  $echo 'restore of' '.Data/.Help/coef.lars' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.Data/.Help/coef.lars:' 'MD5 check failed'
4b23892f59e3627e18ac923c3d371b62  .Data/.Help/coef.lars
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.Data/.Help/coef.lars'`"
    test 2312 -eq "$shar_count" ||
    $echo '.Data/.Help/coef.lars:' 'original size' '2312,' 'current size' "$shar_count!"
  fi
fi
# ============= .Data/.Help/cv.lars ==============
if test -f '.Data/.Help/cv.lars' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.Data/.Help/cv.lars' '(file already exists)'
else
  $echo 'x -' extracting '.Data/.Help/cv.lars' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.Data/.Help/cv.lars' &&
X.BG
X.FN cv.lars
X.TL
Computes K-fold cross-validated error curve for lars
X.DN
Computes the K-fold cross-validated mean squared prediction error for
lars, lasso, or forward stagewise.
X.CS
cv.lars(x, y, folds=10, fraction=seq(from = 0, to = 1, length = 100), trace=F, plot.it=T, se=T, ...)
X.RA
X.AG x
Input to lars
X.AG y
Input to lars
X.OA
X.AG folds
Number of folds
X.AG fraction
Abscissa values at which CV curve should be computed,
X      as a fraction of the saturated |beta|. Default is seq(from = 0, to = 1, length = 100)
X.AG trace
Show Computations?
X.AG plot.it
Plot it?
X.AG se
Include standard error bands?
X.AG ...
Additional arguments to lars
X.RT
Invisibly returns a list with components (which can be plotted using
plot.cv.lars
X.AG fraction
See above
X.AG cv
The CV curve at each value of fraction
X.AG cv.error
The standard error of the CV curve
X.SE
A plot is produced
X.DT
The inputs are randonly divided into K groups. With each group left
out, the lars model is fit to the remaining data, and then used to
predict the left out group at every stage. The NS prediction error is
recorded.
Finally these are all averaged as a function of coefficient norm, and
result in the CV curve.
X.SH REFERENCES
Efron, Hastie, Johnstone and Tibshirani (2003), "Least Angle
Regression", Annals of Statistics (with discussion).
X.SA
lars, predict.lars, plot.lars
X.EX
cv.lars(x,y)
X.KW  Lasso, Forward Stagewise
X.WR
SHAR_EOF
  (set 20 03 05 12 21 38 27 '.Data/.Help/cv.lars'; eval "$shar_touch") &&
  chmod 0664 '.Data/.Help/cv.lars' ||
  $echo 'restore of' '.Data/.Help/cv.lars' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.Data/.Help/cv.lars:' 'MD5 check failed'
48a0b19f5bc722740d5a78e25524749b  .Data/.Help/cv.lars
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.Data/.Help/cv.lars'`"
    test 1397 -eq "$shar_count" ||
    $echo '.Data/.Help/cv.lars:' 'original size' '1397,' 'current size' "$shar_count!"
  fi
fi
# ============= .Data/.Help/lars ==============
if test -f '.Data/.Help/lars' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.Data/.Help/lars' '(file already exists)'
else
  $echo 'x -' extracting '.Data/.Help/lars' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.Data/.Help/lars' &&
X.BG
X.FN lars
X.TL
Fits Least Angle Regression, Lasso and Infinitesimal Forward Stagewise regression models
X.DN
These are all variants of Lasso, and provide the entire sequence of
coefficients and fits, starting from zero, to the least squares fit.
X.CS
lars(x, y, type=c("lasso", "lar", "forward.stagewise"))
X.RA
X.AG x
matrix of predictors
X.AG y
response 
X.AG type
One of  "lasso", "lar"  or "forward.stagewise". The names can be abbreviated to any unique
substring. Default is "lasso".
X.AG trace
If TRUE, lars prints out its progress
X.OA
X.AG Gram
The X'X matrix; useful for repeated runs (bootstrap) where a large X'X
stays the same.
X.AG eps
An effective zero
X.AG max.steps
X  Limit the number of steps taken; the default is 8 * min(m,
X    n-1), with m the number of variables, and n the number of samples.
X  For type="lar", the maximum number of steps is
X  min(m,n-1). For type="lasso" and especially
X type="forward.stagewise", there can be many more terms, because
X  although no more than min(m,n-1) variables can be active during
X  any step, variables are frequently droppped and added as the algorithm
X  proceeds. Although the default usually guarantees that the algorithm
X  has proceeded to the saturated fit, users should check.
X.AG use.Gram
When the number m of variables is very large, i.e. larger than N, then
you may not want LARS to precompute the Gram matrix. Default is use.Gram=T
X.RT
A "lars" object is returned, for which print, plot and predict
methods exist.
X.DT
LARS is described in detail in Efron, Hastie, Johnstone and Tibshirani
(2002). With the "lasso" option, it computes the complete lasso
solution simultaneously for ALL values of the shrinkage parameter in
the same computational cost as a least squares fit.
X.SH REFERENCES
Efron, Hastie, Johnstone and Tibshirani (2003), "Least Angle
Regression", Annals of Statistics (with discussion).
Hastie, Tibshirani and Friedman (2002) Elements of Statistical
Learning, Springer, NY.
X.SA
print, plot, and predict methods for lars
X.EX
object <- lars(x,y,type=lasso)
plot(object)
X.KW Lasso, Forward Stagewise
X.WR
X
SHAR_EOF
  (set 20 03 05 13 10 13 01 '.Data/.Help/lars'; eval "$shar_touch") &&
  chmod 0664 '.Data/.Help/lars' ||
  $echo 'restore of' '.Data/.Help/lars' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.Data/.Help/lars:' 'MD5 check failed'
a248e5da7f37bc536d90e0bbb7c1bfe2  .Data/.Help/lars
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.Data/.Help/lars'`"
    test 2078 -eq "$shar_count" ||
    $echo '.Data/.Help/lars:' 'original size' '2078,' 'current size' "$shar_count!"
  fi
fi
# ============= .Data/.Help/plot.lars ==============
if test -f '.Data/.Help/plot.lars' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.Data/.Help/plot.lars' '(file already exists)'
else
  $echo 'x -' extracting '.Data/.Help/plot.lars' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.Data/.Help/plot.lars' &&
X.BG
X.FN plot.lars
X.TL
Plot a lars object
path.
X.DN
Produce a plot of a lars fit. The default is a complete coefficient
X.CS
plot.lars(object, xvar=c("norm", "df", "arc.length"), breaks=T, plottype=c("coefficients", "Cp"))
X.RA
X.AG object
fitted lars object
X.OA
X.AG xvar
The type of x variable against which to plot. xvar=norm plots against
the L1 norm of the coefficient vector (default). xvar=df plots against the step
number (which is essentially degrees of freedom for LAR (not for LASSO
or Forward Stagewise). xvar=arc.length plots against the arc.length of
the fitted vector;  this is useful for a LAR object, because the L1
norm of its coefficient vector need not be monotone in the steps.
X.AG breaks
If TRUE, then vertical lines are drawn at each break point in the
piecewise linear coefficient paths.
X.AG plottype
Either coefficients (default) or Cp. The
X      coefficient plot shows the path of each coefficient as a function
X      of the norm fraction or Df. The Cp plot shows the Cp curve.
X.AG omit.zeros
When the number of variables  is much greater than
X    the number of observations, many coefficients will never be nonzero;
X      this logical (default TRUE) avoids plotting these zero coefficents
X.AG eps
Definition of zero for the above argument; default is 1e-10.
X.AG ...
Additional arguments for generic plot. Can be used to set xlims, change line
widths, colors etc.
X.SH REFERENCES
Efron, Hastie, Johnstone and Tibshirani (2003), "Least Angle
Regression", Annals of Statistics (with discussion).
Hastie, Tibshirani and Friedman (2002) Elements of Statistical
Learning, Springer, NY.
X.SA
lars, cv.lars, predict.lars
X.EX
object <- lars(x,y,type=lasso)
plot(object)
X.KW Lasso, Forward Stagewise
X.WR
SHAR_EOF
  (set 20 03 05 12 21 38 27 '.Data/.Help/plot.lars'; eval "$shar_touch") &&
  chmod 0664 '.Data/.Help/plot.lars' ||
  $echo 'restore of' '.Data/.Help/plot.lars' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.Data/.Help/plot.lars:' 'MD5 check failed'
8cdb43e932ae2e283fa031e38301f133  .Data/.Help/plot.lars
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.Data/.Help/plot.lars'`"
    test 1714 -eq "$shar_count" ||
    $echo '.Data/.Help/plot.lars:' 'original size' '1714,' 'current size' "$shar_count!"
  fi
fi
# ============= .Data/.Help/predict.lars ==============
if test -f '.Data/.Help/predict.lars' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING '.Data/.Help/predict.lars' '(file already exists)'
else
  $echo 'x -' extracting '.Data/.Help/predict.lars' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > '.Data/.Help/predict.lars' &&
X.BG
X.FN predict.lars, coef.lars
X.TL
Make predictions or extract coefficients from a fitted lars model
X.DN
While lars() produces the entire path of solutions, predict.lars
allows one to extract a prediction at a particular point along the path.
X.CS
predict.lars(object, newx, s, type=c("fit", "coefficients"), mode=c("step", "fraction", "norm"))
coef.lars(object, s,  mode=c("step", "fraction", "norm"))
X.RA
X.AG object
A fitted lars object
X.AG newx
If type="fit", then newx should be the x values at which the fit is
required. If type="coefficients", then newx can be omitted.
X.AG s
a value, or vector of values, indexing the path. Its values depends on the mode= argument. By
default (mode="step"), s should take on values between 0 and p (e.g.,
a step of 1.3 means .3 of the way between step 1 and 2.
(number of variables).
X.OA
X.AG type
If type="fit", predict returns the fitted values. If
type="coefficients", predict returns the coefficients.
Abbreviations allowed.
X.AG mode
Mode="step" means the s= argument indexes the lars step number, and
the coefficients will be returned corresponding to the values
corresponding to step s. If mode="fraction", then s should be a number
between 0 and 1, and it refers to the ratio of the L1 norm of the
coefficient vector, relative to the norm at the full LS solution.
Mode="norm" means s refers to the L1 norm of the coefficient vector.
Abbreviations allowed.
X.RT
Either a vector/matrix of fitted values, or a vector/matrix of coefficients.
X.DT
LARS is described in detail in Efron, Hastie, Johnstone and Tibshirani
(2002). With the "lasso" option, it computes the complete lasso
solution simultaneously for ALL values of the shrinkage parameter in
the same computational cost as a least squares fit.
X.SH REFERENCES
Efron, Hastie, Johnstone and Tibshirani (2002)
Hastie, Tibshirani and Friedman (2002) Elements of Statistical
Learning, Springer, NY.
X.SA
print, plot, coef, predict, lars
X.EX
object <- lars(x,y,type=lasso)
### make predictions at the values in xtest, at each of the steps
produced in object
fits <- predict.lars(object, xtest, type="fit")
### extract the coefficient vector with L1 norm=4.1
coef3 <- coef(object, s=4.1, mode="norm")
### or
coef3<-predict(object, s=4.1, type="coef", mode="norm")
X.KW Lasso, Least Angle Regression, Forward Stagewise
X.WR
SHAR_EOF
  (set 20 03 05 12 21 38 27 '.Data/.Help/predict.lars'; eval "$shar_touch") &&
  chmod 0664 '.Data/.Help/predict.lars' ||
  $echo 'restore of' '.Data/.Help/predict.lars' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo '.Data/.Help/predict.lars:' 'MD5 check failed'
4b23892f59e3627e18ac923c3d371b62  .Data/.Help/predict.lars
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.Data/.Help/predict.lars'`"
    test 2312 -eq "$shar_count" ||
    $echo '.Data/.Help/predict.lars:' 'original size' '2312,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh3707955
exit 0
