Mi variable dependiente se muestra a continuación no se ajusta a ninguna de distribución de stocks, que yo sepa. Regresión lineal produce algo no normal, de derecha sesgada de los residuos que se relacionan Y previstos de un modo extraño (2ª parcela). Alguna sugerencia para las transformaciones o otras maneras de obtener más resultados válidos y mejor precisión predictiva? Si es posible me gustaría evitar que torpe clasificar en, digamos, 5 valores (por ejemplo, 0, lo%, med%, hi%, 1).
Respuestas
¿Demasiados anuncios?Métodos de regresión censurada puede manejar este tipo de datos. Ellos asumen que los residuos se comportan como en el ordinario de regresión lineal, pero han sido modificados para que
(A la izquierda censura): todos los valores inferiores a un umbral bajo, que es independiente de los datos, (pero puede variar de un caso a otro) no han sido cuantificados; y/o
(Derecho de censurar): todos los valores mayores que de un umbral alto, que es independiente de los datos (pero puede variar de un caso a otro) no han sido cuantificados.
"No se ha cuantificado" significa sabemos si es o no un valor cae por debajo (o por encima) de su umbral, pero eso es todo.
Los métodos de ajuste suelen utilizar de máxima verosimilitud. Cuando el modelo de la respuesta $Y$ correspondiente a un vector $X$ es en forma
$$Y \sim X \beta + \varepsilon$$
with iid $\varepsilon$ having a common distribution $F_\sigma$ with PDF $f_\sigma$ (where $\sigma$ are unknown "nuisance parameters"), then--in the absence of censoring--the log likelihood of observations $(x_i, y_i)$ is
$$\Lambda = \sum_{i=1}^n \log f_\sigma(y_i - x_i\beta).$$
With censoring present we may divide the cases into three (possibly empty) classes: for indexes $i=1$ to $n_1$, the $y_i$ contain the lower threshold values and represent left censored data; for indexes $i=n_1+1$ to $n_2$, the $y_i$ are quantified; and for the remaining indexes, the $y_i$ contain the upper threshold values and represent right censored data. The log likelihood is obtained in the same way as before: it is the log of the product of the probabilities.
$$\Lambda = \sum_{i=1}^{n_1} \log F_\sigma(y_i - x_i\beta) + \sum_{i=n_1+1}^{n_2} \log f_\sigma(y_i - x_i\beta) + \sum_{i=n_2+1}^n \log (1 - F_\sigma(y_i - x_i\beta)).$$
This is maximized numerically as a function of $(\beta, \sigma)$.
In my experience, such methods can work well when less than half the data are censored; otherwise, the results can be unstable.
Here is a simple R
example using the censReg
package to illustrate how OLS and censored results can differ (a lot) even with plenty of data. It qualitatively reproduces the data in the question.
library("censReg")
set.seed(17)
n.data <- 2960
coeff <- c(-0.001, 0.005)
sigma <- 0.005
x <- rnorm(n.data, 0.5)
y <- as.vector(coeff %*% rbind(rep(1, n.data), x) + rnorm(n.data, 0, sigma))
y.cen <- y
y.cen[y < 0] <- 0
y.cen[y > 0.01] <- 0.01
data = data.frame(list(x, y.cen))
The key things to notice are the parameters: the true slope is $0.005$, the true intercept is $-0.001$, and the true error SD is $0.005$.
Let's use both lm
and censReg
to fit a line:
fit <- censReg(y.cen ~ x, data=data, left=0.0, right=0.01)
summary(fit)
The results of this censored regression, given by print(fit)
, are
(Intercept) x sigma
-0.001028 0.004935 0.004856
Those are remarkably close to the correct values of $-0.001$, $0.005$, and $0.005$, respectively.
fit.OLS <- lm(y.cen ~ x, data=data)
summary(fit.OLS)
The OLS fit, given by print(fit.OLS)
, is
(Intercept) x
0.001996 0.002345
Not even remotely close! The estimated standard error reported by summary
is $0.002864$, less than half the true value. These kinds of biases are typical of regressions with lots of censored data.
For comparison, let's limit the regression to the quantified data:
fit.part <- lm(y[0 <= y & y <= 0.01] ~ x[0 <= y & y <= 0.01])
summary(fit.part)
(Intercept) x[0 <= y & y <= 0.01]
0.003240 0.001461
Even worse!
A few pictures summarize the situation.
lineplot <- function() {
abline(coef(fit)[1:2], col="Red", lwd=2)
abline(coef(fit.OLS), col="Blue", lty=2, lwd=2)
abline(coef(fit.part), col=rgb(.2, .6, .2), lty=3, lwd=2)
}
par(mfrow=c(1,4))
plot(x,y, pch=19, cex=0.5, col="Gray", main="Hypothetical Data")
lineplot()
plot(x,y.cen, pch=19, cex=0.5, col="Gray", main="Censored Data")
lineplot()
hist(y.cen, breaks=50, main="Censored Data")
hist(y[0 <= y & y <= 0.01], breaks=50, main="Quantified Data")
The difference between the "hypothetical data" and "censored data" plots is that all y-values below $0$ or above $0.01$ in the former have been moved to their respective thresholds to produce the latter plot. As a result, you can see the censored data all lined up along the bottom and top.
Solid red lines are the censored fits, dashed blue lines the OLS fits, both of them based on the censored data only. The dashed green lines are the fits to the quantified data only. It is clear which is best: the blue and green lines are noticeably poor and only the red (for the censored regression fit) looks about right. The histograms at the right confirm that the $Y$ values of this synthetic dataset are indeed qualitatively like those of the question (mean = $0.0032$, SD = $0.0037$). El de más a la derecha del histograma muestra el centro (cuantificada) de la parte del histograma en detalle.
Son siempre los valores entre 0 y 1?
Si es así usted podría considerar la posibilidad de una distribución beta y beta de la regresión.
Pero asegúrese de pensar a través de un proceso que lleva a sus datos. También podrías hacer un 0 y 1 inflado modelo (0 inflado modelos son comunes, probablemente sería necesario ampliar a 1 inflado por su auto). La gran diferencia es si esos picos representan un gran número de exacto de 0's y 1's o simplemente cerca de los valores de 0 y 1.
Puede ser mejor consultar con un local estadístico (con un acuerdo de no divulgación para que usted pueda discutir los detalles de donde provienen los datos) para elaborar el mejor enfoque.
En concordancia con Greg Nieve consejo que he escuchado beta modelos son útiles en este tipo de situaciones así (ver un Smithson y verkuilen, 2006, Un Mejor Exprimidor de Limón), así como la regresión cuantil (Bottai et al., 2010), pero estos parecen tan pronunciada en el suelo y techo efectos pueden ser inadecuados (especialmente el beta de la regresión).
Otra alternativa sería la de considerar los tipos de modelos de regresión censurada, en particular, el Modelo Tobit, donde consideramos que el observado resultados generados por algunos subyacente de la variable latente que es continua (y, presumiblemente, normal). No voy a decir que esto continua subyacente modelo es razonable dado su histograma, pero usted puede encontrar un poco de apoyo como se puede ver la distribución (ignorando el piso) tiene una densidad mayor a menor los valores del instrumento y lentamente se restringe a valores más altos.
Buena suerte a pesar de que la censura es tan dramática es difícil imaginar la recuperación de gran parte de la información útil dentro de la extrema cubos. A mí me parece que casi la mitad de la muestra cae en el suelo y el techo de los contenedores.