### Linear Regression with R, on IQ for Gini and Linguistic Diversity

Reusing the code posted for Correlations within with Hofstede's Cultural Values, Diversity, GINI, and IQ, the same data can be used for linear regression:

Example Code
``````
# LM - Linear Regression

# Load the data into a matrix
oecdData <- read.table("OECD - Quality of Life.csv", header = TRUE, sep = ",")

# Access the vectors
v1 <- oecdData\$IQ
v2 <- oecdData\$HofstederPowerDx
v3 <- oecdData\$HofstederMasculinity
v4 <- oecdData\$HofstederIndividuality
v5 <- oecdData\$HofstederUncertaintyAvoidance
v6 <- oecdData\$Diversity_Ethnic
v7 <- oecdData\$Diversity_Linguistic
v8 <- oecdData\$Diversity_Religious
v9 <- oecdData\$Gini

# IQ ~ Gini
relation1 <- lm(v1 ~ v9)
print(relation1)
print(summary(relation1))

# IQ ~ Diversity_Linguistic
relation2 <- lm(v1 ~ v7)
print(relation2)
print(summary(relation2))
``````

Example Results
`````` > # Access the vectors
+ v1 <- oecdData\$IQ
+ v7 <- oecdData\$Diversity_Linguistic
+ v9 <- oecdData\$Gini
+
+ # IQ ~ Gini
+ relation1 <- lm(v1 ~ v9)
+ print(relation1)
+ print(summary(relation1))
+
+ # IQ ~ Diversity_Linguistic
+ relation2 <- lm(v1 ~ v7)
+ print(relation2)
+ print(summary(relation2))
Call:

lm(formula = v1 ~ v9)
Coefficients:
(Intercept)      v9
107.1884   -0.2487

Call:

lm(formula = v1 ~ v9)

Residuals:
Min   1Q       Median   3Q   Max
-6.3842 -2.4489 -0.0381 1.9954 6.6707

Coefficients:
Estimate Std. Error  t value Pr(>|t|)
(Intercept) 107.1884   4.7379 22.624  1.01e-15 ***
v9          -0.2487    0.1472 -1.689  0.107
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.27 on 20 degrees of freedom
(3 observations deleted due to missingness)
Multiple R-squared: 0.1248,     Adjusted R-squared: 0.08109
F-statistic: 2.853 on 1 and 20 DF, p-value: 0.1067

Call:

lm(formula = v1 ~ v7)

Coefficients:
(Intercept)      v7
99.0895    0.8328

Call:
lm(formula = v1 ~ v7)

Residuals:
Min   1Q      Median   3Q   Max
-7.1145 -1.5080 0.0149 2.3003 6.9105

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 99.0895   1.1035 89.793  <2e-16 ***
v7           0.8328   3.7034  0.225  0.824
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.491 on 20 degrees of freedom
(3 observations deleted due to missingness)
Multiple R-squared: 0.002522,     Adjusted R-squared: -0.04735
F-statistic: 0.05056 on 1 and 20 DF, p-value: 0.8244
``````

Example Plot

``````

```
```

Sample Data