How to determine a covariable in the ANOVA model (r)

Asked

Viewed 96 times

-2

I have the following model:

modelo = aov(y ~ tratamento + idade, data = dt)

How do I determine that the idade is a specific command, or the model understands the levels of the variable in question.

  • I believe that if you put together an example of data, it will be easier to help you

  • I believe you do not need, because it is to say that the idade is a covariable.

  • I don’t understand why idade would not be considered as covariable in the syntax aov(y ~ tratamento + idade, data = dt). Without providing the data or at least the output of the command summary(modelo), it’s impossible for anyone to help you.

  • @Marcusnunes, I understood sorry I thought it was something more specific, I tried to improve my question. But I found out how it works.

  • 1

    This is a matter of nomenclature. For @Curiousg. , if the column has the class (class) "factor" then is a "treatment" and if it is "integer", "Numeric" is a covariable. I wonder how he classifies "Character", "Complex", "Date" and "Logical". For me everything on the side of x’s is covariable.

  • @Márciomocellin, but R understands that everything on the side of x’s is covariable? From what I saw the table of ANOVA changes with the nomenclature.

  • 1

    This discussion is useless without the outputs of summary(modelo) or str(dt) are provided. As the question was posed, idade may be defined in years, which implies that it is a variable with 1 degree of freedom in the ANOVA table (or ANCOVA if we want to be precious). Or idade may be a factor with k levels for intervals of, say, five years. In this case, idade would appear in the ANOVA table with k-1 degrees of freedom, where k is the number of levels of idade. Everyone here, except the AP, is groping in the dark. Information is missing to give a definitive answer.

Show 2 more comments

2 answers

1


I thank the comments above. In fact, to determine a variable as a factor or covariable, it is how it is classified in the database. As a factor or numerical, to know how it is classified (format), just use the str for this information, in my case str(dt). For the variable to be considered a covariable it is enough to be in the numerical format, while to be "treatment" in the factor format. I hope I have been clear. Suggestions to improve my response are welcome.

1

Well, really without some information as already mentioned, it gets a little obscure.

Next time try making one dput() so that we can help better. If you don’t want to display the original data, create a df that contains the basics.

Anyway I think you want the following:

modelo = lm(y ~ tratamento + factor(idade), data = dt)
anova(modelo)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.