Hi, I'm new to the estimation modules in Mathematica and am trying to run a simple multivariate regression using Excel imported data with a header line. I can import the data, but am having trouble getting the data in the right shape to run a regression using LinearModelFit.
Below are my commands and Mathematica output. Any help you can provide would be very much appreciated.
d2 = Import["C:\\Users\\pm91\\Downloads\\test1.csv"]
{{1, 1610, 1, 0, 32, 12}, {1, 1656, 0, 2, 30, 12}, {1, 1980, 1, 3, 35,
12}, {1, 456, 0, 3, 34, 12}, {1, 1568, 1, 2, 31, 14}, {1, 2032, 0,
0, 54, 12}, {1, 1440, 0, 2, 37, 16}, {1, 1020, 0, 0, 54, 12}, {1,
1458, 0, 2, 48, 12}, {1, 1600, 0, 2, 39, 12}, {1, 1969, 0, 1, 33,
12}, {1, 1960, 0, 1, 42, 11}, {1, 240, 1, 2, 30, 12}, {1, 997, 0, 2,
43, 12}, {1, 1848, 0, 1, 43, 10}, {1, 1224, 0, 3, 35, 11}, {1,
1400, 0, 2, 43, 12}, {1, 640, 0, 5, 39, 12}, {1, 2000, 0, 0, 45,
12}}
y = Transpose[d2][[1]] ;
kids1 = Transpose[d2][[3]];
kids2 = Transpose[d2][[4]];
age = Transpose[d2][[5]];
example = Transpose[{kids1, kids2, age, y}]
LInearModelFit[example, {1, kids1, kids2, age, y}, {kids1, kids2, age,
y}]
{{1, 0, 32, 1}, {0, 2, 30, 1}, {1, 3, 35, 1}, {0, 3, 34, 1}, {1, 2,
31, 1}, {0, 0, 54, 1}, {0, 2, 37, 1}, {0, 0, 54, 1}, {0, 2, 48,
1}, {0, 2, 39, 1}, {0, 1, 33, 1}, {0, 1, 42, 1}, {1, 2, 30, 1}, {0,
2, 43, 1}, {0, 1, 43, 1}, {0, 3, 35, 1}, {0, 2, 43, 1}, {0, 5, 39,
1}, {0, 0, 45, 1}}
LInearModelFit[{{1, 0, 32, 1}, {0, 2, 30, 1}, {1, 3, 35, 1}, {0, 3,
34, 1}, {1, 2, 31, 1}, {0, 0, 54, 1}, {0, 2, 37, 1}, {0, 0, 54,
1}, {0, 2, 48, 1}, {0, 2, 39, 1}, {0, 1, 33, 1}, {0, 1, 42, 1}, {1,
2, 30, 1}, {0, 2, 43, 1}, {0, 1, 43, 1}, {0, 3, 35, 1}, {0, 2, 43,
1}, {0, 5, 39, 1}, {0, 0, 45, 1}}, {1, {1, 0, 1, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, 2, 3, 3, 2, 0, 2, 0, 2, 2, 1,
1, 2, 2, 1, 3, 2, 5, 0}, {32, 30, 35, 34, 31, 54, 37, 54, 48, 39,
33, 42, 30, 43, 43, 35, 43, 39, 45}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1}}, {{1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0}, {0, 2, 3, 3, 2, 0, 2, 0, 2, 2, 1, 1, 2, 2,
1, 3, 2, 5, 0}, {32, 30, 35, 34, 31, 54, 37, 54, 48, 39, 33, 42,
30, 43, 43, 35, 43, 39, 45}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1}}]