Learn R Programming

greybox (version 0.3.0)

alm: Advanced Linear Model

Description

Function estimates model based on the selected distribution

Usage

alm(formula, data, subset = NULL, na.action, distribution = c("laplace",
  "s", "fnorm", "chisq"))

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

a data frame or a matrix, containing the variables in the model.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset. The factory-fresh default is na.omit. Another possible value is NULL, no action. Value na.exclude can be useful.

distribution

What density function to use in the process.

Value

Function returns model - the final model of the class "alm".

Details

This is a function, similar to lm, but for the cases of several non-normal distributions. These include:

  1. Laplace distribution, dlaplace,

  2. S-distribution, ds,

  3. Folded-normal distribution, dfnorm,

  4. Chi-Squared Distribution, dchisq.

Probably some other distributions will be added to this function at some point...

The estimation is done using likelihood of respective distributions.

See Also

stepwise, lmCombine

Examples

Run this code
# NOT RUN {
xreg <- cbind(rlaplace(100,10,3),rnorm(100,50,5))
xreg <- cbind(100+0.5*xreg[,1]-0.75*xreg[,2]+rlaplace(100,0,3),xreg,rnorm(100,300,10))
colnames(xreg) <- c("y","x1","x2","Noise")
inSample <- xreg[1:80,]
outSample <- xreg[-c(1:80),]
# Combine all the possible models
ourModel <- alm(y~x1+x2, inSample, distribution="laplace")
summary(ourModel)
plot(forecast(ourModel,outSample))

# }

Run the code above in your browser using DataLab