[R-sig-eco] Calculate Prediction Interval for Regression by hand...

Chris Howden chris at trickysolutions.com.au
Mon Oct 17 01:36:35 CEST 2011


Hi Johannes,

predict() will give u SE's and confidence intervals.

U can either use the original data as an input and get a prediction for
all the original data points. Or create an input data set and get
predictions for them.

If your doing an ANOVA type analysis with discrete factors I often use
expand.grid to quickly get a matrix for all combinations. So something
like this
(predict.ci <- data.frame(expand.grid(model$xlevels), predict(model,
expand.grid(model$xlevels), interval="conf")))


There's also confint() which is for single parameters.


Chris Howden B.Sc. (Hons) GStat.
Founding Partner
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling and Training
(mobile) 0410 689 945
(fax) +612 4782 9023
chris at trickysolutions.com.au




Disclaimer: The information in this email and any attachments to it are
confidential and may contain legally privileged information. If you are
not the named or intended recipient, please delete this communication and
contact us immediately. Please note you are not authorised to copy, use or
disclose this communication or any attachments without our consent.
Although this email has been checked by anti-virus software, there is a
risk that email messages may be corrupted or infected by viruses or other
interferences. No responsibility is accepted for such interference. Unless
expressly stated, the views of the writer are not those of the company.
Tricky Solutions always does our best to provide accurate forecasts and
analyses based on the data supplied, however it is possible that some
important predictors were not included in the data sent to us. Information
provided by us should not be solely relied upon when making decisions and
clients should use their own judgement.


-----Original Message-----
From: r-sig-ecology-bounces at r-project.org
[mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Johannes
Radinger
Sent: Sunday, 16 October 2011 10:45 PM
To: r-sig-ecology at r-project.org
Subject: [R-sig-eco] Calculate Prediction Interval for Regression by
hand...

Hi UseRs,

I calculated with lm(Y~X1+X2) successfully a linear regression.
Based on this linear regression with multiple independent variables
I'd like to calculate manually prediction intervals. Therefore I have a
few
questions:

1) I want a prediction interval for Y (like Y+-PI) for a given value
for X1 and X2.
2) I want to calculate the predicition intervall for Y by hand (either
with the mathematical functions of R or with python etc.

So I think I have to extract the prediction interval for the single
regression parameters (intercept and slopes) from the lm model.

I tried to google for a simple solution but wasn't succesfully yet.
I think following link: Prediction interval in Regression analysis
explains very well
what I want to do.

There it says: "...one may use the standard error of the estimates for the
intercept and slope ( and ) to compute a prediction interval". So is that
the right approach?
If yes how can I get the standard error for a and b and which formula
has to used for the calculation?


Thank you very much in advance

Have a nice sunday!

cheers
Johannes

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list