Learn R Programming

greybox (version 2.0.2)

sm: Scale Model

Description

This method produces a model for scale of distribution for the provided pre-estimated model. The model can be estimated either via lm or alm.

Usage

sm(object, ...)

# S3 method for default sm(object, formula = NULL, data = NULL, parameters = NULL, ...)

# S3 method for lm sm(object, formula = NULL, data = NULL, parameters = NULL, ...)

# S3 method for alm sm(object, formula = NULL, data = NULL, parameters = NULL, ...)

Arguments

object

The pre-estimated alm or lm model.

...

Other parameters to pass to the method, including those explained in alm (e.g. parameters for optimiser).

formula

The formula for scale. It should start with ~ and contain all variables that should impact the scale.

data

The data, on which the scale model needs to be estimated. If not provided, then the one used in the object is used.

parameters

The parameters to use in the model. Only needed if you know the parameters in advance or want to test yours.

Author

Ivan Svetunkov, ivan@svetunkov.ru

Details

This function is useful, when you suspect a heteroscedasticity in your model and want to fit a model for the scale of the pre-specified distribution. This function is complementary for lm or alm.

Examples

Run this code

xreg <- cbind(rnorm(100,10,3),rnorm(100,50,5))
xreg <- cbind(100+0.5*xreg[,1]-0.75*xreg[,2]+sqrt(exp(0.8+0.2*xreg[,1]))*rnorm(100,0,1),
              xreg,rnorm(100,300,10))
colnames(xreg) <- c("y","x1","x2","Noise")

# Estimate the location model
ourModel <- alm(y~.,xreg)
# Estimate the scale model
ourScale <- sm(ourModel,formula=~x1+x2)
# Summary of the scale model
summary(ourScale)

Run the code above in your browser using DataLab