sm | R Documentation |
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
.
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,
...)
object |
The pre-estimated |
... |
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 |
parameters |
The parameters to use in the model. Only needed if you know the parameters in advance or want to test yours. |
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
.
Ivan Svetunkov, ivan@svetunkov.com
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.