Neha Patil (Editor)

Variance function

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Variance function

In statistics, the variance function is a smooth function which depicts the variance of a random quantity as a function of its mean. The variance function 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.

Contents

Intuition

In a regression model setting, the goal is to establish whether or a not a relationship exists between a response variable and a set of predictor variables. Further, if a relationship does exist, the goal is then to be able to describe this relationship as best as possible. A main assumption in linear regression is constant variance or (homoscedasticity), meaning that different response variables have the same variance in their errors, at every predictor level. This assumption works well when the response variable and the predictor variable are jointly Normal, see Normal distribution. As we will see later, the variance function in the Normal setting, is constant, however, we must find a way to quantify heteroscedasticity (non-constant variance) in the absence of joint Normality.

When it is likely that the response follows a distribution that is a member of the exponential family, a generalized linear model may be more appropriate to use, and moreover, when we wish not to force a parametric model onto our data, a non-parametric regression approach can be useful. The importance of being able to model the variance as a function of the mean lies in improved inference (in a parametric setting), and estimation of the regression function in general, for any setting.

Variance functions play a very important role in parameter estimation and inference. In general, maximum likelihood estimation requires that a likelihood function be defined. This requirement then implies that one must first specify the distribution of the response variables observed. However, to define a quasi-likelihood, one need only specify a relationship between the mean and the variance of the observations to then be able to use the quasi-likelihood function for estimation. Quasi-likelihood estimation is particularly useful when there is overdispersion. Overdispersion occurs when there is more variability in the data than there should otherwise be expected according to the assumed distribution of the data.

In summary, to ensure efficient inference of the regression parameters and the regression function, the heteroscedasticity must be accounted for. Variance functions quantify the relationship between the variance and the mean of the observed data and hence play a significant role in regression estimation and inference.

Types of variance functions

The variance function and its applications come up in many areas of statistical analysis. A very important use of this function is in the framework of generalized linear models and non-parametric regression.

Generalized linear model

When a member of the exponential family has been specified, the variance function can easily be derived. The general form of the variance function is presented under the exponential family context, as well as specific forms for Normal, Bernoulli, Poisson, and Gamma. In addition, we describe the applications and use of variance functions in maximum likelihood estimation and quasi-likelihood estimation.

Derivation

The generalized linear model (GLM), is a generalization of ordinary regression analysis that extends to any member of the exponential family. It is particularly useful when the response variable is categorical, binary or subject to a constraint (e.g. only positive responses make sense). A quick summary of the components of a GLM are summarized on this page, but for more details and information see the page on generalized linear models.

A GLM consists of three main ingredients:

1. Random Component: a distribution of y from the exponential family, E [ y X ] = μ 2. Linear predictor: η = X B = j = 1 p X i j T B j 3. Link function: η = g ( μ ) , μ = g 1 ( η )

First it is important to derive a couple key properties of the exponential family.

Any random variable y in the exponential family has a probability density function of the form,

f ( y , θ , ϕ ) = exp ( y θ b ( θ ) ϕ c ( y , ϕ ) )

with loglikelihood,

( θ , y , ϕ ) = log ( f ( y , θ , ϕ ) ) = y θ b ( θ ) ϕ c ( y , ϕ )

Here, θ is the canonical parameter and the parameter of interest, and ϕ 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 θ , f θ ( ) ,

E θ [ θ log ( f θ ( y ) ) ] = 0 Var θ [ θ log ( f θ ( y ) ) ] + E θ [ 2 θ 2 log ( f θ ( y ) ) ] = 0

These identities lead to simple calculations of the expected value and variance of any random variable y in the exponential family E θ [ y ] , V a r θ [ y ] .

Expected value of Y: Taking the first derivative with respect to θ of the log of the density in the exponential family form described above, we have

θ log ( f ( y , θ , ϕ ) ) = θ [ y θ b ( θ ) ϕ c ( y , ϕ ) ] = y b ( θ ) ϕ

Then taking the expected value and setting it equal to zero leads to,

E θ [ y b ( θ ) ϕ ] = E θ [ y ] b ( θ ) ϕ = 0 E θ [ y ] = b ( θ )

Variance of Y: To compute the variance we use the second Bartlett identity,

Var θ [ θ ( y θ b ( θ ) ϕ c ( y , ϕ ) ) ] + E θ [ 2 θ 2 ( y θ b ( θ ) ϕ c ( y , ϕ ) ) ] = 0 Var θ [ y b ( θ ) ϕ ] + E θ [ b ( θ ) ϕ ] = 0 Var θ [ y ] = b ( θ ) ϕ

