View source: R/cap07-tamanho-guarda-chuva.R
| razao_vs_regressao_decidir | R Documentation |
Convenience "umbrella" function that fits the regression model, tests whether the line passes through the origin, and computes both the ratio and the regression estimators of the population mean side by side, clearly flagging which one the origin test recommends – following the full workflow of Examples 7.1-7.2 of the course notes. This lets students and instructors compare both estimators even when only one is formally "correct" for the data at hand.
razao_vs_regressao_decidir(x, y, X_barra, N, conf = 0.95, ...)
x |
Numeric vector with the auxiliary variable. |
y |
Numeric vector with the variable of interest. |
X_barra |
Known population mean of the auxiliary variable
(required for the regression estimator; not required for the ratio
estimator, whose mean form only needs |
N |
Population size. |
conf |
Confidence level, default |
... |
Ignored. Any other variables from a broader problem statement may be passed here without causing an error. |
The function itself does not write anything to the console; print the returned object (or just type its name) to see a side-by-side summary.
An object of class razao_vs_regressao: a named list with
elements teste (from reg_teste_origem()), razao (from
razao_estima_media()), and regressao (from reg_estima_media()),
plus a recomendado character scalar. It has a print() method.
x <- c(1, 30, 44, 20, 0, 10, 15, 5, 2, 50, 35, 25)
y <- c(2, 35, 50, 27, 1, 15, 17, 7, 0, 53, 35, 30)
res <- razao_vs_regressao_decidir(x, y, X_barra = 10, N = 1500)
res$recomendado
print(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.