meechua_reg | R Documentation |
This function fit linear models for a subset of data frames.
meechua_reg(x)
x |
Data to be used in the regression. |
The data used for the regression must be sorted by mu
.
A set of linear models
will be estimated and model coefficients are saved and stored in mod_coef
.
The estimated standard errror for the after
measure is also stored in se_after
to be used further in other functions.
A table containing the estimations for each mu
.
The variables models
, mod_coef
, se_after
are stored globally for further analysis if to_global
is set to TRUE. In any case the values will be returned.
The models are saved in an object called mee_chua
, which is not automatically printed but is saved in the environment.
Daniela Recchia, Thomas Ostermann.
Ostermann, T., Willich, Stefan N. & Luedtke, Rainer. (2008). Regression toward the mean - a detection method for unknown population mean based on Mee and Chua's algorithm. BMC Medical Research Methodology.
lm,dlply
# Generate example data
language_test <- data.frame(
Before = rnorm(100, mean = 50, sd = 10),
After = rnorm(100, mean = 55, sd = 10)
)
# Replicate data
replicate_data <- function(start, end, Before, After, data) {
mu <- seq(start * 100, end * 100, by = (end - start))
mu <- rep(mu, each = nrow(data))
before <- data[[Before]] - mu / 100
after <- data[[After]]
mee_chua <- data.frame(mu = mu, before = before, after = after)
return(mee_chua)
}
mee_chua <- replicate_data(0, 1, "Before", "After", data = language_test)
mee_chua <- mee_chua[order(mee_chua$mu), ] # Sortieren nach 'mu'
# Regression ausführen und Ergebnisse erhalten
reg_results <- meechua_reg(mee_chua)
# Zugriff auf Ergebnisse
mod_coef <- reg_results$mod_coef
se_after <- reg_results$se_after
# Anzeigen der Ergebnisse
print(mod_coef)
print(se_after)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.