We have now a relationship between μ and θ , namely

μ = b ( θ ) and θ = b 1 ( μ ) , which allows for a relationship between μ and the variance, V ( θ ) = b ( θ ) = the part of the variance that depends on  θ V ( μ ) = b ( b 1 ( μ ) ) .

Note that because Var θ [ y ] > 0 , b ( θ ) > 0 , then b : θ μ is invertible. We derive the variance function for a few common distributions.

Example – normal

The Normal distribution is a special case where the variance function is a constant. Let y N ( μ , σ 2 ) then we put the density function of y in the form of the exponential family described above:

f ( y ) = exp ( y μ μ 2 2 σ 2 y 2 2 σ 2 1 2 ln 2 π σ 2 )

where

θ = μ , b ( θ ) = μ 2 2 , ϕ = σ 2 , c ( y , ϕ ) = y 2 2 σ 2 1 2 ln 2 π σ 2

To calculate the variance function V ( μ ) , we first express θ as a function of μ . Then we transform V ( θ ) into a function of μ

θ = μ b ( θ ) = θ = E [ y ] = μ V ( θ ) = b ( θ ) = 1

Therefore the variance function is constant.

Example – Bernoulli

Let y Bernoulli ( p ) , then we express the density of the Bernoulli distribution in exponential family form,

f ( y ) = exp ( y ln p 1 p + ln ( 1 p ) ) θ = ln p 1 p = logit(p), which gives us p = e θ 1 + e θ = expit ( θ ) b ( θ ) = ln ( 1 + e θ ) and b ( θ ) = e θ 1 + e θ = expit ( θ ) = p = μ b ( θ ) = e θ 1 + e θ ( e θ 1 + e θ ) 2

This give us

V ( μ ) = μ ( 1 μ )

Example – Poisson

Let y Poisson ( λ ) , then we express the density of the Poisson distribution in exponential family form,

f ( y ) = exp ( y ln λ ln λ ) θ = ln λ = which gives us λ = e θ b ( θ ) = e θ and b ( θ ) = e θ = λ = μ b ( θ ) = e θ = μ

This give us

V ( μ ) = μ

Here we see the central property of Poisson data, that the variance is equal to the mean.

Example – Gamma

The Gamma distribution and density function can be expressed under different parametrizations. We will use the form of the gamma with parameters ( μ , ν )

f μ , ν ( y ) = 1 Γ ( ν ) y ( ν y μ ) ν e ν y μ

Then in exponential family form we have

f μ , ν ( y ) = exp ( 1 μ y + ln ( 1 μ ) 1 ν + ln ( ν ν y ν 1 Γ ( ν ) ) ) θ = 1 μ μ = 1 θ ϕ = 1 ν b ( θ ) = l n ( θ ) b ( θ ) = 1 θ = 1 1 μ = μ b ( θ ) = 1 θ 2 = μ 2

And we have V ( μ ) = μ 2

Application – weighted least squares

A very important application of the variance function is its use in parameter estimation and inference when the response variable is of the required exponential family form as well as in some cases when it is not (which we will discuss in quasi-likelihood). Weighted least squares (WLS) is a special case of generalized least squares. Each term in the WLS criterion includes a weight that determines that the influence each observation has on the final parameter estimates. As in regular least squares, the goal is to estimate the unknown parameters in the regression function by finding values for parameter estimates that minimize the sum of the squared deviations between the observed responses and the functional portion of the model.

While WLS assumes independence of observations it does not assume equal variance and is therefore a solution for parameter estimation in the presence of heteroscedasticity. The Gauss–Markov theorem and Aitken demonstrate that the best linear unbiased estimator (BLUE), the unbiased estimator with minimum variance, has each weight equal to the reciprocal of the variance of the measurement.

In the GLM framework, our goal is to estimate parameters β , where Z = g ( E [ y X ] ) = X β . Therefore we would like to minimize ( Z X B ) T W ( Z X B ) and if we define the weight matrix W as

W n × n = [ 1 ϕ V ( μ 1 ) g ( μ 1 ) 2 0 0 0 0 1 ϕ V ( μ 2 ) g ( μ 2 ) 2 0 0 0 0 0 0 1 ϕ V ( μ n ) g ( μ n ) 2 ] ,

where ϕ , V ( μ ) , g ( μ ) 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 X B ) T W ( Z X B ) also minimizes the Pearson distance. See Distance correlation for more.

