| ccor_posim | R Documentation |
Inputs raw data representing two curves, and computes a credible interval for the curve correlation between them simulating from the approximate posterior distribution of the joint spline coefficient vector.
ccor_posim(
y,
time,
curve = NULL,
method,
k = 15,
conf = 0.95,
ndraw = 999,
min.overlap = 0
)
y, time, curve, k, min.overlap |
see |
method |
|
conf |
confidence level |
ndraw |
number of draws from posterior distribution of spline coefficient vector |
A list with components
cor |
curve correlation |
model |
the model for the two curves (if |
bsb |
B-spline basis (from package |
Vc.fda |
corrected posterior covariance matrix for the coefficients with respect to the B-spline basis |
sims |
curve correlations for the |
ci |
credible interval for the curve correlation |
Philip Tzvi Reiss <reiss@stat.haifa.ac.il>, Noemi Foa, Dror Arbiv and Biplab Paul <paul.biplab497@gmail.com>
ccor, ccor_boot, mvn
## Not run:
if (interactive () &&
requireNamespace("wbwdi", quietly = TRUE) &&
requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("dplyr", quietly = TRUE)) {
# Curve correlation of per capita GDP and fertility rate in Paraguay
wdi_dat <- wbwdi::wdi_get(entities = c("PRY"), start_year=1960, end_year=2023,
indicators = c("NY.GDP.PCAP.KD","SP.DYN.TFRT.IN"), format="wide") |>
dplyr::rename(percapitaGDP = NY.GDP.PCAP.KD, fertility = SP.DYN.TFRT.IN)
ggplot2::ggplot(wdi_dat, aes(percapitaGDP, fertility, color=year)) + geom_point()
y <- as.matrix(wdi_dat[ , c("percapitaGDP", "fertility")])
set.seed(345)
ci <- list()
ci[[1]] <- ccor_posim(y=y, time=wdi_dat$year, method="indep")
ci[[2]] <- ccor_posim(y=y, time=wdi_dat$year, method="mvn")
ci[[3]] <- ccor_boot(y=y, time=wdi_dat$year, ndraw=399)
tabl <- matrix(NA, 3, 3)
for (k in 1:3) tabl[k, ] <- c(ci[[k]]$cor, ci[[k]]$ci)
dimnames(tabl) <- list(c("Posim_indep", "Posim_MVN", "Bootstrap"), c("Est","Lower95","Upper95"))
round(tabl, 4)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.