1
$\begingroup$

I have a dataset of 30.000+ observations. For my thesis I am investigating the effect of the weather on rating scores. For a subquestion I need to compare the effect of precipitation on the review score for people from different countries. specifically: I’m trying to find out if the effect of precipitation on the rating score is higher for people from countries where the yearly average precipitation is lower. I ran the regression models for all different countries in the dataset and I am wondering how to best proceed from here. How can you test whether the effect of one country is significantly higher than that from another country to test if the hypothesis is true?

This are the models:

regression per country
by_country <- group_by(data3, Land, AVGpercipmm)

data_grouped <-do (by_country, glance(lm(Overallrating ~ DailyprecipIntensitydummy + DailyprecipAccumulationdummy + Numberofreviews, type="text", data = .)))

data_grouped2 <-do (by_country, tidy(lm(Overallrating ~ DailyprecipIntensitydummy + DailyprecipAccumulationdummy + Numberofreviews, type="text", data = .)))

part of the data:

enter image description here

output data_grouped https://docs.google.com/spreadsheets/d/1eOi10fiqIFSHVXZLYNnAHoxlP1YtUPEDyO6pjBKA6iM/edit?usp=sharing

output data_grouped2 https://docs.google.com/spreadsheets/d/1-EL0-TsU9PlbKxi8xU0vIaq7JVT381msG0ZmF5xVBv4/edit?usp=sharing

Thank you in advance!

$\endgroup$
6
  • 1
    $\begingroup$ Could you explain why you are using country as an explanatory variable in your model when your stated purpose is to use precipitation? $\endgroup$ – whuber Jun 11 '19 at 11:04
  • $\begingroup$ They haven't used country in the model, as the state theyhave been grouped by country and the model run within each (I'm guessing by_country is is the result of group_by), see the first under Other Examples. The outcome/dependant is Overallrating whilst the predictor/independents are DailyprecipIntesnitydummy, DailyprecipAccumulationdummy and Numberofreviews. $\endgroup$ – slackline Jun 11 '19 at 11:52
  • $\begingroup$ Further the stated question is How can you test whether the effect of one country is significantly higher than that from another country to test if the hypothesis is true? so whilst precipitaion is of interest it is asking whether this differs between countries. $\endgroup$ – slackline Jun 11 '19 at 11:55
  • $\begingroup$ @Slack Thank you for those clarifications. The governing question appears to be different than what you state; namely, "to find out if the effect of precipitation on the rating score is higher for people from countries where the yearly average precipitation is lower." $\endgroup$ – whuber Jun 11 '19 at 12:05
  • $\begingroup$ Thanks for providing some output @Evelien unfortunately I can not see the column names. Its preferable if you can copy and paste the results in rather than taking a screen capture, if you indent every line by four spaces or surround the paste with double back-ticks as you've done with your code chunk its easier to read. $\endgroup$ – slackline Jun 11 '19 at 12:06
0
$\begingroup$

It would be useful if you could show the output.

However if you want to know whether there is any differences between countries you could include country as a dummy variable in your model. A simple way would be to

lm(Overallrating ~ DailyprecipIntensitydummy + DailyprecipAccumulationdummy + Numberofreviews + Country, type="text", data = by_country)

However, you might want to consider a Generalised Linear Mixed Model (see also here for resources and lots of examples in R and a very good introduction Introduction to Generalized Linear Mixed Models), and include Country as a random effect.

The lme4 package allows you to do this and and has an excellent paper with worked examples on using it (see here). Without knowing more about your data structure something like the following would be a start...

library(lme4)
glmer(Overallrating ~ DailyprecipIntensitydummy + DailyprecipAccumulationdummy + Numberofreviews | Country, data=by_country)
$\endgroup$
4
  • 1
    $\begingroup$ I am curious how either of these recommendations could advance the OP's objective of relating ratings to precipitation: could you indicate how that could be done? $\endgroup$ – whuber Jun 11 '19 at 11:04
  • $\begingroup$ They stated I ran the regression models for all different countries this to me seems folly as it raises the problem of multiple testing. Rather you want to account for the variation in rating that is attributable to precipitation whilst also adjusting for the variation that is attributable to country, which is why I've suggested these two approaches. The GLMM approach would be my preference as I would expect some clustering based on country. $\endgroup$ – slackline Jun 11 '19 at 11:48
  • $\begingroup$ Thank you for your quick answer! I added a small part of the output. My thought was to remove the countries that don't have enough observations to be informative and then compare the slopes in some way, but I understand you don't think that is a good idea so that is also very helpful. I will definitely give this a try! $\endgroup$ – Evelien van der Waal Jun 11 '19 at 12:06
  • $\begingroup$ That makes sense, slackline, but what would be the meaning of DailyprecipIntensitydummy and DailyprecipAccumulationdummy? Those would appear to be redundant with country and, from their names, would not even quantitatively represent precipitation. I think we need some definitions of the variables from the OP in order to formulate sensible answers. $\endgroup$ – whuber Jun 11 '19 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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