2
$\begingroup$

I have data of 50 students of a class as follows:

build : an ordered factor with levels 'low', 'medium' and 'high'
score :   a continuous variable (values 1-9)

What is the best way to find out if scores are different in 3 categories of 'build' and if they are rising or falling with 'build'?

I tried (without converting 'build' to a numeric variable) and could think only of regression analysis:

lm(score~build, data=mydata)

What is the best way to analyze such data by parametric as well as non-parametric methods? Thanks for your help.

Edit:

My specific question is "Is score affected by 'build' and if so, is it an ordered effect?"

I used following data and code:

> mydf = structure(list(buildchr = c("low", "low", "low", "low", "low", 
"low", "low", "low", "low", "low", "low", "low", "low", "low", 
"low", "low", "low", "medium", "medium", "medium", "medium", 
"medium", "medium", "medium", "medium", "medium", "medium", "medium", 
"medium", "medium", "medium", "medium", "medium", "medium", "high", 
"high", "high", "high", "high", "high", "high", "high", "high", 
"high", "high", "high", "high", "high", "high", "high"), score = c(1L, 
2L, 3L, 2L, 1L, 3L, 4L, 5L, 2L, 2L, 2L, 2L, 1L, 3L, 1L, 4L, 5L, 
6L, 5L, 4L, 4L, 2L, 5L, 6L, 5L, 4L, 3L, 5L, 6L, 2L, 3L, 5L, 6L, 
7L, 7L, 8L, 4L, 5L, 9L, 8L, 8L, 6L, 5L, 8L, 7L, 9L, 9L, 7L, 5L, 
6L), buildfac = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("low", "medium", 
"high"), class = "factor"), buildordfac = structure(c(1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L
), .Label = c("low", "medium", "high"), class = c("ordered", 
"factor"))), .Names = c("buildchr", "score", "buildfac", "buildordfac"
), row.names = c(NA, -50L), class = "data.frame")
> 
> head(mydf)
  buildchr score buildfac buildordfac
1      low     1      low         low
2      low     2      low         low
3      low     3      low         low
4      low     2      low         low
5      low     1      low         low
6      low     3      low         low


# REGRESSION WITH BUILD JUST AS CHARACTER:

> summary(lm(score~buildchr, data=mydf))

Call:
lm(formula = score ~ buildchr, data = mydf)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.9375 -0.9375  0.0625  1.0625  2.4706 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   6.9375     0.3670  18.903  < 2e-16 ***
buildchrlow     -4.4081     0.5113  -8.621 3.07e-11 ***
buildchrmedium  -2.3493     0.5113  -4.594 3.27e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.468 on 47 degrees of freedom
Multiple R-squared:  0.6127,    Adjusted R-squared:  0.5962 
F-statistic: 37.17 on 2 and 47 DF,  p-value: 2.087e-10





# REGRESSION WITH BUILD AS A FACTOR: 

> summary(lm(score~buildfac, data=mydf))

Call:
lm(formula = score ~ buildfac, data = mydf)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.9375 -0.9375  0.0625  1.0625  2.4706 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)      2.5294     0.3560   7.104 5.68e-09 ***
buildfacmedium   2.0588     0.5035   4.089 0.000168 ***
buildfachigh     4.4081     0.5113   8.621 3.07e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.468 on 47 degrees of freedom
Multiple R-squared:  0.6127,    Adjusted R-squared:  0.5962 
F-statistic: 37.17 on 2 and 47 DF,  p-value: 2.087e-10



# REGRESSION WITH BUILD AS AN ORDERED FACTOR:

> summary(lm(score~buildordfac, data=mydf))

Call:
lm(formula = score ~ buildordfac, data = mydf)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.9375 -0.9375  0.0625  1.0625  2.4706 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)     4.6850     0.2077  22.557  < 2e-16 ***
buildordfac.L   3.1170     0.3616   8.621 3.07e-11 ***
buildordfac.Q   0.1186     0.3579   0.331    0.742    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.468 on 47 degrees of freedom
Multiple R-squared:  0.6127,    Adjusted R-squared:  0.5962 
F-statistic: 37.17 on 2 and 47 DF,  p-value: 2.087e-10

The boxplots are as follows:

enter image description here

Result using anova are same for three types of 'build' variable:

> summary(aov(score~buildchr, mydf))
            Df Sum Sq Mean Sq F value   Pr(>F)    
buildchr     2  160.2   80.11   37.17 2.09e-10 ***
Residuals   47  101.3    2.16                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> summary(aov(score~buildfac, mydf))
            Df Sum Sq Mean Sq F value   Pr(>F)    
buildfac     2  160.2   80.11   37.17 2.09e-10 ***
Residuals   47  101.3    2.16                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



> summary(aov(score~buildordfac, mydf))
            Df Sum Sq Mean Sq F value   Pr(>F)    
buildordfac  2  160.2   80.11   37.17 2.09e-10 ***
Residuals   47  101.3    2.16                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

The results of character and factor form of build are similar, but those with ordered factor are different. Which one should I use and how to interpret results of ordered factor regression output?

$\endgroup$
4
  • $\begingroup$ Not to overdo it with semantics, but what does "best" mean to you? If you're dissatisfied with your regression approach maybe you could say why. $\endgroup$
    – rolando2
    Mar 26, 2015 at 3:29
  • $\begingroup$ By best I mean most appropriate. I am asking which test would you apply for this problem? Are there any other factors that will affect the choice of test? The sample size is 50. $\endgroup$
    – rnso
    Mar 26, 2015 at 3:33
  • $\begingroup$ Appropriate analyses depend on the substantive questions you want to answer, which you have not addressed. (Did you notice anything about the analysis that it returned? How did it differ from an unordered factor? ) $\endgroup$
    – Glen_b
    Mar 26, 2015 at 4:50
  • $\begingroup$ @Glen_b : I have edited my question to include the precise query as well as attempt at regression analysis. $\endgroup$
    – rnso
    Mar 26, 2015 at 8:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.