The matrix W falls right out of the estimating equations for estimation of β . Maximum likelihood estimation for each parameter β r , 1 r p , requires

i = 1 n l i β r = 0 , where l ( θ , y , ϕ ) = log ( f ( y , θ , ϕ ) ) = y θ b ( θ ) ϕ c ( y , ϕ ) is the log-likelihood.

Looking at a single observation we have,

l β r = l θ θ μ μ η η β r η β r = x r l θ = y b ( θ ) ϕ = y μ ϕ θ μ = b 1 ( μ ) μ = 1 b ( b ( μ ) ) = 1 V ( μ )

This gives us

l β r = y μ ϕ V ( μ ) μ η x r , and noting that η μ = g ( μ ) we have that l β r = y μ ϕ V ( μ ) W η μ x r

The Hessian matrix is determined in a similar manner and can be shown to be,

H = X T ( y μ ) [ β s W β r ] X T W X

Noticing that the Fisher Information (FI),

FI = E [ H ] = X T W X , allows for asymptotic approximation of β ^ β ^ N p ( β , ( X T W X ) 1 ) , and hence inference can be performed.

Application – quasi-likelihood

Because most features of GLMs only depend on the first two moments of the distribution, rather than then entire distribution, the quasi-likelihood can be developed by just specifying a link function and a variance function. That is, we need to specify

– Link function: E [ y ] = μ = g 1 ( η ) – Variance function: V ( μ ) , where the  Var θ ( y ) = σ 2 V ( μ )

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 β .

Quasi-likelihood (QL)

Though called a quasi-likelihood, this is in fact a quasi-log-likelihood. The QL for one observation is

Q i ( μ i , y i ) = y i μ i y i t σ 2 V ( t ) d t

And therefore the QL for all n observations is

Q ( μ , y ) = i = 1 n Q i ( μ i , y i ) = i = 1 n y i μ i y t σ 2 V ( t ) d t

From the QL we have the quasi-score

Quasi-score (QS)

Recall the score function, U, for data with log-likelihood l ( μ y ) is

U = l d μ .

We obtain the quasi-score in an identical manner,

U = y μ σ 2 V ( μ )

Noting that, for one observation the score is

Q μ = y μ σ 2 V ( μ )

The first two Bartlett equations are satisfied for the quasi-score, namely

E [ U ] = 0

and

Cov ( U ) + E [ U μ ] = 0.

In addition, the quasi-score is linear in y.

Ultimately the goal is to find information about the parameters of interest β . Both the QS and the QL are actually functions of β . Recall, μ = g 1 ( η ) , and η = X β , therefore,

μ = g 1 ( X β ) .

Quasi-information (QI)

The quasi-information, is similar to the Fisher information,

i b = E [ U β ]

QL,QS,QI as functions of β

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 β .

Recalling again that μ = g 1 ( X β ) , we derive the expressions for QL,QS and QI parametrized under β .

Quasi-likelihood in β ,

Q ( β , y ) = y μ ( β ) y t σ 2 V ( t ) d t

The QS as a function of β is therefore

U j ( β j ) = β j Q ( β , y ) = i = 1 n μ i β j y i μ i ( β j ) σ 2 V ( μ i ) U ( β ) = [ U 1 ( β ) U 2 ( β ) U p ( β ) ] = D T V 1 ( y μ ) σ 2

Where,

D n × p = [ μ 1 β 1 μ 1 β p μ 2 β 1 μ 2 β p μ m β 1 μ m β p ] V n × n = diag ( V ( μ 1 ) , V ( μ 2 ) , , , V ( μ n ) )

The quasi-information matrix in β is,

i b = U β = Cov ( U ( β ) ) = D T V 1 D σ 2

Obtaining the score function and the information of β allows for parameter estimation and inference in a similar manner as described in Application – weighted least squares.

Non-parametric regression analysis

Non-parametric estimation of the variance function and its importance, has been discussed widely in the literature 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 ) = E [ y 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 ) = Var ( Y 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 ) = Var ( Y X = x ) = E [ y 2 X = x ] [ E [ y X = x ] ] 2

An example is detailed in the pictures to the left. 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 ) = Var ( Y X = x ) = E [ y 2 X = x ] [ E [ y X = x ] ] 2 , and look to see if the shape is indicative of any known distribution. One can estimate E [ y 2 X = x ] and [ E [ y X = x ] ] 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

Variance function Wikipedia