R. Quiero excluir valores en un ANOVA con un bucle

I would like to check for the influence of the datapoints I use for an anova by excluding them:

wanted =(1:10 !=10)
wanted
summary(aov(log(Sdrtl)~location,subset=wanted))

In stead of excluding 1:10 manually, I would like to make some kind of loop so that all anova's flow out at once. I'm a beginner and I tried following:

for (i in 1:10){
    wanted =(1:10 !=i)
        summary(aov(log(Sdrtl)~location,subset=wanted))
    }

, which does not give what I want. Can someone help me out?

preguntado el 01 de febrero de 12 a las 22:02

2 Respuestas

Supongo que el problema es que summary doesn't print anything - it returns an object (which you ignore).

# This will print the summaries
for(i in 1:10) print(summary(aov(log(Sdrtl)~location, subset=1:10!=i)))

# This will return a list of all summaries
x <- lapply(1:10, function(i) summary(aov(log(Sdrtl)~location, subset=1:10!=i)))
x # prints the summaries

The second version is more useful since you can store the result and analyze it...

Respondido 02 Feb 12, 02:02

Have you checked to see whether the influence.measures function in base R already does what you want? It computes a range of leave-one-out diagnostics ...

Respondido 02 Feb 12, 02:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.