R Tutorial with Bayesian Statistics Using OpenBUGS by Yau Chi

R Tutorial with Bayesian Statistics Using OpenBUGS by Yau Chi

Author:Yau, Chi
Language: eng
Format: epub
Tags: COM077000
Publisher: Chi Yau
Published: 2013-09-17T04:00:00+00:00


Solution

We apply the function lm to a formula that describes the dependent variable eruptions by the independent variable waiting, and save the new linear regression model in a variable eruption.lm.

> attach(faithful) > eruption.lm = + lm(eruptions ~ waiting)

Then we create a data frame containing the waiting time parameter.

> newdata = data.frame(waiting=80)

We now apply the function predict by setting the predictor variable in the argument newdata. We also set the interval type as "predict", and use the default 0.95 confidence level.

> predict(eruption.lm, newdata, + interval="predict") fit lwr upr 1 4.1762 3.1961 5.1564 > detach(faithful) # clean up



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.