Variance function
In statistics, the variance function is a smooth function that depicts the variance of a random quantity as a function of its mean. The variance function is a measure of heteroscedasticity and plays a large role in many settings of statistical modelling. It is a main ingredient in the generalized linear model framework and a tool used in non-parametric regression, semiparametric regression and functional data analysis. In parametric modeling, variance functions take on a parametric form and explicitly describe the relationship between the variance and the mean of a random quantity. In a non-parametric setting, the variance function is assumed to be a smooth function.
In statistics, the variance function is a smooth function that depicts the variance of a random quantity as a function of its mean. The variance function is a measure of heteroscedasticity and plays a large role in many settings of statistical modelling. It is a main ingredient in the generalized linear model framework and a tool used in non-parametric regression, semiparametric regression and functional data analysis. In parametric modeling, variance functions take on a parametric form and explicitly describe the relationship between the variance and the mean of a random quantity. In a non-parametric setting, the variance function is assumed to be a smooth function. 1. Random Component: a distribution of y from the exponential family, E[y \mid X] = \mu 2. Linear predictor: \eta = XB = \sum_{j=1}^p X_{ij}^T B_j 3. Link function: \eta = g(\mu), \mu = g^{-1}(\eta) First it is important to derive a couple key properties of the exponential family. Any random variable \textit{y} in the exponential family has a probability density function of the form, f(y,\theta,\phi) = \exp\left(\frac{y\theta - b(\theta)}{\phi} - c(y,\phi)\right) with loglikelihood, \ell(\theta,y,\phi)=\log(f(y,\theta,\phi)) = \frac{y\theta - b(\theta)}{\phi} - c(y,\phi) Here, \theta is the canonical parameter and the parameter of interest, and \phi is a nuisance parameter which plays a role in the variance. We use the Bartlett's Identities to derive a general expression for the variance function. The first and second Bartlett results ensures that under suitable conditions (see Leibniz integral rule), for a density function dependent on \theta, f_\theta() , \operatorname{E}_\theta\left[\frac{\partial}{\partial \theta} \log(f_\theta(y)) \right] = 0 \operatorname{Var}_\theta\left[\frac{\partial}{\partial \theta}\log(f_\theta(y))\right]+\operatorname{E}_\theta\left[\frac{\partial^2}{\partial \theta^2} \log(f_\theta(y))\right] = 0 These identities lead to simple calculations of the expected value and variance of any random variable \textit{y} in the exponential family E_\theta[y], Var_\theta[y] . Expected value of Y: Taking the first derivative with respect to \theta of the log of the density in the exponential family form described above, we have \frac{\partial}{\partial \theta}\log(f(y,\theta,\phi))= \frac{\partial}{\partial \theta}\left[\frac{y\theta - b(\theta)}{\phi} - c(y,\phi)\right] = \frac{y-b'(\theta)}{\phi} Then taking the expected value and setting it equal to zero leads to, \operatorname{E}_\theta\left[\frac{y-b'(\theta)}{\phi}\right] = \frac{\operatorname{E}_\theta[y]-b'(\theta)}{\phi}=0 \operatorname{E}_\theta[y] = b'(\theta) Variance of Y: To compute the variance we use the second Bartlett identity, \operatorname{Var}_\theta\left[\frac{\partial}{\partial \theta}\left(\frac{y\theta - b(\theta)}{\phi} - c(y,\phi)\right)\right]+\operatorname{E}_\theta\left[\frac{\partial^2}{\partial \theta^2}\left(\frac{y\theta - b(\theta)}{\phi} - c(y,\phi)\right)\right] = 0 \operatorname{Var}_\theta\left[\frac{y - b'(\theta)} \phi \right] + \operatorname{E}_\theta \left[\frac{-b(\theta)} \phi \right] = 0 \operatorname{Var}_\theta\left[y\right]=b(\theta)\phi We have now a relationship between \mu and \theta , namely \mu = b'(\theta) and \theta = b'^{-1}(\mu) , which allows for a relationship between \mu and the variance, V(\theta) = b(\theta) = \text{the part of the variance that depends on }\theta \operatorname{V}(\mu) = b(b'^{-1}(\mu)). \, Note that because \operatorname{Var}_\theta\left[y\right]>0, b(\theta)>0 , then b': \theta \rightarrow \mu is invertible. We derive the variance function for a few common distributions. f(y) = \exp\left(\frac{y\mu - \frac{\mu^2}{2}}{\sigma^2} - \frac{y^2}{2\sigma^2} - \frac{1}{2}\ln{2\pi\sigma^2}\right) where \theta = \mu, b(\theta) = \frac{\mu^2}{2}, \phi=\sigma^2, c(y,\phi)=- \frac{y^2}{2\sigma^2} - \frac{1}{2}\ln{2\pi\sigma^2} To calculate the variance function V(\mu) , we first express \theta as a function of \mu . Then we transform V(\theta) into a function of \mu \theta=\mu b'(\theta) = \theta= \operatorname{E}[y] = \mu V(\theta) = b(\theta) = 1 Therefore, the variance function is constant. f(y) = \exp\left(y\ln\frac{p}{1-p} + \ln(1-p)\right) \theta = \ln\frac{p}{1-p} = logit(p), which gives us p = \frac{e^\theta}{1+e^\theta} = expit (\theta) b(\theta) = \ln(1+e^\theta) and b'(\theta) = \frac{e^\theta}{1+e^\theta} = expit (\theta) = p = \mu b(\theta) =\frac{e^\theta}{1+e^\theta} - \left(\frac{e^\theta}{1+e^\theta}\right)^2 This give us V(\mu) = \mu(1-\mu) f(y) = \exp(y\ln\lambda -\ln\lambda) \theta = \ln\lambda = which gives us \lambda = e^\theta b(\theta) = e^\theta and b'(\theta) = e^\theta = \lambda = \mu b(\theta) =e^\theta = \mu This give us V(\mu) = \mu Here we see the central property of Poisson data, that the variance is equal to the mean. f_{\mu,\nu}(y) = \frac{1}{\Gamma(\nu)y}\left(\frac{\nu y}{\mu}\right)^\nu e^{-\frac{\nu y}{\mu}} Then in exponential family form we have f_{\mu,\nu}(y) = \exp\left(\frac{-\frac{1}{\mu}y+\ln(\frac{1}{\mu})}{\frac{1}{\nu}}+ \ln\left(\frac{\nu^\nu y^{\nu-1}}{\Gamma(\nu)}\right)\right) \theta = \frac{-1}{\mu} \rightarrow \mu = \frac{-1}{\theta} \phi = \frac{1}{\nu} b(\theta) = -\ln(-\theta) b'(\theta) = \frac{-1}{\theta} = \frac{-1}{\frac{-1}{\mu}} = \mu b(\theta) = \frac{1}{\theta^2} = \mu^2 And we have V(\mu) = \mu^2 In the GLM framework, our goal is to estimate parameters \beta , where Z = g(E[y\mid X]) = X\beta . Therefore, we would like to minimize (Z-XB)^{T}W(Z-XB) and if we define the weight matrix W as \underbrace{W}_{n \times n} = \begin{bmatrix} \frac{1}{\phi V(\mu_1)g'(\mu_1)^2} &0&\cdots&0&0 \\ 0&\frac{1}{\phi V(\mu_2)g'(\mu_2)^2}&0&\cdots&0 \\ \vdots&\vdots&\vdots&\vdots&0\\ \vdots&\vdots&\vdots&\vdots&0\\ 0 &\cdots&\cdots&0&\frac{1}{\phi V(\mu_n)g'(\mu_n)^2} \end{bmatrix}, where \phi,V(\mu),g(\mu) are defined in the previous section, it allows for iteratively reweighted least squares (IRLS) estimation of the parameters. See the section on iteratively reweighted least squares for more derivation and information. Also, important to note is that when the weight matrix is of the form described here, minimizing the expression (Z-XB)^{T}W(Z-XB) also minimizes the Pearson distance. See Distance correlation for more. The matrix W falls right out of the estimating equations for estimation of \beta . Maximum likelihood estimation for each parameter \beta_r, 1\leq r \leq p , requires \sum_{i=1}^n \frac{\partial l_i}{\partial \beta_r} = 0 , where \operatorname{l}(\theta,y,\phi)=\log(\operatorname{f}(y,\theta,\phi)) = \frac{y\theta - b(\theta)}{\phi} - c(y,\phi) is the log-likelihood. Looking at a single observation we have, \frac{\partial l}{\partial \beta_r} = \frac{\partial l}{\partial \theta} \frac{\partial \theta}{\partial \mu}\frac{\partial \mu}{\partial \eta}\frac{\partial \eta}{\partial \beta_r} \frac{\partial \eta}{\partial \beta_r} = x_r \frac{\partial l}{\partial \theta} = \frac{y-b'(\theta)}{\phi}=\frac{y-\mu}{\phi} \frac{\partial \theta}{\partial \mu} = \frac{\partial b'^{-1}(\mu)}{\mu} = \frac{1}{b(b'(\mu))} = \frac{1}{V(\mu)} This gives us \frac{\partial l}{\partial \beta_r} =\frac{y-\mu}{\phi V(\mu)} \frac{\partial \mu}{\partial \eta}x_r , and noting that \frac{\partial \eta}{\partial \mu} = g'(\mu) we have that \frac{\partial l}{\partial \beta_r} = (y-\mu )W\frac{\partial \eta}{\partial \mu}x_r The Hessian matrix is determined in a similar manner and can be shown to be, H = X^T(y-\mu)\left[\frac{\partial}{\beta_s}W\frac{\partial}{\beta_r}\right] - X^TWX Noticing that the Fisher Information (FI), \text{FI} = -E[H] = X^TWX , allows for asymptotic approximation of \hat{\beta} \hat{\beta} \sim N_p(\beta,(X^TWX)^{-1}) , and hence inference can be performed. the link function, E[y] = \mu = g^{-1}(\eta) the variance function, V(\mu) , where the \operatorname{Var}_\theta(y) = \sigma^2 V(\mu) With a specified variance function and link function we can develop, as alternatives to the log-likelihood function, the score function, and the Fisher information, a quasi-likelihood, a quasi-score, and the quasi-information. This allows for full inference of \beta . Quasi-likelihood (QL) Though called a quasi-likelihood, this is in fact a quasi-log-likelihood. The QL for one observation is Q_i(\mu_i,y_i) = \int_{y_i}^{\mu_i} \frac{y_i-t}{\sigma^2V(t)} \, dt And therefore the QL for all n observations is Q(\mu,y) = \sum_{i=1}^n Q_i(\mu_i,y_i) = \sum_{i=1}^n \int_{y_i}^{\mu_i} \frac{y-t}{\sigma^2V(t)} \, dt From the QL we have the quasi-score Quasi-score (QS) Recall the score function, U, for data with log-likelihood \operatorname{l}(\mu\mid y) is U = \frac{\partial l }{d\mu}. We obtain the quasi-score in an identical manner, U = \frac{y-\mu}{\sigma^2V(\mu)} Noting that, for one observation the score is \frac{\partial Q}{\partial \mu} = \frac{y-\mu}{\sigma^2V(\mu)} The first two Bartlett equations are satisfied for the quasi-score, namely E[U] = 0 and \operatorname{Cov}(U) + E\left[\frac{\partial U}{\partial \mu}\right] = 0. In addition, the quasi-score is linear in y. Ultimately the goal is to find information about the parameters of interest \beta . Both the QS and the QL are actually functions of \beta . Recall, \mu = g^{-1}(\eta) , and \eta = X\beta , therefore, \mu = g^{-1}(X\beta). Quasi-information (QI) The quasi-information, is similar to the Fisher information, i_b = -\operatorname{E}\left[\frac{\partial U}{\partial \beta}\right] QL, QS, QI as functions of \beta The QL, QS and QI all provide the building blocks for inference about the parameters of interest and therefore it is important to express the QL, QS and QI all as functions of \beta . Recalling again that \mu = g^{-1}(X\beta) , we derive the expressions for QL, QS and QI parametrized under \beta . Quasi-likelihood in \beta , Q(\beta,y) = \int_y^{\mu(\beta)} \frac{y-t}{\sigma^2V(t)} \, dt The QS as a function of \beta is therefore U_j(\beta_j) = \frac{\partial}{\partial \beta_j} Q(\beta,y) = \sum_{i=1}^n \frac{\partial \mu_i}{\partial\beta_j} \frac{y_i-\mu_i(\beta_j)}{\sigma^2V(\mu_i)} U(\beta) = \begin{bmatrix} U_1(\beta)\\ U_2(\beta)\\ \vdots\\ \vdots\\ U_p(\beta) \end{bmatrix} = D^TV^{-1}\frac{(y-\mu)}{\sigma^2} Where, \underbrace{D}_{n \times p} = \begin{bmatrix} \frac{\partial \mu_1}{\partial \beta_1} &\cdots&\cdots&\frac{\partial \mu_1}{\partial \beta_p} \\ \frac{\partial \mu_2}{\partial \beta_1} &\cdots&\cdots&\frac{\partial \mu_2}{\partial \beta_p} \\ \vdots\\ \vdots\\ \frac{\partial \mu_m}{\partial \beta_1} &\cdots&\cdots&\frac{\partial \mu_m}{\partial \beta_p} \end{bmatrix} \underbrace{V}_{n\times n} = \operatorname{diag}(V(\mu_1),V(\mu_2),\ldots,\ldots,V(\mu_n)) The quasi-information matrix in \beta is, i_b = -\frac{\partial U}{\partial \beta} = \operatorname{Cov}(U(\beta)) = \frac{D^TV^{-1}D}{\sigma^2} Obtaining the score function and the information of \beta allows for parameter estimation and inference in a similar manner as described in Application – weighted least squares. In non-parametric regression analysis, the goal is to express the expected value of your response variable(y) as a function of your predictors (X). That is we are looking to estimate a mean function, g(x) = \operatorname{E}[y\mid X=x] without assuming a parametric form. There are many forms of non-parametric smoothing methods to help estimate the function g(x) . An interesting approach is to also look at a non-parametric variance function, g_v(x) = \operatorname{Var}(Y\mid X=x) . A non-parametric variance function allows one to look at the mean function as it relates to the variance function and notice patterns in the data. g_v(x) = \operatorname{Var}(Y\mid X=x) =\operatorname{E}[y^2\mid X=x] - \left[\operatorname{E}[y\mid X=x]\right]^2 An example is detailed in the pictures to the right. The goal of the project was to determine (among other things) whether or not the predictor, number of years in the major leagues (baseball), had an effect on the response, salary, a player made. An initial scatter plot of the data indicates that there is heteroscedasticity in the data as the variance is not constant at each level of the predictor. Because we can visually detect the non-constant variance, it useful now to plot g_v(x) = \operatorname{Var}(Y\mid X=x) =\operatorname{E}[y^2\mid X=x] - \left[\operatorname{E}[y\mid X=x]\right]^2 , and look to see if the shape is indicative of any known distribution. One can estimate \operatorname{E}[y^2\mid X=x] and \left[\operatorname{E}[y\mid X=x]\right]^2 using a general smoothing method. The plot of the non-parametric smoothed variance function can give the researcher an idea of the relationship between the variance and the mean. The picture to the right indicates a quadratic relationship between the mean and the variance. As we saw above, the Gamma variance function is quadratic in the mean. ==References== ==External links==
Cite this
"Variance function". 1694716252. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1175406517