Input Amazon1 data

{rawdata} = Import["/Users/dmeyer/Teaching/111fall18/regression/data.xlsx"];
Dimensions[rawdata]
First[rawdata]
data = Rest[rawdata];
NN = Length[data];

Print data

MatrixForm[data]

Exploration of data

Scatterplot of features

points = Table[{Red,PointSize[Large],Point[{data[[i,1]],data[[i,2]],data[[i,3]]}]},{i,1,NN}];
Show[
Graphics3D[points],
Axes->True,
AxesLabel->{"1","2","3"},
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
PlotRange->All,
ImageSize->720
]

Marginal distributions

datax1 = Table[data[[i,1]],{i,1,NN}];
m1 = Max[datax1];
Histogram[
datax1,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
AxesLabel->{"1",""},
ImageSize->720
]

datax2 = Table[data[[i,2]],{i,1,NN}];
m2 = Max[datax2];
Histogram[
datax2,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
AxesLabel->{"2",""},
ImageSize->720
]

datax3 = Table[data[[i,3]],{i,1,NN}];
m3 = Max[datax3];
Histogram[
datax3,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
AxesLabel->{"3",""},
ImageSize->720
]

datax4 = Table[data[[i,4]],{i,1,NN}];
m4 = Max[datax4];
Histogram[
datax4,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
AxesLabel->{"4",""},
ImageSize->720
]

datax5 = Table[data[[i,5]],{i,1,NN}];
m5 = Max[datax5];
Histogram[
datax5,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
AxesLabel->{"5",""},
ImageSize->720
]

Towards models

Correlations between features?

plot =
ListPlot[
Table[{data[[i,1]],data[[i,2]]},{i,1,NN}],
PlotStyle->Red,
AxesLabel->{"1","2"},
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
PlotRange->All,
ImageSize->720
]

lm = 
LinearModelFit[
Table[{data[[i,1]],data[[i,2]]},{i,1,NN}],
{x},{x}
]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]
fit = Normal[lm];
fitplot = 
Plot[
fit,{x,0,m1},
PlotStyle->Blue
];
Show[plot,fitplot]

Correlations between values and features?

plot =
ListPlot[
Table[{data[[i,1]],data[[i,4]]},{i,1,NN}],
AxesLabel->{"1","4"},
PlotStyle->Red,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
PlotRange->All,
ImageSize->720
]

lm = 
LinearModelFit[
Table[{data[[i,1]],data[[i,4]]},{i,1,NN}],
{x},{x}
]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]
fit = Normal[lm];
fitplot = 
Plot[
fit,{x,0,m1},
PlotStyle->Blue
];
Show[plot,fitplot]

plot =
ListPlot[
Table[{data[[i,1]],data[[i,5]]},{i,1,NN}],
AxesLabel->{"1","5"},
PlotStyle->Red,
AxesStyle->Directive[Thick],
LabelStyle->Directive[Large],
PlotRange->All,
ImageSize->720
]

lm = 
LinearModelFit[
Table[{data[[i,1]],data[[i,5]]},{i,1,NN}],
{x},{x}
]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]
fit = Normal[lm];
fitplot = 
Plot[
fit,{x,0,m1},
PlotStyle->Blue
];
Show[plot,fitplot]

Full regression models

data4 = Transpose[Take[Transpose[data],4]];

Print["w = "];
lm = LinearModelFit[data4,{x1,x2,x3},{x1,x2,x3}]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]

data5 = Transpose[Drop[Transpose[data],{4}]];
Print["v = "];
lm = LinearModelFit[data5,{x1,x2,x3},{x1,x2,x3}]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]

Print["v = "];
lm = LinearModelFit[data,{x1,x2,x3,w},{x1,x2,x3,w}]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]

Print["w = "];
datas = Transpose[data5];
AppendTo[datas,Last[Transpose[data4]]];
datas = Transpose[datas];
lm = LinearModelFit[datas,{x1,x2,x3,v},{x1,x2,x3,v}]
Print["adjusted (R^2) = ",lm["AdjustedRSquared"]];
lm["ParameterTable"]