I have an overall estimate of an effect based on many data strata. But I want to figure out the estimate based on each individual strata. The problem is that some strata have only a few points. On their own they build a point estimate for my effect. But that is over confident. I want to see the estimate of the effect based on their data, but without this over confidence.
Linear regerssion estimates determined goodness of fit based on how well the points fit to the line. Concretely, variance, σ2, is based on the mean squared error of the residuals:
And the goodness of fit is based on the variance.
Fixed effect meta-regression is similar except that we specificy the variance at each point because we have measured it.
So if I run a linear regression, get the estimate of σ2 and use it as my estimate variance for meta regression I should get the same result from both regressions. Right?
Lets find out.
# mean squared error
# thanks fbt: http://stats.stackexchange.com/a/107645/7494
mse <- function(sm) {
mse <- mean(sm$residuals^2)
return(mse)
}
# A little toy data
data <- data.frame(x = 1:10,
y = 1:10 + rnorm(10))
# Linear model
linear_model <- lm(y ~ x, data)
mean_squared_error <- mse(linear_model)
# Fixed effects model
library("metafor")
## Loading 'metafor' package (version 1.9-5). For an overview
## and introduction to the package please type: help(metafor).
fixed_effects_model <- rma(y,
rep(mean_squared_error, nrow(data)),
data = data,
mods = x,
method = "FE")
# Coefficients are the same (phew)
coefficients(linear_model)
## (Intercept) x
## -0.02928145 1.02143043
coefficients(fixed_effects_model)
## intrcpt mods
## -0.02928145 1.02143043
# Likelihoods are the same (yay!)
logLik(linear_model)
## 'log Lik.' -10.50677 (df=3)
logLik(fixed_effects_model)
## 'log Lik.' -10.50677 (df=2)
So we can see that the fixed effects model acts just like a linear model if we set the variances to be the same.