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

Johannes Radinger JRadinger at gmx.at
Mon Oct 17 10:59:42 CEST 2011


Hi again,

thank you all for you tips with predict, predict.lm etc.
>From summary(lm-model), I can get the Estimate and the Standard
Error for intercept and slopes. With confint I can get confidence
intervals (?) for these parameters for different levels.

I want to calculate it by hand, rather then by using R's predict
function, due to some reasons:

1) I want to get the mathematical background
2) I want to use it in a model outside of grass (python-model, and
I don't want to use a direct interaction python-R)
3) I want to calculate it with simple programming languages (e.g. simplest form of basic etc.)

In wikipedia it says that it is possible to calculate the prediction interval from the standard error of the parameters. So how is that done exactly? Can anyone guide me to the formula? Or is it just 

Y=b+Intercept + (a1+SE(a1))*X1+(a2+SE(a2)*X2 (of course with all variations in plus and minus SE)?

Your help is greatly appreciated!

/johannes

-------- Original-Nachricht --------
> Datum: Mon, 17 Oct 2011 10:36:35 +1100
> Von: Chris Howden <chris at trickysolutions.com.au>
> An: Johannes Radinger <jradinger at gmx.at>, r-sig-ecology at r-project.org
> Betreff: RE: [R-sig-eco] Calculate Prediction Interval for Regression by hand...

> 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