Estimates the parameters of a probability distribution by maximizing the log‐likelihood.
Initial parameter estimates are obtained using the method of L‐moments and optimization
is performed via stats::nlminb()
with repeated perturbations if needed.
For NS-FFA: To estimate parameters for a nonstationary model, include the
observation years (ns_years
) and the nonstationary model structure
(ns_structure
).
Arguments
- data
Numeric vector of observed annual maximum series values. Must be strictly positive, finite, and not missing.
- distribution
A three-character code indicating the distribution family. Must be
"GUM"
,"NOR"
,"LNO"
,"GEV"
,"GLO"
,"GNO"
,"PE3"
,"LP3"
, or"WEI"
.- ns_years
For NS-FFA only: Numeric vector of observation years corresponding to
data
. Must be the same length asdata
and strictly increasing.- ns_structure
For NS-FFA only: Named list indicating which distribution parameters are modeled as nonstationary. Must contain two logical scalars:
location
: IfTRUE
, the location parameter has a linear temporal trend.scale
: IfTRUE
, the scale parameter has a linear temporal trend.
Value
A list containing the results of parameter estimation:
data
: Thedata
argument.distribution
: Thedistribution
argument.ns_years
: Thens_years
argument, if given.ns_structure
: Thens_structure
argument, if given.method
:"MLE"
.params
: Numeric vector of estimated parameters.mll
: The maximum value of the log‐likelihood.
Details
Calls
fit_lmoments()
ondata
to obtain initial parameter estimates.Initializes trend parameters to zero if necessary.
For
WEI
models, sets the location parameter to zero to ensure support.Defines an objective function using
utils_log_likelihood()
.Runs
stats::nlminb()
with box constraints. Attempts minimization up to 100 times.
Examples
data <- rnorm(n = 100, mean = 100, sd = 10)
ns_years <- seq(from = 1901, to = 2000)
ns_structure <- list(location = TRUE, scale = FALSE)
fit_mle(data, "GNO", ns_years, ns_structure)
#> $data
#> [1] 102.26379 108.00647 94.50523 87.72731 99.77925 108.63950 112.97008
#> [8] 96.02339 84.07061 102.54378 82.27624 100.78716 86.00637 132.19060
#> [15] 91.81452 100.36118 94.42961 91.78141 112.85518 87.10887 98.47703
#> [22] 90.29603 115.85079 96.85944 90.73756 113.84408 89.75266 84.38758
#> [29] 103.32694 83.67615 110.88718 105.92150 88.93916 97.37292 105.86291
#> [36] 91.23258 108.51698 99.39284 95.83097 107.19835 85.08089 100.34346
#> [43] 97.53211 119.54145 100.09658 113.11216 88.64854 95.31387 103.40441
#> [50] 98.21043 116.15922 99.69659 110.39512 102.20352 109.53315 111.88895
#> [57] 95.33576 116.22845 92.46341 108.04747 93.51511 94.71189 76.80314
#> [64] 111.49970 97.32005 113.35798 103.04911 110.48993 92.94706 100.24797
#> [71] 100.81656 105.06131 94.48316 107.03604 101.50665 81.50408 96.53061
#> [78] 99.56023 98.79920 92.41629 110.41362 100.44308 108.27265 98.96216
#> [85] 92.11579 108.29480 116.68956 102.13646 111.57535 89.21120 113.15584
#> [92] 93.25724 93.56120 100.40112 108.21379 114.65366 104.47294 103.40752
#> [99] 120.89891 103.25784
#>
#> $distribution
#> [1] "GNO"
#>
#> $ns_years
#> [1] 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915
#> [16] 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
#> [31] 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
#> [46] 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
#> [61] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
#> [76] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
#> [91] 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
#>
#> $ns_structure
#> $ns_structure$location
#> [1] TRUE
#>
#> $ns_structure$scale
#> [1] FALSE
#>
#>
#> $prior
#> NULL
#>
#> $method
#> [1] "MLE"
#>
#> $params
#> [1] 97.08225431 6.57788171 9.78909788 -0.08641844
#>
#> $mll
#> [1] -370.0208
#>