NLreg.jl

NLreg.NLregModelType
NLregModel{T<:AbstractFloat}

A representation of a nonlinear regression model. The important fields are

  • data: a Tables.RowTable of data values
  • ysym: the name of the response variable in data, as a Symbol
  • model: a function of two arguments - parameters and data - both as NamedTuples
  • parref: a Ref{R} where {R<:NamedTuple} containing the current parameter values
  • optsum: a NamedTuple of information on the optimization
source

StatsBase generics with methods for NLregModel

StatsBase.coefFunction
coef(obj::StatisticalModel)

Return the coefficients of the model.

StatsBase.coefnamesFunction
coefnames(obj::StatisticalModel)

Return the names of the coefficients.

StatsBase.coeftableFunction
coeftable(obj::StatisticalModel; level::Real=0.95)

Return a table of class CoefTable with coefficients and related statistics. level determines the level for confidence intervals (by default, 95%).

StatsBase.dof_residualFunction
dof_residual(obj::RegressionModel)

Return the residual degrees of freedom of the model.

StatsBase.fitFunction
fit(Histogram, data[, weight][, edges]; closed=:left, nbins)

Fit a histogram to data.

Arguments

  • data: either a vector (for a 1-dimensional histogram), or a tuple of vectors of equal length (for an n-dimensional histogram).

  • weight: an optional AbstractWeights (of the same length as the data vectors), denoting the weight each observation contributes to the bin. If no weight vector is supplied, each observation has weight 1.

  • edges: a vector (typically an AbstractRange object), or tuple of vectors, that gives the edges of the bins along each dimension. If no edges are provided, these are determined from the data.

Keyword arguments

  • closed: if :left (the default), the bin intervals are left-closed [a,b); if :right, intervals are right-closed (a,b].

  • nbins: if no edges argument is supplied, the approximate number of bins to use along each dimension (can be either a single integer, or a tuple of integers).

Examples

# Univariate
h = fit(Histogram, rand(100))
h = fit(Histogram, rand(100), 0:0.1:1.0)
h = fit(Histogram, rand(100), nbins=10)
h = fit(Histogram, rand(100), weights(rand(100)), 0:0.1:1.0)
h = fit(Histogram, [20], 0:20:100)
h = fit(Histogram, [20], 0:20:100, closed=:right)

# Multivariate
h = fit(Histogram, (rand(100),rand(100)))
h = fit(Histogram, (rand(100),rand(100)),nbins=10)

Fit a statistical model.

fit(ZScoreTransform, X; dims=nothing, center=true, scale=true)

Fit standardization parameters to vector or matrix X and return a ZScoreTransform transformation object.

Keyword arguments

  • dims: if 1 fit standardization parameters in column-wise fashion; if 2 fit in row-wise fashion. The default is nothing, which is equivalent to dims=2 with a deprecation warning.

  • center: if true (the default) center data so that its mean is zero.

  • scale: if true (the default) scale the data so that its variance is equal to one.

Examples

julia> using StatsBase

julia> X = [0.0 -0.5 0.5; 0.0 1.0 2.0]
2×3 Array{Float64,2}:
 0.0  -0.5  0.5
 0.0   1.0  2.0

julia> dt = fit(ZScoreTransform, X, dims=2)
ZScoreTransform{Float64}(2, 2, [0.0, 1.0], [0.5, 1.0])

julia> StatsBase.transform(dt, X)
2×3 Array{Float64,2}:
  0.0  -1.0  1.0
 -1.0   0.0  1.0
fit(UnitRangeTransform, X; dims=nothing, unit=true)

Fit a scaling parameters to vector or matrix X and return a UnitRangeTransform transformation object.

Keyword arguments

  • dims: if 1 fit standardization parameters in column-wise fashion;

if 2 fit in row-wise fashion. The default is nothing.

  • unit: if true (the default) shift the minimum data to zero.

Examples

julia> using StatsBase

julia> X = [0.0 -0.5 0.5; 0.0 1.0 2.0]
2×3 Array{Float64,2}:
 0.0  -0.5  0.5
 0.0   1.0  2.0

julia> dt = fit(UnitRangeTransform, X, dims=2)
UnitRangeTransform{Float64}(2, 2, true, [-0.5, 0.0], [1.0, 0.5])

julia> StatsBase.transform(dt, X)
2×3 Array{Float64,2}:
 0.5  0.0  1.0
 0.0  0.5  1.0
StatsBase.fittedFunction
fitted(obj::RegressionModel)

Return the fitted values of the model.

StatsBase.nobsFunction
nobs(obj::StatisticalModel)

Return the number of independent observations on which the model was fitted. Be careful when using this information, as the definition of an independent observation may vary depending on the model, on the format used to pass the data, on the sampling plan (if specified), etc.

StatsBase.residualsFunction
residuals(obj::RegressionModel)

Return the residuals of the model.

StatsBase.responseFunction
response(obj::RegressionModel)

Return the model response (a.k.a. the dependent variable).

StatsBase.rssFunction
rss(obj::StatisticalModel)

Return the residual sum of squares.

StatsBase.stderrorFunction
stderror(obj::StatisticalModel)

Return the standard errors for the coefficients of the model.

StatsBase.vcovFunction
vcov(obj::StatisticalModel)

Return the variance-covariance matrix for the coefficients of the model.