N <- 100
psi <- 5.0
limmag <- 6.3
# Simulate magnitudes
m <- rvmideal(N, limmag, psi)
# Variance-stabilizing transformation
tm <- vmidealVstFromMagn(m, limmag)
tm.mean <- mean(tm)
tm.var <- var(tm)
# Estimator for psi from the transformed mean
psi.hat <- vmidealVstToPsi(tm.mean, limmag)
# Derivative d(psi)/d(tm) at tm.mean (needed for the delta method)
dpsi_dtm <- vmidealVstToPsi(tm.mean, limmag, deriv.degree = 1L)
# Variance of the sample mean of tm
var_tm.mean <- tm.var / N
# Delta method: variance and standard error of psi.hat
var_psi.hat <- (dpsi_dtm^2) * var_tm.mean
se_psi.hat <- sqrt(var_psi.hat)
# Results
print(psi.hat)
print(se_psi.hat)
Run the code above in your browser using DataLab