Title: | Heteroscedastic t-Regression |
---|---|
Description: | Functions for the fitting and summarizing of heteroscedastic t-regression. |
Authors: | Julian Taylor <[email protected]> |
Maintainer: | Julian Taylor <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3-3 |
Built: | 2024-11-10 06:32:09 UTC |
Source: | CRAN |
Data from the Martin Marietta company collected overa period of 5 years on a monthly basis
data(mm)
data(mm)
A data frame with 60 observations on the following 4 variables.
the month the data was collected
a numeric vector
excess returns from the Martin Marietta company
an index for the excess rate returns for the New York stock exchange
Bulter et al (1990). Robust and partly adpative estimation of regression models. Review of Economic Statistics, 72, 321-327.
data(mm, package = "hett") attach(mm) plot(CRSP, m.marietta) lines(CRSP, fitted(lm(m.marietta ~ CRSP)), lty = 2)
data(mm, package = "hett") attach(mm) plot(CRSP, m.marietta) lines(CRSP, fitted(lm(m.marietta ~ CRSP)), lty = 2)
Dataset collected in 1977 from Minnesota to study the variation in land rented for growing alfalfa
data(rent)
data(rent)
A data frame with 67 observations on the following 5 variables.
a numeric vector average rent per acre.
a numeric vector describing average rent paid for all tillable land.
a numeric vector describing the density of dairy cows (number per square mile).
a numeric vector describing the proportion of farmland used as pasture.
a factor with levels No
if no liming is
required to grow alfalfa and Yes
if it does.
Weisberg, S (1985). Applied Linear Regression Wiley: New York
library(lattice) data(rent, package = "hett") attach(rent) xyplot(log(Rent/AllRent) ~ sqrt(Cows), groups = Liming, panel = panel.superpose)
library(lattice) data(rent, package = "hett") attach(rent) xyplot(log(Rent/AllRent) ~ sqrt(Cows), groups = Liming, panel = panel.superpose)
Summarizes the heteroscedastic t regression object
## S3 method for class 'tlm' summary(object, correlation = FALSE, ...) ## S3 method for class 'summary.tlm' print(x, ...)
## S3 method for class 'tlm' summary(object, correlation = FALSE, ...) ## S3 method for class 'summary.tlm' print(x, ...)
object |
heteroscedastic t regression object called from |
x |
an object of class " |
correlation |
should the calaculation of the parameter correlation matrix be
supressed. If the fit includes a location and a scale formula then both
correlation matrices are printed. The default is |
... |
arguments passed to or from other methods |
The table summary produced by this function should be used with
caution. A more appropriate test between nested models is to use the
score statistic function tscore
.
a list containing the following components:
loc.summary |
an object containing a list of objects that summarize the location model |
scale.summary |
an object containing a list of objects that summarize the scale model |
iter |
the number of iterations of the algorithm |
dof |
value of the fixed or estimated degrees of freedom |
dofse |
the standard error associated with the degrees of freedom if estimated |
logLik |
the maximised log-likelihood |
method |
the method used to maximize the likelihood |
endTime |
the time taken for the algorithm to converge |
Julian Taylor
data(mm, package = "hett") attach(mm) ## fit a model with heteroscedasticity and estimating the degrees of freedom tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) summary(tfit2)
data(mm, package = "hett") attach(mm) ## fit a model with heteroscedasticity and estimating the degrees of freedom tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) summary(tfit2)
Fits a heteroscedastic t regression to given data for known and unknown degrees of freedom.
tlm(lform, sform = ~ 1, data = NULL, subset = NULL, contrasts = NULL, na.action = na.fail, start = NULL, control = tlm.control(...), obs = FALSE, estDof = FALSE, ... ) ## S3 method for class 'tlm' print(x, ...)
tlm(lform, sform = ~ 1, data = NULL, subset = NULL, contrasts = NULL, na.action = na.fail, start = NULL, control = tlm.control(...), obs = FALSE, estDof = FALSE, ... ) ## S3 method for class 'tlm' print(x, ...)
x |
an object of class " |
lform |
a formula of the type |
sform |
a formula of the type |
data |
the data in the form of a |
subset |
numerical vector to subset the |
contrasts |
set of contrasts for the location model (see |
na.action |
the action to proceed with in the event of |
start |
is a list of possibly four named components, (" |
control |
is an argument to a function that maintains the control of the
algorithm. The |
obs |
should the location parameters be calculated using the observed or
expected information(default = |
estDof |
should the degrees of freedom parameter be estimated or not. If |
... |
arguments passed to |
When the degrees of freedom is unknown the code uses the non-linear optimiser
nlm
. If the response (and therefore the errors) is tending toward
a Gaussian this optimisation will still converge but with with very high degrees of freedom.
To obtain the appropriate standard errors from summary
the user
must specify the argument obs = F
to ensure that the location
parameter is calculated using the expected information.
a list containing the following components:
loc.fit |
an object containing the estimated location parameters and other elements associated with the location parameter model |
scale.fit |
an object containing the estimated scale parameters and other elements associated with the scale parameter model |
random |
the random scale effects |
dof |
fixed or estimated degrees of freedom |
dofse |
the standard error associated with the degrees of freedom |
iter |
the number of iterations of the algorithm |
logLik |
the maximised log-likelihood |
endTime |
the time taken for the algorithm to converge |
The theoretical background for this function can be found in Taylor and Verbyla (2004).
Julian Taylor
Taylor, J. D. & Verbyla, A. P (2004). Joint modelling of the location and scale parameters of the t-distribution. Statistical Modelling 4, 91-112.
data(mm, package = "hett") attach(mm) ## fit a model with no heteroscedasticity and fixed degrees of freedom tfit <- tlm(m.marietta ~ CRSP, data = mm, start = list(dof = 3)) ## fit a model with heteroscedasticity and fixed degrees of freedom tfit1 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3)) ## fit a model with heteroscedasticity and estimating the degrees of freedom tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE)
data(mm, package = "hett") attach(mm) ## fit a model with no heteroscedasticity and fixed degrees of freedom tfit <- tlm(m.marietta ~ CRSP, data = mm, start = list(dof = 3)) ## fit a model with heteroscedasticity and fixed degrees of freedom tfit1 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3)) ## fit a model with heteroscedasticity and estimating the degrees of freedom tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE)
Auxiliary function for fitting tlm
model. Generally only used
when calling tlm
tlm.control(epsilon = 1e-07, maxit = 50, trace = FALSE, verboseLev = 1)
tlm.control(epsilon = 1e-07, maxit = 50, trace = FALSE, verboseLev = 1)
epsilon |
positive convergence tolerance value. The iterations converge when [newlik - oldlik] < epsilon/2 |
maxit |
integer giving the maximum iterations allowable for the routine |
trace |
logical. If |
verboseLev |
integer. If 1 then print according to |
A list with the argument as values
Julian Taylor
data(mm, package = "hett") attach(mm) ## change the maximum amount of iterations for the algorithm fit1 <- tlm(m.marietta ~ CRSP, ~ 1, data = mm, start = list(dof = 3), estDof = TRUE, control = tlm.control(maxit = 100))
data(mm, package = "hett") attach(mm) ## change the maximum amount of iterations for the algorithm fit1 <- tlm(m.marietta ~ CRSP, ~ 1, data = mm, start = list(dof = 3), estDof = TRUE, control = tlm.control(maxit = 100))
Provides a score test for the location and scale parameters of the heteroscedastic t regression model.
tscore(..., data = NULL, scale = FALSE)
tscore(..., data = NULL, scale = FALSE)
... |
Any number of arguments containing nested model fits from |
data |
the data used to fit the models involved |
scale |
logical. If |
The user must supply nested models that test, either, the scale or the location component of the model. The model objects must be nested from left to right. Currently there are no traps if the arguments are not given in this order.
The models must also have either, all fixed degrees of freedom or estimated degrees of freedom.
Output containing the hypothesis, the score statistic, degrees of freedom for the test and the p-value are printed to the screen.
Julian Taylor
Taylor, J. D. & Verbyla, A. P (2004). Joint modelling of the location and scale parameters of the t-distribution. Statistical Modelling 4, 91-112.
data(mm, package = "hett") attach(mm) tfit1 <- tlm(m.marietta ~ CRSP, ~ 1, data = mm, start = list(dof = 3), estDof = TRUE) tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) tscore(tfit1, tfit2, data = mm, scale = TRUE)
data(mm, package = "hett") attach(mm) tfit1 <- tlm(m.marietta ~ CRSP, ~ 1, data = mm, start = list(dof = 3), estDof = TRUE) tfit2 <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) tscore(tfit1, tfit2, data = mm, scale = TRUE)
Summarizes the location or scale components of a heteroscedastic t model
tsum(object, dispersion = NULL, correlation = FALSE, symbolic.cor = FALSE, ...) ## S3 method for class 'tsum' print(x, digits = max(3, getOption("digits") - 3), symbolic.cor = x$symbolic.cor, signif.stars = getOption("show.signif.stars"), scale = TRUE, ...)
tsum(object, dispersion = NULL, correlation = FALSE, symbolic.cor = FALSE, ...) ## S3 method for class 'tsum' print(x, digits = max(3, getOption("digits") - 3), symbolic.cor = x$symbolic.cor, signif.stars = getOption("show.signif.stars"), scale = TRUE, ...)
object |
either the location or scale object created by fitting
a heteroscedastic t object with |
x |
an object of class " |
dispersion |
1 if summarizing the location model; 2 if summarizing the scale model (see Details) |
correlation |
logical; if |
digits |
the number of significant digits to be printed. |
symbolic.cor |
logical. If |
signif.stars |
logical. if |
scale |
logical. If |
... |
further arguments passed to or from other methods. |
The argument supplied to dispersion
must be either 1
(location model) or 2 (scale model). The reason for this is because
the fitting of the model has already
scaled the covariance matrix for the location coefficients. Hence the
scaled and unscaled versions of covariance matrix for the location
model are identical.
This function will not be generally called by the user as it
will only summarize the location or scale model but not both. Instead
the user should refer to summary.tlm
to print a summary of both models.
tsum
returns an object of class "tsum
", a list
with components
call |
the component from |
df.residual |
the component from |
coefficients |
the matrix of coefficients, standard errors, z-values and p-values |
dispersion |
the supplied dispersion argument |
df |
a 2-vector of the rank of the model and the number of residual degrees of freedom |
cov.unscaled |
the unscaled ( |
cov.scaled |
ditto, scaled by |
correlation |
(only if |
symbolic.cor |
(only if |
Julian Taylor
data(mm, package = "hett") attach(mm) tfit <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) tsum(tfit$loc.fit, dispersion = 1)
data(mm, package = "hett") attach(mm) tfit <- tlm(m.marietta ~ CRSP, ~ CRSP, data = mm, start = list(dof = 3), estDof = TRUE) tsum(tfit$loc.fit, dispersion = 1)