sn.mle {sn} | R Documentation |
Fits a skew-normal (SN) distribution to data, or fits a linear regression model with skew-normal errors, using maximum likelihood estimation.
sn.mle <- function(X, y, cp, plotit=T, trace=F, control=list(iter.max=100, abs.tol=1e-5))
y |
a vector contaning the observed variable. This is the response
variable in case of linear regression.
Missing values (NA s) are not allowed.
|
X |
a matrix of explanatory variables. If X is missing, then a one-column
matrix of all 1's is created. If X is supplied, and an intercept term
is required, then it must include a column of 1's.
Missing values (NA s) are not allowed.
|
cp |
a vector of initial values for the centred parameters,
with length(cp)=ncol(X)+2
|
plotit |
logical value, If plotit=T (default) and a graphical device is active,
a plot of the nonparametric estimate of variable y (or the residuals,
in the case of regression), and the parametric fit is superimposed.
See below for details.
|
trace |
logical value which controls printing of the algorithm convergence.
If trace=T , details are printed. Default value is F .
|
control |
this parameter is jusr passed to the optimizer optim ;
see the documentation of this function for its usage.
|
The optimizer optim
is used, supplying the gradient of the log-likelihood.
Convergence is generally fast and reliable, but inspection of
the returned message
from optim
is always appropriate.
In suspect cases, re-run the function changing the starting cp
vector.
If plotting operates, the function sm.density
of the library sm
is searched; this library is associated with the book by Bowman and
Azzalini (1997). If sm.density
is not found, an histogram is plotted.
a list containing the following components:
call |
a string containing the calling statement |
cp |
a vector of length ncol(X)+2 with the centred parameters
|
logL |
the log-likelihood at convergence |
se |
a vector of standard errors for the cp component
|
info |
the observed information matrix for the cp component
|
optim |
the list returned by the optimizer optim ; see the documentation
of this function for explanation of its components.
|
If plotit=T
and a graphical device is active, a plot is produced,
as described above.
Background information on the SN distribution is given by Azzalini (1985). See Azzalini and Capitanio (1999) for a more detailed discussion of the centred parametrization.
Azzalini, A. (1985). A class of distributions which includes the normal ones. Scand. J. Statist. 12, 171-178.
Azzalini, A. and Capitanio, A. (1999). Statistical applications of the multivariate skew-normal distribution. J.Roy.Statist.Soc. B 61, 579602.
Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.
data(ais,package=sn) attach(ais) a<-sn.mle(y=bmi) # a<-sn.mle(X=cbind(1,lbm,lbm^2),y=bmi) # M<-model.matrix(~lbm+I(ais$sex)) b<-sn.mle(M,bmi)