R Under development (unstable) (2024-10-16 r87241 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > require(OneStep) Loading required package: OneStep Loading required package: fitdistrplus Loading required package: MASS Loading required package: survival Loading required package: numDeriv Loading required package: parallel Loading required package: extraDistr > > n <- 1e3 > > #### standard student distribution #### > > #theta <- c("df"=3/2, "ncp"=1) > #o.sample <- rt(n, df = theta["df"], ncp = theta["ncp"]) > > #ML1 <- mledist(o.sample, "t", start=list("df"=2, "ncp"=0)) > #onestep(o.sample, "t", control=list(delta=1/2)) > #onestep(o.sample, "t", control=list(delta=.75)) > > #### location-scaled student distribution #### > > require(extraDistr) > > curve(dlst(x, 3/2), -10, 10) > > theta <- c("df"=3/2, "mu"=1, "sigma"=2) > o.sample <- rlst(n, df=theta["df"], mu=theta["mu"], sigma=theta["sigma"]) > > ML1 <- fitdist(o.sample, "lst", start=list("df"=10, "mu"=median(o.sample), "sigma"=IQR(o.sample)/2)) > OS1 <- onestep(o.sample, "lst", control=list(delta=0.4)) > OS2 <- onestep(o.sample, "lst", control=list(delta=0.8)) > > > cbind("theo"=theta, "MLE"=coef(ML1)[names(theta)], + "OS1"=coef(OS1)[c("df", "mu", "sigma")],"OS2"=coef(OS2)[c("df", "mu", "sigma")]) theo MLE OS1 OS2 df 1.5 1.304540 1.304389 1.302670 mu 1.0 1.045610 1.046276 1.047196 sigma 2.0 1.858703 1.858552 1.857783 > > proc.time() user system elapsed 1.90 0.32 2.18