data<-read.csv("reg_herit_corr.csv", header=T)
attach(data)
head(data)
## Pair Parent Offspring
## 1 1 21.6 22.3
## 2 2 20.3 21.0
## 3 3 20.6 19.4
## 4 4 31.2 23.6
## 5 5 20.4 28.2
## 6 6 25.4 23.8
str(data)
## 'data.frame': 20 obs. of 3 variables:
## $ Pair : int 1 2 3 4 5 6 7 8 9 10 ...
## $ Parent : num 21.6 20.3 20.6 31.2 20.4 25.4 26.6 21.4 23.6 24.6 ...
## $ Offspring: num 22.3 21 19.4 23.6 28.2 23.8 25.6 24.2 20.9 29.2 ...
### Fit a linear regression model
model <- lm(Offspring ~ Parent)
### Summary of the regression model
summary(model)
##
## Call:
## lm(formula = Offspring ~ Parent)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.4515 -1.1235 -0.2818 0.5050 5.0817
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 22.4776 3.8638 5.817 1.64e-05 ***
## Parent 0.0667 0.1572 0.424 0.676
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.503 on 18 degrees of freedom
## Multiple R-squared: 0.009906, Adjusted R-squared: -0.0451
## F-statistic: 0.1801 on 1 and 18 DF, p-value: 0.6763
plot(Parent, Offspring,
main = "Offspring vs Parent",
xlab = "Parent",
ylab = "Offspring",
pch = 4, col = "blue")
###fitted values with line
# Same plot as above
plot(Parent, Offspring,
main = "Offspring vs Parent (with fitted line)",
xlab = "Parent",
ylab = "Offspring",
pch = 4, col = "blue")
lines(Parent, fitted(model), col = "red", lwd = 2)
### Heritability estimate
heri_reg <- 2*coef(model)[2] # The slope coefficient
print(paste("Heritability estimate:", round(heri_reg, 2)))
## [1] "Heritability estimate: 0.13"
## Heritablility using the correlation method
Parent_num <- as.numeric(as.character(Parent))
Offspring_num <- as.numeric(as.character(Offspring))
heri_cor <- 2 * cor(Parent_num, Offspring_num)
print(heri_cor)
## [1] 0.1990625
#### heritability using the covariance method
covariance <- cov(Parent_num, Offspring_num)
variance_parent <- var(Parent_num)
variance_offspring <- var(Offspring_num)
heri_cov <- 2 * (covariance / sqrt(variance_parent * variance_offspring))
print(paste("Heritability estimate:", round(heri_cov, 2)))
## [1] "Heritability estimate: 0.2"
Heritability in the narrow sense (ℎ²) can often be estimated as the slope of the regression line of offspring on parent (or mid-parent). Here’s how to interpret it:
The red line has a slight positive slope , meaning there is some genetic resemblance between parents and offspring.
However, the slope is very shallow , suggesting low heritability .
In other words, while offspring tend to slightly resemble their parents, much of the variation may be due to environmental factors or non-additive genetics .
The points are widely scattered around the line, which means the fit of the model is weak .
This reinforces the idea that parental traits explain only a small portion of offspring traits —another sign of low heritability.
heri_reg <- 2 * coef(model)[2]
Estimate: **0.13**
### 3. **Correlation Method**
`heri_cor <- 2 * cor(Parent_num, Offspring_num)`
Estimates heritability as twice the Pearson correlation between parent and offspring traits.
Estimate: 0.20
Interpretation : About 20% of the variation in offspring traits is due to resemblance with parents. Again, this reflects low heritability.
heri_cov <- 2 * (cov(Parent_num, Offspring_num) / sqrt(var_parent * var_offspring))
This uses covariance standardized by variances (like correlation), then multiplies by 2.
Estimate: 0.20
Interpretation : Also suggests low additive genetic influence .
Summary :
All three methods aim to estimate narrow-sense heritability , and values are fairly close (0.13 to 0.20).
The regression estimate is slightly lower because it is sensitive to the scaling and distribution of variables.
Correlation and covariance-based methods give identical results in this case because they are mathematica