1
$\begingroup$

I'm trying to check a relationship between two variable. one with three levels and other is with 7 levels.
one variable is overall_sentiment with (Positive, Negative, Neutral) other is comments_created_at with (Monday, Tuesday, Wed, Thu, Fri, sat, sun)

I have to put Overall_sentiment as dependent variable for regression. I know for 2 level we can use glm().

As there is three levels in dependent variable what should I do. I ran the model using glm function it worked. But I don't know how to interpret the result.

m <- glm(as.numeric(Meteor$overall_sentiment) ~ comments_created_at, data = Meteor)
summary(m)

OUTPUT

Call:
glm(formula = as.numeric(Meteor$overall_sentiment) ~ comments_created_at, 
    data = Meteor)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3364  -0.3364   0.6636   0.7030   0.7821  

Coefficients:
                        Estimate Std. Error t value Pr(>|t|)    
(Intercept)             2.296965   0.011820 194.320  < 2e-16 ***
comments_created_atMon -0.005070   0.017018  -0.298 0.765751    
comments_created_atSat -0.037599   0.021351  -1.761 0.078258 .  
comments_created_atSun -0.079039   0.023320  -3.389 0.000701 ***
comments_created_atThu -0.007945   0.016532  -0.481 0.630832    
comments_created_atTue  0.039464   0.015337   2.573 0.010083 *  
comments_created_atWed  0.005864   0.015871   0.369 0.711762    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 0.6582407)

    Null deviance: 20097  on 30501  degrees of freedom
Residual deviance: 20073  on 30495  degrees of freedom
AIC: 73814

Number of Fisher Scoring iterations: 2
$\endgroup$
1
  • $\begingroup$ You didn't indicate the family of response (binomial), and your model made a linear regression fit. It is a possible way to solve your task, but first of all, you have to manage your response variable so that 1 = negative, 2 = neutral, and 3 = positive (ordinal scale)... What you did may be very different, and results became simply misleading. Also, you don't necessarily need glm, you can start off with lm. $\endgroup$ Commented Sep 12, 2019 at 13:42

1 Answer 1

0
$\begingroup$

Your response factor overall_sentiment with levels (Positive, Negative, Neutral)` looks like ordinal, so I would start out trying ordinal logistic regression. There are many posts on this site.

But you used the usual glm function, but without a family argument. That gives you a linear regression model (with assumption about gaussian errors), and you converted the response to numerical! That gives you nonsensical results, period. Don't try to interpret that output, start anew. If you had used the somewhat more sensible family=binomial argument, then the following excerpt from the R help page is relevant:

For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success)

But neither is that what you want! For ordinal logistic regression in R, start with for instance or How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values?.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.