Closed wleoncio closed 3 years ago
- SE not yet implemented for different sample sizes ANOVA table for schools, q1
This is also pointed out on issue #22. The warning is expected and will not be addressed on the next release.
- When setting “cor_matrix” and “rho” together, there’re cases when true values and estimated values having a large difference.
This behavior is expected given the small sample size of 10 schools in n7
. On average, however, those numbers converge to the expected values. See, for example, how the following code:
sample_size <- 1000
rho_hat <- matrix(nrow=sample_size, ncol=2)
for (i in seq_len(sample_size)) {
cr1 <- cluster_gen_2(n7, n_X=2, n_W=2, cor_matrix=m1, rho=c(0.1, 0.2))
rho_hat[i, ] <- c(
anova_table(cr1, calc.se=FALSE, print=FALSE)$population$q1[[3]],
anova_table(cr1, calc.se=FALSE, print=FALSE)$population$q2[[3]]
)
}
apply(rho_hat, 2, mean)
generates the following output (your values may change slightly):
[1] 0.1268647 0.2156342
The code above is basically 1000 replications of the same cr1
generation procedure.
Another example: see how increasing the sample size (instead of the number of replications) also results in converging rhos:
n7_200 <- list(school = 200, student = ranges(10, 50))
cr1_200 <- cluster_gen_2(n7_200, n_X=2, n_W=2, cor_matrix=m1, rho=c(0.1, 0.2))
anova_table(cr1_200, calc.se=FALSE)
ANOVA table for schools, q1
ANOVA estimators
Source Sample.statistic Population.estimate
1 Within-group variance 3.6073815 3.6073815
2 Between-group variance 0.7638303 0.6042921
3 Total variance 4.2082910 NA
Intraclass correlation
Estimated Standard.error
q1 0.1434803 NA
Testing for group differences
F-statistic: 4.78776 on 199 and 4326 DF. p-value: 2.395365e-86
ANOVA table for schools, q2
ANOVA estimators
Source Sample.statistic Population.estimate
1 Within-group variance 0.6380039 0.6380039
2 Between-group variance 0.2504619 0.2222459
3 Total variance 0.8590057 NA
Intraclass correlation
Estimated Standard.error
q2 0.2583505 NA
Testing for group differences
F-statistic: 8.876588 on 199 and 4326 DF. p-value: 8.724305e-201
cr13 <- cluster_gen_2(n13, n_X=1, n_W=2, cor_matrix=m2, rho=0.7) Error in check_condition((!is.null(names(n)) | !is.null(names(N))) & (!is.null(cluster_labels) | : object 'n13' not found
This is expected since the n13
object is missing (it should be created by the user, since it's being manually plugged into cluster_gen_2()
.
0. Setup
I've tested most values below. Not all testings are shown in this report. I only included the testings that are showing errors/warnings or inconsistent results.
9. cor_matrix & rho
Error and warning messages