[R] Multivariate regression in R [followup]
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Fri Jan 17 10:42:03 CET 2003
On 16-Jan-03 Ted Harding wrote:
> Hence the multivariate regression model for the data could be
> written in matrix form as
>
> Y = X*B + w1*W1 + w2*W2 + w3*W3 + e
>
[ Y Nxp ; X Nxk ; W1 W2 W3 Nxp matices of factor level indicators;
B kxp ; w1, w2, w3 scalars ]
> where e is 3-dim N(0,S), and B, w1, w2, w3 and S are to be estimated.
>
> What, in R, I can't make out how to do is to give some function
> (which function?) a model specification of the form
>
> Y ~ X + W1 + W2 + W3
>
> but in such a way that it will fit a 2x3 matrix B of coefficients for
> X, but scalar coefficients w1, w2, w3 for W1, W2, W3
I think the thought underlying my query was that, if R would accept
designating a _matrix_ of factor levels as a factor while preserving
its matrix structure, then the above could fit into the model
specification scheme. However, factor(W1), for instance, returns
a linear structure.
Apologies for the typo originally in the formula below (now corrected):
> Analytically, the log-likelihood can be written (summing over r)
>
> (-N/2)*log(det(S)) - 0.5*SUM[ e_r * S^(-1) * e_r' ] (e_r = rth row)
>
> where e = Y - B*X - w1*W1 - w2*W2 - w3*W3. After differentiation and
> algebra, one could implement the resulting matrix equations in octave
> (or matlab) and proceed to a solution. One could even do this, as a
> numerical procedure, in R -- but I'd rather not! Indeed, R's richness
> in model-fitting resources tempts one to think that this problem may
> be solvable using these -- it's just that I can't seem to put my hand
> on what's needed.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 17-Jan-03 Time: 09:09:46
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list