Categories &

Functions List

Function Reference: tlsfit

statistics: paramhat = tlsfit (x)
statistics: [paramhat, paramci] = tlsfit (x)
statistics: [paramhat, paramci] = tlsfit (x, alpha)
statistics: […] = tlsfit (x, alpha, censor)
statistics: […] = tlsfit (x, alpha, censor, freq)
statistics: […] = tlsfit (x, alpha, censor, freq, options)

Estimate parameters and confidence intervals for the Location-scale Student’s T distribution.

muhat = tlsfit (x) returns the maximum likelihood estimates of the parameters of the location-scale T distribution given the data in x. paramhat(1) is the location parameter, mu, paramhat(2) is the scale parameter, sigma, and paramhat(3) is the degrees of freedom, nu.

[paramhat, paramci] = tlsfit (x) returns the 95% confidence intervals for the parameter estimates.

[…] = tlsfit (x, alpha) also returns the 100 * (1 - alpha) percent confidence intervals for the parameter estimates. By default, the optional argument alpha is 0.05 corresponding to 95% confidence intervals. Pass in [] for alpha to use the default values.

[…] = tlsfit (x, alpha, censor) accepts a boolean vector, censor, of the same size as x with 1s for observations that are right-censored and 0s for observations that are observed exactly. By default, or if left empty, censor = zeros (size (x)).

[…] = tlsfit (x, alpha, censor, freq) accepts a frequency vector, freq, of the same size as x. freq typically contains integer frequencies for the corresponding elements in x, but it can contain any non-integer non-negative values. By default, or if left empty, freq = ones (size (x)).

[…] = tlsfit (…, options) specifies control parameters for the iterative algorithm used to compute ML estimates with the fminsearch function. options is a structure with the following fields and their default values:

  • options.Display = "off"
  • options.TolX = 1e-6

Further information about the location-scale Student’s T distribution can be found at https://en.wikipedia.org/wiki/Student%27s_t-distribution#Location-scale_t_distribution

See also: tlscdf, tlsinv, tlspdf, tlsrnd, tlslike, tlsstat

Source Code: tlsfit

Example: 1

 

 ## Sample 3 populations from 3 different location-scale T distibutions
 randn ("seed", 1);    # for reproducibility
 randg ("seed", 2);    # for reproducibility
 r1 = tlsrnd (-4, 3, 1, 2000, 1);
 randn ("seed", 3);    # for reproducibility
 randg ("seed", 4);    # for reproducibility
 r2 = tlsrnd (0, 3, 1, 2000, 1);
 randn ("seed", 5);    # for reproducibility
 randg ("seed", 6);    # for reproducibility
 r3 = tlsrnd (5, 5, 4, 2000, 1);
 r = [r1, r2, r3];

 ## Plot them normalized and fix their colors
 hist (r, [-21:21], [1, 1, 1]);
 h = findobj (gca, "Type", "patch");
 set (h(1), "facecolor", "c");
 set (h(2), "facecolor", "g");
 set (h(3), "facecolor", "r");
 ylim ([0, 0.25]);
 xlim ([-20, 20]);
 hold on

 ## Estimate their lambda parameter
 mu_sigma_nuA = tlsfit (r(:,1));
 mu_sigma_nuB = tlsfit (r(:,2));
 mu_sigma_nuC = tlsfit (r(:,3));

 ## Plot their estimated PDFs
 x = [-20:0.1:20];
 y = tlspdf (x, mu_sigma_nuA(1), mu_sigma_nuA(2), mu_sigma_nuA(3));
 plot (x, y, "-pr");
 y = tlspdf (x, mu_sigma_nuB(1), mu_sigma_nuB(2), mu_sigma_nuB(3));
 plot (x, y, "-sg");
 y = tlspdf (x, mu_sigma_nuC(1), mu_sigma_nuC(2), mu_sigma_nuC(3));
 plot (x, y, "-^c");
 hold off
 legend ({"Normalized HIST of sample 1 with μ=0, σ=2 and nu=1", ...
          "Normalized HIST of sample 2 with μ=5, σ=2 and nu=1", ...
          "Normalized HIST of sample 3 with μ=3, σ=4 and nu=3", ...
          sprintf("PDF for sample 1 with estimated μ=%0.2f, σ=%0.2f, and ν=%0.2f", ...
                  mu_sigma_nuA(1), mu_sigma_nuA(2), mu_sigma_nuA(3)), ...
          sprintf("PDF for sample 2 with estimated μ=%0.2f, σ=%0.2f, and ν=%0.2f", ...
                  mu_sigma_nuB(1), mu_sigma_nuB(2), mu_sigma_nuB(3)), ...
          sprintf("PDF for sample 3 with estimated μ=%0.2f, σ=%0.2f, and ν=%0.2f", ...
                  mu_sigma_nuC(1), mu_sigma_nuC(2), mu_sigma_nuC(3))})
 title ("Three population samples from different location-scale T distibutions")
 hold off

                    
plotted figure