On Wed, Nov 23, 2011 at 2:45 PM, Johannes Radinger <JRadinger@gmx.at> wrote:

> Hello,
>
> I have a dataset like:
>
> dataframe(y,x1,x2,x3)
>
> and I know a given (external) regression with its
> parameter estimates like:
>
> y = Intercept + b1*x1 + b2*x2 + b3*x3
>
> Now I'd like to manually calculate the residuals
> of my "new" data based on the given (external) regression.
>
> Is there any built in function of R for doing that
> (not resid()) or do I have to manually calculate fitted values
> and then residuals for each dataset?
>
>
Well - that is not to difficult:



x <- data.frame(y=runif(10), x1=1:10, x2=11:20, x3=1:10)
Intercept <- 0.5
b1 <- 0.6
b2 <- 0.7
b3 <- 0.8
x$yTheo <- Intercept + b1*x$x1 + b2*x$x2 + b3*x$x3
x$resid <- x$y - x$yTheo
x


The values are obviously useless examples.

Cheers,

Rainer

best regards,
> Johannes
> --
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax (F):       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

	[[alternative HTML version deleted]]

