# Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0

I'm assisting a colleague with a weighted regression of average length of stay (LOS) measured in days vs. inpatient admit rate in a dataset consisting of inpatient records from 30 hospitals. We've calculated the weight at each data point as the inverse standard error of patient's LOS at the hospital.

Is there a standard procedure for estimating the inverse stnd error weight where the stnd error = 0? In several hospitals with low patient volume the LOS is identical for all patients during our analysis time period, and therefore the stnd error = 0, producing a weight equal to infinity.

We could drop these data points from the regression (or avoid a weighted regression entirely), but in principle it seems there ought to be an accepted technique for calculating weights in special cases where the variance = 0. I haven't had any luck checking my stats textbooks.

Thank you for the advice, Michael and whuber. Most of the total error sum of squares can be attributed to measurement error in my case when I run a simple unweighted least squares regression (RSS=44.5, ESS=168.9, TSS=213.4).

So if I were to construct my own weighting scheme it might entail, at one extreme if variance=0 then the weight = # obs in that hospital, and at the other extreme, if variance=infinity, the weight=0.

Perhaps a handy formula could be weight_i = N_i/(N_i^CV_i), where weight_i = weight for hospital i, N_i = # obs for hospital i, and CV_i = Coefficient of Variation of observed LOS for hospital i? • This is, at bottom, an issue of identifying and quantifying separate components of variance. Your weighting is appropriate when all variation can be attributed to the measurement error in LOS. Because you're doing a regression, there will likely be residuals: they will include a separate (independent) variance component. If, eyeballing the scatterplot, it appears the regression residuals will be larger than typical LOS SE's, then you are probably OK not weighting anything. The problem is more challenging otherwise, so first it would be good to do this check! What does it tell you? – whuber Sep 19 '12 at 19:21
• Just checking: you are weighting by the standard error of the mean for the $i$th observation: $\hat{s_i}/\sqrt{n_i}$, right? The $\sqrt{n_i}$ factor could be more important than the $\hat{s_i}$ factor – Andrew M Dec 1 '15 at 18:16
• @AndrewM - Yes, weighting by stnd error, although it's been 3 years so I'd have to search thru my files for the SAS code to be absolutely certain. – RobertF Dec 1 '15 at 18:32

## 2 Answers

The problem you have is that you are using the estimated standard error in the denominator of the weight. The population standard deviation is not likely to be 0 in real situations. I do not think there is a standard way that applies this particular weighting scheme and some other weight when to estimated standard error is 0. The solution is to take a different weighting scheme. There is no law that says that you must take the reciprocal of the standard errors as the weights. Under certain assumptions those would be the optimal weights. But that is not the case here.

In other cases when I have tricky zeros that make my calculations hard, such as on the diagonal of a matrix I need to invert, I was taught something that was called regularisation: that is, adding a small value uniformly to the offending variable.

For instance, in my case where I had a covariance matrix that I need to invert, Q, I set Qhat = I*q for q = 10e-x for some x and for I the identity matrix of same size as Q. In your case, you could add a small value to the variance.

• Although this can work, it would seem that the results might be exquisitely sensitive to the choice of regularization parameter. (Arbitrarily small values will weight the zero-SD data by arbitrarily large amounts.) That kicks the question down the road: what value of that parameter should be used? – whuber Dec 1 '15 at 15:54
• That's absolutely correct. The only answer that I can give is to use values that produce results are still good enough by a reasonable metric. The problem is that yes, it does introduce noise and another parameter to tune. – Ogaday Dec 1 '15 at 16:05
• One could cast this as a hierarchical model, impose a prior on the LOS standard deviations, and use empirical bayes to estimate the shrinkage factor. – Andrew M Dec 1 '15 at 17:47