fit_t_dist_fixed_mu: use optim() to fit a t-distribution with fixed mu=0

View source: R/util_generic.R

fit_t_dist_fixed_muR Documentation

use optim() to fit a t-distribution with fixed mu=0

Description

use optim() to fit a t-distribution with fixed mu=0

Usage

fit_t_dist_fixed_mu(x)

Arguments

x

numeric vector of at least 10 finite values

Examples

## Not run: 
# fit normal
x = rnorm(1000, sd = 2)
fit = suppressWarnings(fit_t_dist_fixed_mu(x))
h = hist(x, breaks = 25, freq = F)
curve(dt(x / fit[1], df=fit[2]) / fit[1], col = 2, add = T)

## End(Not run)
## Not run: 
# fit t-distribution
x = rt(1000, df = 3)
fit = suppressWarnings(fit_t_dist_fixed_mu(x))
h = hist(x, breaks = 25, freq = F)
curve(dt(x / fit[1], df=fit[2]) / fit[1], col = 2, add = T)

## End(Not run)

ftwkoopmans/msdap documentation built on March 5, 2025, 12:15 a.m.