# [R] regression coefficients

Spencer Graves spencer.graves at pdf.com
Tue May 20 17:19:40 CEST 2003

```	  I don't know of a simply function to do what you want, but I can give
you part of the standard log(likelihood ratio) theory:

Suppose b[i]|s ~ N.r(b, s^2*W[i]), i = 1, ..., k.  Then the
log(likelihood) is a sum of k terms of the following form:

l[i] = (-0.5)*(r*log(2*pi*s^2)+log|W[i]|
+(s^-2)*t(b[i]-b)%*%solve(W[i]%*%(b[i]-b)

By differentiating with respect to b and setting to 0, we get the
maximum likelihood estimate for b as follows:

b.hat = solve(sum(solve(W[i]))%*%sum(solve(W[i])%*%b[i])

In words:  b.hat = weighted average with weights inversely proportional
to the variances.  Then log(likelihood ratio) is as follows:

log.LR = sum((s^-2)*t(b[i]-b.hat)%*%solve(W[i])%*%(b[i]-b.hat))

This problem should be in most good books on multivariate analysis.  I
would guess that log.LR probably has an F distribution with numerator
degrees of freedom = r*(k-1) and with denominator degrees of freedom =
degrees of freedom in the estimate of s.  However, I don't remember for
sure.  It's vaguely possible that this is an "unsolved" problem.  In the
latter case, you should have all the pieces here to generate a Monte
Carlo.

hope this helps.  spencer graves

lamack lamack wrote:
> dear all, How can I compare regression coefficients across three (or
> more) groups?
>
> Thank you very much
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

```