qme(formula, data, point = 0, direction = "left", cval = "ml",
const = 1, beta = "ml", covar = FALSE, na.action, ...)
## S3 method for class 'qme':
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'qme':
summary(object, level=0.95, ...)
## S3 method for class 'summary.qme':
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'qme':
coef(object,...)
## S3 method for class 'qme':
vcov(object,...)
## S3 method for class 'qme':
residuals(object,...)
## S3 method for class 'qme':
fitted(object,...)
"qme"
"left"
(the default) or "right"
"ml"
meaning that the estimated residual standard deviation from a maximum likelihood model for truncated regression, fitted using
const=0.5
would give a threshold value that is half the original size. The default value is 1."ml"
, meaning that the estimated regression coefficients from fitting a maximum likelihood model foTRUE
the covariance matrix is estimated using bootstrap, as described in Karlsson (2004). The default number of replicates is 2000 but this can be adjusted (see aNA
s.summary.qme
. A number between 0 and 1. The default value is 0.95
.qme
the number of bootstrap replicates can be adjusted by setting R=
the desired number of replicates. Also the control
argument of optim
can beqme
returns an object of class "qme"
.
The function summary
prints a summary of the results, including two types of confidence intervals (normal approximation and percentile method). The generic accessor functions
coef
, fitted
, residuals
and vcov
extract various useful features of the value returned by qme
An object of class "qme"
, a list with elements:optim
coefficients
optim
. See the documentation for optim
for further detailsoptim
. An integer code. 0 indicates successful completion. Possible error codes are
1 indicating that the iteration limit maxit had been reached.
10 indicating degeneracy of the Nelder--Mead simplex.optim
. A character string giving any additional information returned by the optimizer, or NULL
.covar
=
TRUE
, the estimated covariance matrixcovar
=
TRUE
, the number of bootstrap replicatescovar
=
TRUE
, the bootstrap replicatesoptim
using the "Nelder--Mead" method. The maximum number of iterations is set at 2000, but this can be adjusted by setting control=list(maxit=...)
(for more information see the documentation for optim
).
The starting values of the regression coefficients can have a great impact on the result of the maximization. For this reason it is recommended to use one of the methods for generating these rather than supplying the values manually, unless one is confident that one has a good idea of what the starting values should be. For more detailed information see Karlsson and Lindmark (2014).qme.fit
, the function that does the actual fitting
lt
, for estimation of models with truncated response variables using the LT estimator
stls
, for estimation of models with truncated response variables using the STLS estimator
truncreg
for estimating models with truncated response variables by maximum likelihood, assuming Gaussian errors##Simulate a data.frame (model with asymmetrically distributed errors)
n <- 10000
x1 <- runif(n,0,10)
x2 <- runif(n,0,10)
x3 <- runif(n,-5,5)
eps <- rexp(n,0.2)- 5
y <- 2-2*x1+x2+2*x3+eps
d <- data.frame(y=y,x1=x1,x2=x2,x3=x3)
##Use a truncated subsample
dtrunc <- subset(d, y>0)
##Use qme to consistently estimate the slope parameters
qme(y~x1+x2+x3, dtrunc, point=0, direction="left", cval="ml", const=1,
beta="ml", covar=FALSE)
##Example using data "PM10trunc"
data(PM10trunc)
qmepm10 <- qme(PM10~cars+temp+wind.speed+temp.diff+wind.dir+hour+day,
data=PM10trunc, point=2, control=list(maxit=4500))
summary(qmepm10)
Run the code above in your browser using DataCamp Workspace