Re: [R] Question on partial effect

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Wed 12 Jul 2006 - 02:24:51 EST

On Tue, 2006-07-11 at 23:51 +0800, Guo Wei-Wei wrote:
> Dear all,
>
> I don't know what's my question is called. I have a performance
> variable A, such as sales. And I have another variable B, let's say
> establish time of firm. I want to create the third variable that is
> sales without the effect of establish time. Maybe it can be called
> partial effect problem. I'm not sure.
>
> Does anyone have any suggestion? Thank you in advance!
>
> All the best,
> Wei-Wei

Do you mean?

## dummy data

A <- rnorm(100)
B <- rnorm(100)
C <- resid(lm(A ~ B))

C now contains the residual variation in A after fitting B.

e.g. with some real data
?cars
data(cars) # not sure this is needed now, I forget mod <- lm(dist ~ speed, data = cars)
summary(mod)
partial <- resid(mod)

## check
mod2 <- lm(dist ~ partial, data = cars)
summary(mod2)
## from the two R^2 form mod1 and mod2 - partial contains dist minus ## the effects of speed
> 0.6511 + 0.3489
[1] 1

HTH G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC & ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/cv/
 London, UK. WC1E 6BT.         [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jul 12 03:41:13 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 12 Jul 2006 - 04:18:03 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.