4
$\begingroup$

I have a dataframe with 8 columns (variables, X1 to X8) . Each column represents a different model parameter. Each row of the dataframe represents a modelling scenario.

All the modelling scenarios result in some desired output (i.e. Y1). In other words, different model parameters can result in Y1.

I was wondering - are there ways in R to graphically reveal the data structure of my dataframe?

Ideally, I would like some way to quantify: if the value of variable X1 is 1000, what are the likely values of variables X2 to X8?

I was thinking that perhaps some kind of tree diagram might be useful.

Hope I am making sense.

$\endgroup$
2
  • $\begingroup$ I like to use trellis displays for this kind of visual investigations. You'll find them in the lattice package. $\endgroup$
    – MånsT
    Commented Jul 13, 2012 at 8:57
  • $\begingroup$ Thanks. I have found these displays similar to scatterplotMatrix(). $\endgroup$
    – mjburns
    Commented Jul 13, 2012 at 11:49

3 Answers 3

2
$\begingroup$

I would suggest you to use matrix scatter plots such as Scatterplot Matrices in R or Plot matrix in MatLab

Here is sample code for R:

library(car)
scatterplotMatrix(x = mtcars)

It will help you to understand the one-to-one dependencies in data and possibly find the prediction you are looking for (if they really exist). E.g., if some Xs are perfectly correlated you will see the points lying in strait line.

$\endgroup$
3
  • $\begingroup$ Thanks for your response. This plot shows up OK. However, I should probably have mentioned, that the variables X1, X2 etc. are not continuous. They are more like categories. So for example, all the values of X1 are either 1,2, 3 or 4. Because of this, the correlations look strange. $\endgroup$
    – mjburns
    Commented Jul 13, 2012 at 11:43
  • $\begingroup$ Than probably you can fix one variable value (e.g. X_1 = 1) and plot histograms of other variables. You will see the frequencies. I do not know the out-of-box solution for such analysis. Hope this helps. $\endgroup$
    – Paul
    Commented Jul 13, 2012 at 12:06
  • $\begingroup$ Thanks Paul good idea. I like the idea of fixing a variable of interest to a set number and then seeing what the other variables turn out to be. $\endgroup$
    – mjburns
    Commented Jul 14, 2012 at 7:39
3
$\begingroup$

Although your data represent particular things - estimates of parameters under different scenarios - the net result is the same as though you have any ordinary set of eight-dimensional (nine if you count Y1) data. So all the ordinary multidimensional visualisation techniques apply.

Normally I would start with a scatterplot matrix - there are implementations in base graphics, lattice or ggplot2 according to your preference.

$\endgroup$
1
  • $\begingroup$ Thanks for your response. I did start with a scatterplot matrix (see comment above). As mentioned, my variables are not contineious. The variables are basically factors? I would really like to show something like: when X1 was 1000, the frequency of observing X3 as 1 was '44' etc. Hope that makes sense. $\endgroup$
    – mjburns
    Commented Jul 13, 2012 at 11:52
1
$\begingroup$

If you want a tree with conditions, check out rpart. It fits a CART/Regression tree to your data. Simply run

fit = rpart(Y1~X1+X2+X3+X4+X5+X6+X7+X8, data=d)
plot(fit, uniform=TRUE)
text(fit, use.n=TRUE, all=TRUE, cex=.8)

Which leads to a tree like this: Tree

$\endgroup$
1
  • $\begingroup$ Thanks theomega. I was able to plot a useful tree diagram. $\endgroup$
    – mjburns
    Commented Jul 14, 2012 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.