Message Boards Message Boards

1
|
12559 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

How does one use LinearModelFit with multiple y variables?

Using a list as the y variable would seem most natural but doesn't work.
POSTED BY: Philip Maymin
6 Replies
Wonderful! Thank you Vitaliy and Daniel.
POSTED BY: Philip Maymin
You'd lose the covarianece between the two variables. In some applications, that's fine, and people just do several independent univariate regressions. But sometimes you really want to do a single multivariate one. There's a whole literature on it, the general linear model, MANOVA, etc.

http://en.wikipedia.org/wiki/General_linear_model

http://en.wikipedia.org/wiki/Multivariate_analysis_of_variance
POSTED BY: Philip Maymin
Is there some reason to do this other than one at a time? Offhand I do not see a drawback to that approach.
POSTED BY: Daniel Lichtblau
For example let's say we want to simultaneously predict GDP and Population as a linear function of the Area and Coastline Length for each country having sufficient data:
data = Cases[  Table[CountryData[country, property], {country,     CountryData[]}, {property, {"Area", "CoastlineLength", "GDP",      "Population"}}], {_Real ..}];
There is no problem predicting either GDP or Population separately. Each of the following works:
LinearModelFit[data[[All, {1, 2, 3}]], {area, coast}, {area, coast}]
LinearModelFit[data[[All, {1, 2, 4}]], {area, coast}, {area, coast}]
And one would imagine this would generalize to multivariate regressions with multiple outcome variables naturally:
LinearModelFit[{#1, #2, {#3, #4}} & @@@ data, {area, coast}, {area,   coast}]
But this comes back with an error:
LinearModelFit::notdata: The first argument is not a vector, matrix, or a list containing a design matrix and response vector. >>
POSTED BY: Philip Maymin
Could you please post the example of code that you tried and couldn’t get to work? Also you probably use some data that you are fitting; - it’d be very useful to point us to them or give a code that generates a similar test data set. Without this info it is hard to proceed. 
POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract