-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.
-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.
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 r anova
You are not signed in. Login or sign up in order to post.
I believe that if you put together an example of data, it will be easier to help you
– Henrique Faria de Oliveira
I believe you do not need, because it is to say that the
idadeis a covariable.– Curious G.
I don’t understand why
idadewould not be considered as covariable in the syntaxaov(y ~ tratamento + idade, data = dt). Without providing the data or at least the output of the commandsummary(modelo), it’s impossible for anyone to help you.– Marcus Nunes
@Marcusnunes, I understood sorry I thought it was something more specific, I tried to improve my question. But I found out how it works.
– Curious G.
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árcio Mocellin
@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.
– Curious G.
This discussion is useless without the outputs of
summary(modelo)orstr(dt)are provided. As the question was posed,idademay 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). Oridademay be a factor withklevels for intervals of, say, five years. In this case,idadewould appear in the ANOVA table withk-1degrees of freedom, wherekis the number of levels ofidade. Everyone here, except the AP, is groping in the dark. Information is missing to give a definitive answer.– Marcus Nunes