1
|
11773 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
GROUPS:

# How does one use LinearModelFit with multiple y variables?

Posted 11 years ago
 Using a list as the y variable would seem most natural but doesn't work.
6 Replies
Sort By:
Posted 11 years ago
 Wonderful! Thank you Vitaliy and Daniel.
Posted 11 years ago
 In Wolfram Library there is an upload:Multiple-Response Fitting by Bruce MillerDaniel sent a few links - perhaps they will be useful:
Posted 11 years ago
 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_modelhttp://en.wikipedia.org/wiki/Multivariate_analysis_of_variance
Posted 11 years ago
 Is there some reason to do this other than one at a time? Offhand I do not see a drawback to that approach.
Posted 11 years ago
 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 11 years ago
 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.