0

I am very new to R and I made a linear model of price based on variables like size and location. I used data from 2005-2010 for the model (Model_Data) and I want to make predictions for 2011-2014 (Test_Data).

model=lm(Price~Size+Location, data=Model_Data)

Test_Data$Predicted_Price = predict(model, Test_Data)

df=data.frame(Test_Data$Predicted_Price)

write.csv(df, file="Predictions.csv")

When I run this and open the csv file, it returns all NA values for the 2011-2014 test data. There are some empty cells for some of the variables, but I thought those are just omitted when predictions are made. Is it something wrong with the code? Any help would be appreciated.

Thanks

5738
  • 13
  • 2
  • Please edit **your question** according to guidelines stated [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – NelsonGon Mar 24 '19 at 14:50
  • 3
    It's unclear which step is causing the issue. Run each line and inspect the inputs and the result if they match what you'd expect – Roman Luštrik Mar 24 '19 at 14:51
  • You should add your dataset, or at least a subset of it. – Alessio Mar 24 '19 at 21:16

0 Answers0