sm: Scale Model

View source: R/scaler.R

smR Documentation

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, ...)

## Default S3 method:
sm(object, formula = NULL, data = NULL,
  parameters = NULL, ...)

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

## S3 method for class '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.

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.

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

Examples


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)


config-i1/greybox documentation built on Dec. 12, 2024, 1:42 p.m.