# R linear regression - how to handle when some factors significant while others aren't [duplicate]

I'm playing with the Titanic data set, and trying to figure out what to do about the results I got from a lm that predict the age of the passenger.

How should I handle the Cabin values? Some Cabin levels are significant, while others aren't -- but they're all under the same 'Cabin' column.

So if I want to predict the age of a passenger, should I omit the cabin levels that aren't significant? What's best practice here?

Thanks!

• I dont think CabinA10 is a feature in Titanic Dataset. Did you encode the data? – Justice_Lords Mar 14 '19 at 16:31
• You used treatment contrasts; that means p-values in the summery table are a comparison against a reference cabin value. I expect there is still a significant difference between cabin 10 and cabin 16. Just looking at the p-values, you should use the model as is (including all cabins) for prediction. However, if your goal is prediction, you should based such decisions not on p-values but on cross-validation (and then validate the final method with a test data set). – Roland Mar 15 '19 at 10:21

Apart from following @Mathijs advice, I will run again the regression with CabinA23 as a dummy variarable where 1 means factor CabinA23 and 0 any other. If it is still significative (It should be), you can see that being in CabinA23 had a XX Estimate effect on your model. Best!