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

> now just another question popped up:
>
> How do I have to handle the case when
> variables are transformed?
>
> the regression function is as follows:
>
> log(y) ~ log(x1)+ log(x2) + sqrt(x3)
>
> Is that way correct?:
>
> #original data not transformed yet
> df <- data.frame(y=runif(10), x1=1:10, x2=11:20, x3=1:10)
>
> # parameter estimates for from lm with transformed data
> Intercept <- 0.5
> b1 <- 0.6
> b2 <- 0.7
> b3 <- 0.8
>
> df$yTheo <- Intercept + b1*log(x$x1) + b2*log(x$x2) + b3*sqrt(x$x3)
>
> #how about the transformed y? this way?
> df$resid <- df$y - exp(df$yTheo)
> #or this way
> df$resid <- log(df$y) - df$yTheo
>
>
>
Workflow is:

1) data gathering (done)
2) data analysis
2.1) data assessment and choice of methodology for analysis
2.2) data transformation (if necessary)
2.3) data analysis
2.3.1) regression of TRANSFORMED DATA
2.3.2) calculation of residuals of TRANSFORMED DATA

As your regression is based on the transformed data, your residuals are as
well - they tell you something of your regression!

Nobody stops you from transforming them back, but I do not know if it makes
much sense.


> Are the manually calculated residuals to those which are usually produced
> with resid(lm())? Or are there any standardizations of residuals etc.
>

Try it out...

Cheers,

Rainer


>
>
> /Johannes
>
>
>
> -------- Original-Nachricht --------
> > Datum: Wed, 23 Nov 2011 14:52:51 +0100
> > Von: Rainer M Krug <r.m.krug@gmail.com>
> > An: Johannes Radinger <JRadinger@gmx.at>
> > CC: r-sig-ecology@r-project.org
> > Betreff: Re: [R-sig-eco] Manually calculate residuals
>
> > 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
>
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
>



-- 
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]]

