[R] User error in calling predict/model.frame
Joshua Wiley
jwiley.psych at gmail.com
Sat Jan 29 22:30:46 CET 2011
On Sat, Jan 29, 2011 at 1:23 PM, Joshua Wiley <jwiley.psych at gmail.com> wrote:
>> xxAB <- dat$xxA * dat$xxB
>> meanAB <- meanA * meanB
>> sdAB <- sqrt(sdA^2 + sdB^2 + meanA^2 * sdB^2 + meanB^2 * sdA^2)
don't know why I did that the hard way (besides I think I messed up
the formula slightly), but the point is there's still a difference
between the scaled interaction from unscaled variables and the
interaction of scaled variables.
sdAB <- sd(xxAB) # <-- what I should have done
> (xxAB - meanAB)/sdAB
[1] 0.18412267 -0.97105894 -1.45088077 -1.37131900 0.09339332 0.74663645
[7] -1.27092403 -0.41183471 -1.45890639 0.06568750 0.60130106 1.35945072
[13] 0.79255938 1.80314145 0.51553234 -0.23553700 -0.42045914 -0.73543976
[19] 1.40009474 0.68251640
>> (sxxAB <- with(dat, scale(xxA) * scale(xxB))[1:20,])
> [1] 0.01838999 0.25899229 -0.15337178 1.07536361 -0.26520706 0.25119036
> [7] -0.11295999 0.05205466 -1.49676116 -0.14367368 -1.86921225 0.80860167
> [13] -0.44816896 1.44122535 -0.73361472 -0.14930187 -1.46192081 0.19784309
> [19] 0.62089372 0.0821291515
More information about the R-help
mailing list