NORTHLANDS - REGRESSING ON SMOOTHED POPULATION

EXPLORING THE DATA

Reading:

northlands = read.csv("Canada_raw.csv")

Monotonizing

Asc <- function(dataColumn) {
    r = max(dataColumn) - dataColumn
}
northlands[, 8] = Asc(northlands[, 4])
northlands[, 9] = Asc(northlands[, 5])
northlands[, 10] = Asc(northlands[, 6])
head(northlands)
##   Row Column SmoothPop Elevation River Port Temperature   V8     V9   V10
## 1 546    475     1.514       566 607.6 1461       258.0 4843 112.14 82.87
## 2 547    473     2.103       233 641.5 1471       257.8 5176  78.20 72.40
## 3 547    475     2.275       166 666.0 1472       258.0 5243  53.73 72.00
## 4 548    466     1.981       871 543.8 1458       273.1 4538 175.93 85.48
## 5 548    468     2.265       342 548.2 1458       273.1 5067 171.51 85.61
## 6 548    469     2.422       871 548.2 1453       258.9 4538 171.51 90.38

PCA

northlands_pca <- prcomp(northlands[, 7:10], scale = TRUE)
summary(northlands_pca)
## Importance of components:
##                          PC1   PC2   PC3    PC4
## Standard deviation     1.555 0.985 0.668 0.4059
## Proportion of Variance 0.605 0.242 0.112 0.0412
## Cumulative Proportion  0.605 0.847 0.959 1.0000
plot(northlands_pca)

plot of chunk unnamed-chunk-4

print(northlands_pca)
## Standard deviations:
## [1] 1.5554 0.9846 0.6683 0.4059
## 
## Rotation:
##                 PC1      PC2     PC3       PC4
## Temperature  0.5937 -0.02587  0.3770  0.710419
## V8          -0.1882 -0.96167  0.1987  0.016832
## V9           0.5113 -0.26879 -0.8163 -0.003859
## V10          0.5922 -0.04765  0.3899 -0.703567
cor(scale(northlands$SmoothPop), northlands_pca$x[, 1])
##        [,1]
## [1,] 0.1414
plot(scale(northlands$SmoothPop), northlands_pca$x[, 1])

plot of chunk unnamed-chunk-5

LATENT

library(lavaan)
## This is lavaan 0.5-16
## lavaan is BETA software! Please report any bugs.
latentSatisfaction <- " satisfaction  =~ Elevation + V8 + V9 + V10"
fit <- cfa(latentSatisfaction, data = northlands)
x = predict(fit)
cor(scale(northlands$SmoothPop), x)
##      satisfaction
## [1,]     -0.01239