Description Usage Arguments Details Value Author(s) Examples
This function finds the most likely P-dimensional model parameters of a D-dimensional distribution function (DF) generating an observed set of N objects with D-dimensional observables x, accounting for measurement uncertainties and a user-defined selection function. For instance, if the objects are galaxies, dffit
can fit a mass function (D=1), a mass-size distribution (D=2) or the mass-spin-morphology distribution (D=3). A full description of the algorithm can be found in Obreschkow et al. (2017).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | dffit(
x,
selection = NULL,
x.err = NULL,
r = NULL,
gdf = "Schechter",
p.initial = NULL,
prior = NULL,
obs.selection = NULL,
obs.sel.cov = NULL,
n.iterations = 100,
method = "Nelder-Mead",
reltol = 1e-10,
correct.lss.bias = FALSE,
lss.weight = NULL,
lss.errors = TRUE,
n.bootstrap = NULL,
n.jackknife = NULL,
xmin = NULL,
xmax = NULL,
dx = 0.01,
keep.eddington.bias = FALSE,
write.fit = FALSE,
add.gaussian.errors = TRUE,
make.posteriors = TRUE
)
|
x |
is an N-by-D matrix (or N-element vector if D=1) containing the observed D-dimensional properties of N objects. For instance, x can be N-element vector containing the logarithmig masses of N galaxies, to which a mass function should be fitted. |
selection |
Specifies the effective volume (1) (2) (3) (4) (5) |
x.err |
specifies the observational uncertainties of the N data points. These uncertainties can be specified in four ways: (1) If (2) If (3) If (4) |
r |
Optional N-element vector specifying the comoving distances of the N objects (e.g. galaxies). This vector is only needed if |
gdf |
Either a string or a function specifying the DF to be fitted. A string is interpreted as the name of a predefined mass function (i.e. functions of one obervable, |
p.initial |
is a P-vector specifying the initial model parameters for fitting the DF. |
prior |
is an optional function specifying the priors on the P model parameters. This function must take a P-dimensional vector |
obs.selection |
is an optional selection function of a D-vector |
obs.sel.cov |
is an optional |
n.iterations |
Maximum number of iterations in the repeated fit-and-debias algorithm to evaluate the maximum likelihood. |
method |
optimization method argument of |
reltol |
relative tolerance parameter of |
correct.lss.bias |
If |
lss.weight |
If |
lss.errors |
is a logical flag specifying whether uncertainties computed via resampling should include errors due to the uncerainty of large-scale structure (LSS). If |
n.bootstrap |
If |
n.jackknife |
If |
xmin, xmax, dx |
are |
keep.eddington.bias |
If |
write.fit |
If |
add.gaussian.errors |
If |
make.posteriors |
If |
For a detailed description of the method, please refer to the peer-reviewed publication by Obreschkow et al. 2017 (in prep.).
The routine dffit
returns a structured list, which can be interpreted by other routines, such as dfwrite
, dfplot
, dfplotcov
, dfplotveff
. The list contains the following sublists:
data |
contains the input arguments |
selection |
is a list describing the selection function of the data used when fitting the generative DF. The most important entries in this list are: |
fit |
is a list describing the fitted generative distribution function. Its most important entries are: |
posteriors |
is a list specifying the posterior PDFs of the observed data, given the best-fitting model. It contains the following entries: |
model |
is a list describing the generative DF used to model the data. The main entries of this list are: |
grid |
is a list of arrays with numerical evaluations of different functions on a grid in the D-dimensional observable space. This grid is used for numerical integrations and graphical representations. The most important list entries are: |
options |
is a list of various optional input arguments of |
Danail Obreschkow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # For a quick overview of some key functionalities run
dfexample()
# with varying integer arguments 1, 2, 3, 4.
# The following examples introduce the basics of dftools step-by step.
# First, generate a mock sample of 1000 galaxies with 0.5dex mass errors, drawn from
# a Schechter function with the default parameters (-2,11,-1.3):
dat = dfmockdata(n=1000, sigma=0.5)
# show the observed and true log-masses (x and x.true) as a function of true distance r
plot(dat$r,dat$x,col='grey'); points(dat$r,dat$x.true,pch=20)
# fit a Schechter function to the mock sample without accounting for errors
survey1 = dffit(dat$x, dat$veff)
# plot fit and add a black dashed line showing the input MF
ptrue = dfmodel(output='initial')
mfplot(survey1, xlim=c(1e6,2e12), ylim=c(2e-4,2),
show.data.histogram = TRUE, p = ptrue, col.fit = 'purple')
# now, do the same again, while accountting for measurement errors in the fit
# this time, the posterior data, corrected for Eddington bias, is shown as black points
survey2 = dffit(dat$x, dat$veff, dat$x.err)
mfplot(survey2, show.data.histogram = NA, add = TRUE)
# show fitted parameter PDFs and covariances with true input parameters as black points
dfplotcov(list(survey2,survey1,ptrue),pch=c(20,20,3),col=c('blue','purple','black'),nstd=15)
# show effective volume function
dfplotveff(survey2)
# now create a smaller survey of only 30 galaxies with 0.5dex mass errors
dat = dfmockdata(n=30, sigma=0.5)
# fit a Schechter function and determine uncertainties by resampling the data
survey = dffit(dat$x, dat$veff, dat$x.err, n.bootstrap = 30)
# show best fit with 68% Gaussian uncertainties from Hessian and posterior data as black points
mfplot(survey, show.data.histogram = TRUE, uncertainty.type = 1)
# show best fit with 68% and 95% resampling uncertainties and posterior data as black points
mfplot(survey, show.data.histogram = TRUE, uncertainty.type = 3)
# add input model as dashed lines
lines(10^survey$grid$x, survey$model$gdf(survey$grid$x,ptrue), lty=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.