Description Usage Arguments Value Author(s) Examples

This function fits galaxy mass function (MF) to a discrete set of `N`

galaxies with noisy data. More generally, `dffit`

finds the most likely `P`

-dimensional distribution function (DF) generating `N`

objects `i=1,...,N`

with uncertain measurements `P`

observables. For instance, if the objects are galaxies, it can fit a MF (`P=1`

), a mass-size distribution (`P=2`

) or the mass-spin-morphology distribution (`P=3`

). A full description of the algorithm can be found in Obreschkow et al. (2017).

1 2 3 4 |

`x` |
Normally |

`selection` |
Specifies the effective volume |

`x.err` |
Optional vector or array specifying the observational errors of |

`distance` |
Optional vector of |

`phi` |
Either a string or a function specifying the DF to be fitted. A string is interpreted as the name of a predefined mass function. Available options are |

`p.initial` |
Initial model parameters for fitting the DF. |

`n.iterations` |
Maximum number of iterations in the repeated fit-and-debias algorithm to evaluate the maximum likelihood. |

`n.resampling` |
Integer (>0) specifying the number of iterations for the resampling of the most likely DF used to evaluate realistic parameter uncertainties with quantiles. If |

`correct.mle.bias` |
The maximum likelihood estimator (MLE) of a finite dataset can be biased - a general property of the ML approach. If |

`correct.lss.bias` |
If |

`lss.sigma` |
Cosmic variance of survey volume. Explicitly, |

`write.fit` |
If |

`x.grid` |
sets the grid on which the numerical integration is performed. This grid must be specified as |

Returns a structured list. The sublist `input`

contains all relevant input arguments. The sublist `fit`

contains all the output arguments of the MLE algorithm. The output can be visualized using `mfplot`

, `plot.df`

and `dfwrite`

.

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 | ```
# basic example
data = mfdata()
df = dffit(data$x, data$selection)
mfplot(df, xlim=c(2e6,5e10))
# show fitted parameter PDFs and covariances
dfplotcov(df)
# show fitted effective volume function
dfplotveff(df)
# include measurement errors in fit and determine Schechter function uncertainties from resampling
df = dffit(data$x, data$selection, data$x.err, n.resampling = 1e2)
mfplot(df, uncertainty.type=3, nbins=10, bin.xmin=6.5, bin.xmax=9.5, xlim=c(2e6,5e10), ylim=c(2e-3,1.5))
# evaluate bias corrected maximum-likelihood estimator and add to plot
df = dffit(data$x, data$selection, data$x.err, write.fit=FALSE, correct.mle.bias=TRUE)
mfplot(df, show.uncertainties=FALSE, nbins=0, show.bias.correction=TRUE, col.bias.correction="blue", add=TRUE)
# evaluate posteriors of the mass measurements and visualize the change in the mass mode between observation and posterior
# i.e. the Eddington bias correction
df = posterior.data(df)
plot(data$x,10^df$posterior$x.mode.correction,log='x',pch=20,xlab='Mass',ylab='Eddington bias correction = posterior/observed mass mode')
lines(10^seq(5,10,by=0.01),df$fit$functions$source.count(seq(5,10,by=0.01))*1e-2+1)
abline(h=1,v=5.4e7)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.