Skip to content
Back to formatted view

Raw Message

Message-ID: <HCECJPLNNGBBJIOJMJJAKEPODCAA.jens_hainmueller@ksg05.harvard.edu>
Date: 2005-04-21T03:43:41Z
From: jhainm@fas.harvard.edu
Subject: local average
In-Reply-To: <mailman.596.1114053472.1586.r-help@stat.math.ethz.ch>

Hello,

probably this isn't hard, but I can't get R to do this. Thanks for your
help!

Assume I have a matrix of two covariates:

n    <- 1000
Y    <- runif(n)
X    <- runif(n,min=0,max=100)
data <- cbind(Y,X)

Now, I would like to compute the local average of Y for each X interval 0-1,
1-2, 2-3, ... 99-100. In other words, I would like to obtain 100 (local)
Ybars, one for each X interval with width 1.

Also, I would like to do the same but instead of local means of Y obtain
local medians of Y for each X interval.

Best,
Jens