Answer: The least squares equation or sum((x - mu)ˆ2), that sum is minimized by the empirical mean. Hence, we have
x<- c(0.725, 0.429, -0.372, 0.863)
mean(x)
## [1] 0.41125
The value of mu is 0.41125 which minimizes sum((x - mu)ˆ2) with the data set of x=c(0.725,0.429,-0.372 ,0.863).
Answer:
x<-c(0.725,0.429,-0.372 ,0.863)
w<-c(2, 2, 1, 1)
sum(x*w)/sum(w)
## [1] 0.4665
library(UsingR)
data(Galton)
head(Galton)
## parent child
## 1 70.5 61.7
## 2 68.5 61.7
## 3 65.5 61.7
## 4 64.5 61.7
## 5 64.0 61.7
## 6 67.5 62.2
setting
y=Galton$parent
x=Galton$child
yc= y- mean(y) ### centered
xc= x- mean(x) ### centered
sum(yc*xc)/sum(xc^2) ### the regression with y as the outcome and x as the predictor through the origin
## [1] 0.3256475
or we can have,
lm(formula = yc ~ xc -1)
##
## Call:
## lm(formula = yc ~ xc - 1)
##
## Coefficients:
## xc
## 0.3256