Title: | Regression Toward the Mean |
---|---|
Description: | In repeated measures studies with extreme large or small values it is common that the subjects measurements on average are closer to the mean of the basic population. Interpreting possible changes in the mean in such situations can lead to biased results since the values were not randomly selected, they come from truncated sampling. This method allows to estimate the range of means where treatment effects are likely to occur when regression toward the mean is present. 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.<doi:10.1186/1471-2288-8-52>. |
Authors: | Daniela Recchia [aut, cre], Thomas Ostermann [ctb] |
Maintainer: | Daniela Recchia <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1 |
Built: | 2024-11-10 03:44:38 UTC |
Source: | https://github.com/cran/regtomean |
This function calculates the correlation for the data and Cohen's d effect sizes, both based on pooled and on treatment standard deviations.
cordata(Before,After,data)
cordata(Before,After,data)
Before |
a numeric vector giving the data values for the first (before) measure. |
After |
a numeric vector giving the data values for the second (after) measure. |
data |
an optional data frame containing the variables in the formula. By |
This function computes the correlation between both measures as also both effect sizes based on Cohen's d statistic.
The inputs must be numeric.
Return a table containing the correlation, effect size pooled and effect size based on treatment.
Daniela R. Recchia, Thomas Ostermann.
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). New York:Academic Press.
cordata("Before","After",data=language_test)
cordata("Before","After",data=language_test)
A dataset with scores from 8 students who failed a high school test and could not get their diploma. They repeated the exam and got new scores.
data("language_test")
data("language_test")
A data frame with 8 observations on the following 9 variables.
Student
a numeric vector
Before
a numeric vector
After
a numeric vector
a numeric vector
Cross
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
McClave, J.T; Dietrich, F.H.:"Statistics";New York, Dellen Publishing; 1988.
data(language_test) ## maybe str(language_test) ; plot(language_test) ...
data(language_test) ## maybe str(language_test) ; plot(language_test) ...
This function calculates and plots treatment and regression effects of both before and after measures as also its p-values.
meechua_eff.CI(x,n,se.after)
meechua_eff.CI(x,n,se.after)
x |
a data frame containing the results from |
n |
the original sample size (number of observations) from data. |
se.after |
the estimated standard error from |
After performing the meechua_reg
the model coefficients mod_coef
as also its global variable se.after
are used as input in this function to estimate treatment and regression effects.
Two plots are performed, the first "Treatment Effect and p-value" and the second "Confidence Intervals" for mu
.
Daniela R. 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.
# First perform replicate_data and meechua_reg replicate_data(50,60,"Before","After",data=language_test) mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort) # Model coeeficients (mod_coef) and se.after are stored in the environment # as a result from the function meechua_reg meechua_eff.CI(mod_coef,8,se.after)
# First perform replicate_data and meechua_reg replicate_data(50,60,"Before","After",data=language_test) mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort) # Model coeeficients (mod_coef) and se.after are stored in the environment # as a result from the function meechua_reg meechua_eff.CI(mod_coef,8,se.after)
meechua_reg
This functions plots all 4 diagnostics plots for each linear regression model: "Residuals vs Fitted", "Normal Q-Q", "Scale-Location" and "Residuals vs Leverage".
meechua_plot(x)
meechua_plot(x)
x |
List containing the estimated linear models from |
For each model from models
4 diagnostic plots are performed. For the first model the numbers 1 to 4 should be given, for the second model numbers from to 8 to 12, and so on.
Diagnostics plots for the set of models from meechua_reg
.
Daniela R. 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.
# models are an output from meechua_reg replicate_data(50,60,"Before","After",data=language_test) mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort) #models are the output from meechua_reg saved in the environment after running the function meechua_plot(models)
# models are an output from meechua_reg replicate_data(50,60,"Before","After",data=language_test) mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort) #models are the output from meechua_reg saved in the environment after running the function meechua_plot(models)
This function fit linear models for a subset of data frames.
meechua_reg(x)
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
.
Global variables models
, mod_coef
, se_after
are stored for further analysis.
The models are saved in an obejct called mee_chua
, which is not automatically printted but is saved in the environment.
Daniela R. 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.
## get the values ## mee_chua<-replicate_data(50,60,"Before","After",data=language_test) ## sort mu ## mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort)
## get the values ## mee_chua<-replicate_data(50,60,"Before","After",data=language_test) ## sort mu ## mee_chua_sort <- mee_chua[with(mee_chua,order(mu)),] meechua_reg(mee_chua_sort)
This function replicates 100 times the before and after values giving a start and end reference.
replicate_data(start,end,by=NULL,Before,After,data)
replicate_data(start,end,by=NULL,Before,After,data)
start |
a start value for mu. |
end |
an end value for mu. |
by |
an increment for the sequence, if not informed (default) the increment is caluculated as the difference between |
Before |
a numeric vector giving the data values for the first (before) measure. |
After |
a numeric vector giving the data values for the second (after) measure. |
data |
an optional data frame containing the |
.
In order to overcome the limitation of Mee and Chua's test regarding the population mean mu
a replication of the data is performed.
After replicating the data the unknown population mean mu
is systematically estimated over a range of values. Further estimations will be based on this new dataset.
Return a data frame we could call mee_chua
containing the values for mu
, before
and after
.
Daniela R. 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.
Galton, F. (1886). Regression towards mediocrity in heriditary stature. Journal of the Anthropological Institute (I5: 246-263).
replicate_data(50,60,"Before","After",data=language_test)
replicate_data(50,60,"Before","After",data=language_test)