[R] Calculating sum of squares from density estimates
Rainer M Krug
r.m.krug at gmail.com
Thu Jan 24 14:56:45 CET 2008
Hi
I have some density estimates obtained from density(). I would like to
calculate the sum of squares of these. As the x values of the estimates
are not the same, and I would prefer not to restrict the estiomate to a
certain range of x values, how can I do the calculation?
Lets say:
d1 <- density(Data1)
d2 <- density(Data2)
If the x values would be the same, I would:
ssq <- sum( (d1$y - d2$y)^2 )
but as it isn't, I can't do that.
is there an easy way to get the sum of squares?
Thanks,
Rainer
More information about the R-help
mailing list