ancova for 3 categorial variable

Is there any R tool/script//package to do ANCOVA for 3 categorical variables?
e.g. i have normal weight, obese and overweight as a variable and glucose_before and glucose_after as a covariate (dependent and independent).
Kindly help me,

Thanks in advance,

The data described have one categorical variable, with three levels, and two continuous variables. An ANCOVA analysis would test differences in the levels of the response variable (the tripartite weight class) controlling for the variability in the glucose variables. An ANCOVA does not test the continuous variables against the categorical. See the VGAM package.

Thanks @technocrat for the reply and suggestion,
I checked the VGAM package but couldn't find an option for an ANCOVA analysis? i hope i didn't miss or is this analysis has a different name in VGAM.

Please see an attached image for an ANCOVA analysis i did in SAS studio, CRP_B and CRP_A are dependent and independent variables. Fish, soda, meat are my categories.

Please let me know if something like this is possible in R.


Let's start by abstracting the terminology away and look at the problem functionally in terms of f(x) = y.

x is an object containing two variables, Y_1 \& Y_2. Are they categorical or continuous? It also contains one or more variables X_i. Are the members of the set X_i all continuous, all categorical, all binary, or some combination? Some function, g measures the relationship between Y_1 \&Y_2 or Y_1 | Y_2 and X_i \dots X_n. As a return value y is a table of estimates and errors, etc. of main effects and interaction among factors produced by f.

Each of these roles must be mapped to the solution.

f may be lm with additive (X_i + X_{i+1}) or interactive X_i * X_{i+1} terms.
g is obtained by aov, which is a wrapper for f. See this helpful S/O thread

The VGAM package suggestion was more for the vignette. One of the difficulties in coming to R from SAS or another platform is mapping from the familiar to the unfamiliar. Approaching the task as function composition of objects to objects helps clarify the syntactical requirements in the new language.

Hi @technocrat,

Thanks for the link. It was very helpful and working for me now,
I will check with my previous data analyzed by SAS studio and cross-check properly,

My apologies for the late response,

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.