Using a list as the y variable would seem most natural but doesn’t work.
Could you please post the example of code that you tried and couldnt get to work? Also you probably use some data that you are fitting; - itd 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.
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. >>
Is there some reason to do this other than one at a time? Offhand I do not see a drawback to that approach.
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
In Wolfram Library there is an upload:
Multiple-Response Fitting by Bruce Miller
Daniel sent a few links - perhaps they will be useful:
- http://mathematica.stackexchange.com/questions/866/simultaneously-fitting-multiple-datasets
- http://forums.wolfram.com/mathgroup/archive/2011/Sep/msg00555.html (this one links to the four below)
- http://forums.wolfram.com/mathgroup/archive/2004/Oct/msg00031.html
- http://forums.wolfram.com/mathgroup/archive/2006/Apr/msg00011.html
- http://forums.wolfram.com/mathgroup/archive/2006/Apr/msg00020.html
- http://forums.wolfram.com/mathgroup/archive/2010/Apr/msg00280.html
Wonderful! Thank you Vitaliy and Daniel.