# Should data be split into test / training prior to descriptive statistics being carried out on it?

I have a data set that I have added to and plan to carry out some modelling with. I'm wondering whether I should split the data into test / training prior to carrying out the modelling, or if I should write the descriptive section out first then split into test/training for the modelling part.

The descriptive stuff is going to be things like percentiles, some $$\chi^2$$ between different levels, basics like this.

The data is mainly categorical, there are around 700 rows and 30 columns. I'm planning to carry out logistic regression and (probably) a decision tree.

Data splitting often requires a sample size exceeding 20,000 to work properly, i.e., to be stable. Otherwise re-splitting the data will result in arbitrary changes of the model and also of the validation stats. And note that decision trees are not competitive with logistic regression. The bootstrap or repeated cross-validation are preferred. See my RMS book and course notes.

In terms of what you can do before model validation, anything that is masked to Y is fair game. So you can do descriptive statistics that do not examine associations between X and Y.

• Thank's Frank. So here you're suggesting suggesting that test/training with 700 rows is pointless? In your course notes though (Data splitting, 5.3.3 from : hbiostat.org/doc/rms.pdf) you give an example of a dataset with 300 elements, where the training is 200 and the test is 100. I'm still not too sure whether, in this example, you would carry out descriptive statistics on the data prior to splitting or not.
– baxx
Dec 25, 2018 at 21:36
• @FrankHarrell I didn't find it clear, and the notes that you linked seemed to contradict what you've written in your original post (to me).
– baxx
Dec 26, 2018 at 23:06
• Tell me the nature of the contradiction and what is unclear about the notes. Dec 26, 2018 at 23:08
• In the post you've mentioned 20,000 but not explained why. In the notes you have n = 300 for splitting. For myself that is contradictory in this context. I've probably missed something, but I'm not experienced. In the explanation about whether or not descriptives can be done you mention about anything 'masked to Y', I'm not familiar with this expression. Are you saying that anything which isn't ultimately used in the model can be used in the descriptives?
– baxx
Dec 27, 2018 at 12:44
• @FrankHarrell: I just looked at your notes too; while nothing about $n=300$ as a sample size requirement is mentioned, the notes read: "overall sample $n = 300$, training sample $n = 200$, develop model, freeze $\hat{\beta}$, predict on test sample ( $n = 100$ )". Reading this and your comments here I suspect you mean to say to repeat this procedure several hundred times. But definitely this not clearly in by looking at your notes in isolation. If anything, in the notes these lines come under then "Data Splitting" and are mentioned separately from CV and/or Bootstrap. Jan 12, 2019 at 22:55