# Compare linear regression models for same variables but different data

I have created a linear regression model for height and weight using UK data, and want to compare this with the height and weight relationship of other countries. What would be an appropriate method to compare?

The aim is to see for example if the relationship between height and weight in the UK is similar to Canada for example.

• Are you trying to determine if people from Canada, for example, are shorter/taller than people form the UK of the same weight? Commented Apr 8, 2020 at 16:19
• @DemetriPananos yes that is pretty much it Commented Apr 9, 2020 at 8:40
• Combine the data from different countries together and use a binary indicator for country. This is a fairly standard technique in statistics. Commented Apr 9, 2020 at 16:16
• Do you want to know if the weights will be the same or if the slopes (increase in weight for a given increase in height) will be the same. The existing answers only address the former.
– Dave
Commented Apr 11, 2020 at 18:22
• @Dave I had not considered analysing the slopes but I suppose I could via comparison of the gradient? Commented Apr 14, 2020 at 16:58

I Agree with Demetri Pananos.

Creating a new variable indicating the country and binding the data will work.

UKdata<- as.data.frame(cbind('weight' = rnorm(20, 70, 20),
'height' = rnorm(20, 155, 30)))
CANdata<- as.data.frame(cbind('weight' = rnorm(20, 70, 20),
'height' = rnorm(20, 155, 30)))

UKdata$$country <- 'UK' CANdata$$country <- 'CAN'
newdata<- rbind(UKdata, CANdata)

mod1<- lm(weight~height+country, data = newdata)
summary(mod1)


The output will be

Call:
lm(formula = weight ~ height + country, data = newdata)

Residuals:
Min      1Q  Median      3Q     Max
-33.982  -9.093  -0.251  10.185  49.469

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 53.63128   17.26453   3.106  0.00363 **
height       0.07454    0.10436   0.714  0.47956
countryUK   -3.82033    5.69030  -0.671  0.50615
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 17.99 on 37 degrees of freedom
Multiple R-squared:  0.02528,   Adjusted R-squared:  -0.02741
F-statistic: 0.4798 on 2 and 37 DF,  p-value: 0.6227


If you intend to go for ANCOVA

library(car)
mod2<- aov(weight~height+country, data = newdata)
Anova(mod2, type = 'III')


and the output will be

Anova Table (Type III tests)

Response: weight
Sum Sq Df F value   Pr(>F)
(Intercept)  3124.6  1  9.6500 0.003626 **
height        165.2  1  0.5101 0.479563
country       145.9  1  0.4507 0.506151
Residuals   11980.4 37
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

• thank you I found this particularly useful, however I am curious how to analyse the outputs here regarding the comparison between countries? Commented Apr 14, 2020 at 16:59
• @j.doe Country is nominal and so in first model (lm), the country will be aoutomaticatlly coded into binary (0=CAN, 1=UK). The expression will be "weight = 53.63128 + 0.07454*height+ (0 for CAN; -3.82033 for UK)". In this sample, the Pr(>|t|) for countryUK is 0.50615 (>.05) which means that the country does not signficantly impacts weight. Model2 (ANCOVA): Here, height is covariate. In simple terms it is to test whether, weights of the people significant differ with country after adjusting the effect of height. Pr(>F) is 0.506151 (>0.05) which means there is no significant difference. Commented Apr 14, 2020 at 17:53
• @j.doe There is no much difference between both the models. The F values in the second model are the squares of the corresponding t values in the first model. Also, the corresponding probabilities are same. Commented Apr 14, 2020 at 17:54
• Thank you, the summary only mentions 'countryUK' should I find a way so that the summary includes 'countryCAN'? Or is it redundant as if countryUK doesn't significantly impact the weight than neither will countryCAN? Commented Apr 15, 2020 at 21:08
• CountryUK has been set as a reference category. It is implied that the coefficient if CountryCAN is the change in dependent variable when the country changes from CountryUK. If you have three categories in country, you will get two coefficients in the output, Commented Apr 15, 2020 at 22:53