Skip to contents

Calculate a censored mean

Usage

mean_tobit(
  x,
  lower = -Inf,
  upper = Inf,
  include_equal = TRUE,
  include_equal_lower = include_equal,
  include_equal_upper = include_equal,
  distribution,
  na.rm = TRUE,
  ...
)

Arguments

x

A numeric vector

lower, upper

The lower and upper bounds for censoring x

include_equal, include_equal_lower, include_equal_upper

Should the bounds consider x <= lower and x >= upper (if TRUE) or x < lower and x > upper (if FALSE) to be censored? (include_equal is overridden by setting include_equal_lower or include_equal_upper.)

distribution

What distribution (Student "t" or "normal") should be used. If "t", the degrees of freedom are the number of non-NA values in x.

na.rm

A logical value indicating whether NA values should be stripped from x before the computation proceeds.

...

Arguments passed on to stats::optim

par

Initial values for the parameters to be optimized over.

fn

A function to be minimized (or maximized), with first argument the vector of parameters over which minimization is to take place. It should return a scalar result.

gr

A function to return the gradient for the "BFGS", "CG" and "L-BFGS-B" methods. If it is NULL, a finite-difference approximation will be used.

For the "SANN" method it specifies a function to generate a new candidate point. If it is NULL a default Gaussian Markov kernel is used.

method

The method to be used. See ‘Details’. Can be abbreviated.

lower,upper

Bounds on the variables for the "L-BFGS-B" method, or bounds in which to search for method "Brent".

control

a list of control parameters. See ‘Details’.

hessian

Logical. Should a numerically differentiated Hessian matrix be returned?

Value

A 'mean_tobit' object which is a number with attributes for the standard deviation (sd) and convergence information in the "message" attribute.

See also

Other Censored Descriptive Statistics: geomean_tobit(), sd_tobit()