Plotting Y=f(X) after a regression where X contains 2 predictors
3 ビュー (過去 30 日間)
to regress the y vector as a function of two predictors x1 and x2, which together form the X matrix.
I would like to obtain a plot of y=f(x1), with the data points, regression line and regression bands displayed. I know I can do all of this manually but I'm wondering if there's an easier way. I can see that plot(mdl) gives me an added variable plot with adjusted values, which in this case is not helpful, and I can see that there are no options to single out a single predictor for the plot - or is it the case that it would not make sense statistically to only plot y=f(x1) as long as there is an x2 predictor as well?
回答 (3 件)
Ahmet Cecen 2014 年 8 月 1 日
It doesn't make sense to plot y vs f(x1). Here you have several options.
1) You can plot y vs x1 and y vs x2, which can show you how well each variable agrees with y. Cftool is an easy way to play around fits and scatter plots.
2) You can plot y vs x2 vs x1, which is another way to see how variables agree with y. (Cftool does this too)
3) You can plot y vs f(x1,x2) as a scatter plot, which is arguably the most meaningful thing you can plot.
There are a variety of diagnostic plots you can go for if your answer is unsatisfactory. I won't get into those here, check linear regression (assumptions) on wikipedia.