12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting the valuesFor example, a car manufacturer has three designs for a new car and wants toknow what the predicted mileage is based on the weight of each new design. Inorder to do this, you first create a data frame with the new values — for example,like this:> new.cars predict(Model, newdata=new.cars)1 2 328.19952 24.45839 18.04503So, the lightest car has a predicted mileage of 28.2 miles per gallon and theheaviest car has a predicted mileage of 18 miles per gallon, according to thismodel. Of course, if you use an inadequate model, your predictions can be prettymuch off as well.Having confidence in your predictionsIn order to have an idea about the accuracy of the predictions, you can ask forintervals around your prediction. To get a matrix with the prediction and a 95percent confidence interval around the mean prediction, you set the argumentinterval to ‘confidence’ like this:> predict(Model, newdata=new.cars, interval=’confidence’)fit lwr upr1 28.19952 26.14755 30.251502 24.45839 23.01617 25.900623 18.04503 16.86172 19.22834Now you know that — according to your model — a car with a weight of 2.4tons has, on average, a mileage between 23 and 25.9 miles per gallon. In thesame way, you can ask for a 95 percent prediction interval by setting the argumentinterval to ‘prediction’:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!