correcting raw score for age and gender
Posted on
valentinav
Joined: 06/15/2020
Forums
Hi Everyone,
I received suggestions to correct the the raw score for age and sex main effects, and for the age x sex interaction. However, I am not familiar with this procedure, does someone knows more about it?
I received suggestions to correct the the raw score for age and sex main effects, and for the age x sex interaction. However, I am not familiar with this procedure, does someone knows more about it?
So far, what I had done was to insert age a covariate in my analysis.
Thanks!
Can use lm() with predict
which is ok, but to get the interaction term I am told you need to use * instead of + for the independent variables (age & sex): lm(y~age*sex)
set.seed(1)
n=10
y=rnorm(n)
x1=rnorm(n)
x2=rnorm(n)
lm.ft=function(y,x1,x2)
# return(lm(y~x1+x2)$coef)
return(lm(y~x1+x2))
res=lm.ft(y,x1,x2)
ypredicted <- predict(res)
residuals <- y - ypredicted
Log in or register to post comments
umx_residualize can help (also for twin data)
The help page is useful, but:
residDF = umx_residualize(mpg ~ cyl * disp, data = mtcars)
plot(residDF$mpg ~mtcars$mpg)
twin example
r1 = umx_residualize(ht ~ wt, data = twinData, suffixes=1:2)
**multiple left hand side variables**
r1 = umx_residualize(var = c("disp", "mpg"),cov = "cyl", data = mtcars)
Log in or register to post comments