r/rstats•
bms111

Visualizing function with multiple independent variables

I have a data set which uses multiple independent variables to predict the dependant variable. I am trying to figure out if there is any way that I might be able to create a visualization of this data.

All of these variables except for membership represent 1% of a whole being made up of that group. The 4 variables are the only / most statistically significant independent variables in the data.

If it helps, the regression returned is:

(Intercept) 563.772927

Asian -86.816275

Membership 0.018212

Multiracial 27.317145

African American 7.686109

​

If not a plot, then I would be happy to hear any ideas for other ways to visually show the results.

Posted Dec 4, 2019, 1:35 AM UTC

19
[deleted]•

[removed]

1
1
bms111OP•

That might be useful, I will have to explore it more to understand it and see if it works. Thanks for the idea.

1
dbraun31•

So each variable in your design can be thought of as a 'dimension' of the data, and, in general, it's really hard / usually not clear to plot more than two continuous dimensions at once. It's hard to give too much advice without knowing more about the nature of these variables and your design overall, but your best bet for plotting the results of a regression is with what's called a simple slopes plot (example). This gets complicated, however, because it involves plugging your results back into the regression equation and plotting predictions.

A simpler approach might be to just take your variables that ended up being significant and make a scatter plot for each, where the x-axis is one of the independent variables and the y-axis is the dependent variable. You could then slap a linear trend line on each plot (like making a bunch of these). This might be the best way to go because it looks like the effects you're showing are all independent (ie, no interactions).

1
bms111OP•

To give a little context about the data: I am trying to see if you can use # of total students and the % of each ethnic group enrolled to predict how many dollars the district gets from the federal level. There are more ethnic groups than the ones I listed. All of the ethnic groups added together added to 100, because they were percentages. So, some of them are sort of correlated, but only so far as they never exceed 100 in total. I only listed the ones that a MASS package "step" command found to be significant.

Also, what do you think of the breakdown suggestion made in the other comment? I looked at it and it might work but it is not your usual plot.

1
dbraun31•

So from what I can glean, the "breakdown" plot is just plotting the coefficient estimates from the regression? It's very unclear to me what the colors mean and why positives and negatives are going in the same direction.

I'm struggling somewhat with your model because independent variables are supposed to be independent from each other (ie not correlated) and computing yours as a percentage necessarily violates that, so I'm not sure how much you can trust your results. Maybe include those vars in the model as raw counts instead of percentages? Either way, scatter plots have the advantage that they show the raw data to the viewer, so, even if your model results are misleading, it'll be obvious from the plot.

1
bms111OP•

That's fair. Do you think it would help or hurt to add back in the other ethnicities, making it add to 100? I also have the percentage of a districts funding comes from the fed, which could be used as possible Y. In any case, the best regression that it will give me has a pretty low r^2. The low r2 isn't really a big problem though.

1
dbraun31•

I imagine adding in the rest of those variables would hurt, actually. Think about how such percentages work: if one of them goes up, others of them necessarily have to go down. That's the definition of dependence. So I'd really advise against coding them as percentages if you're going to include more than one tbh--and the codependence of your independent vars could be a reason for the low R^2.

​

Re fed funding: It could also make sense to include that as an IV, I think. But that depends on whether you're interested in controlling for it (include as IV) or explaining it (include as DV).

1