Documentation ¶
Index ¶
- func GetVcov(model RegFitter, params Parameter) ([]float64, error)
- type BaseResults
- func (rslt *BaseResults) FittedValues(da [][]Dtype) []float64
- func (rslt *BaseResults) LogLike() float64
- func (rslt *BaseResults) Model() RegFitter
- func (rslt *BaseResults) Names() []string
- func (rslt *BaseResults) PValues() []float64
- func (rslt *BaseResults) Params() []float64
- func (rslt *BaseResults) StdErr() []float64
- func (rslt *BaseResults) VCov() []float64
- func (rslt *BaseResults) ZScores() []float64
- type BaseResultser
- type Dataset
- type Dtype
- type Fmter
- type Focuser
- type HessType
- type Knockoff
- func (ko *Knockoff) Close()
- func (ko *Knockoff) CrossProd() []float64
- func (ko *Knockoff) CrossProdMinEig() float64
- func (ko *Knockoff) Get(name string) interface{}
- func (ko *Knockoff) GetPos(j int) interface{}
- func (ko *Knockoff) Names() []string
- func (ko *Knockoff) Next() bool
- func (ko *Knockoff) NumObs() int
- func (ko *Knockoff) NumVar() int
- func (ko *Knockoff) Reset()
- type KnockoffResult
- type Parameter
- type RegFitter
- type SummaryTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseResults ¶
type BaseResults struct {
// contains filtered or unexported fields
}
BaseResults contains the results after fitting a model to data.
func NewBaseResults ¶
func NewBaseResults(model RegFitter, loglike float64, params []float64, xnames []string, vcov []float64) BaseResults
NewBaseResults returns a BaseResults corresponding to the given fitted model.
func (*BaseResults) FittedValues ¶
func (rslt *BaseResults) FittedValues(da [][]Dtype) []float64
FittedValues returns the fitted linear predictor for a regression model. If da is nil, the fitted values are based on the data used to fit the model. Otherwise, the provided data stream is used to produce the fitted values, so it must have the same columns as the training data.
func (*BaseResults) LogLike ¶
func (rslt *BaseResults) LogLike() float64
LogLike returns the log-likelihood or objective function value for the fitted model.
func (*BaseResults) Model ¶
func (rslt *BaseResults) Model() RegFitter
Model produces the model value used to produce the results.
func (*BaseResults) Names ¶
func (rslt *BaseResults) Names() []string
Names returns the covariate names for the variables in the model.
func (*BaseResults) PValues ¶
func (rslt *BaseResults) PValues() []float64
PValues returns the p-values for the null hypothesis that each parameter's population value is equal to zero.
func (*BaseResults) Params ¶
func (rslt *BaseResults) Params() []float64
Params returns the point estimates for the parameters in the model.
func (*BaseResults) StdErr ¶
func (rslt *BaseResults) StdErr() []float64
StdErr returns the standard errors for the parameters in the model.
func (*BaseResults) VCov ¶
func (rslt *BaseResults) VCov() []float64
VCov returns the sampling variance/covariance model for the parameters in the model. The matrix is vetorized to one dimension.
func (*BaseResults) ZScores ¶
func (rslt *BaseResults) ZScores() []float64
ZScores returns the Z-scores (the parameter estimates divided by the standard errors).
type BaseResultser ¶
type BaseResultser interface { Model() RegFitter Names() []string LogLike() float64 Params() []float64 VCov() []float64 StdErr() []float64 ZScores() []float64 PValues() []float64 }
BaseResultser is a fitted model that can produce results (parameter estimates, etc.).
type Dataset ¶
type Dataset interface { // Data returns all variables in the dataset, stored column-wise. Data() [][]Dtype // Names returns the names of the variables in the dataset, // in the same order as the data are stored in the Data field. Names() []string }
Dataset defines a way to pass data to a statistical model.
func NewDataset ¶
NewDataset returns a dataset containing the given data columns.
type Dtype ¶
type Dtype = float64
Dtype is a type alias that is used to define the datatype of all data passed to the statistical models. It should be set to float64 or float32.
type Focuser ¶
type Focuser interface { NumParams() int NumObs() int Focus(int, []float64, []float64) RegFitter LogLike(Parameter, bool) float64 Score(Parameter, []float64) Hessian(Parameter, HessType, []float64) }
Focuser restricts a model to one parameter.
type HessType ¶
type HessType int
HessType indicates the type of a Hessian matrix for a log-likelihood.
type Knockoff ¶
type Knockoff struct {
// contains filtered or unexported fields
}
Knockoff is a dstream that creates knockoff versions of variables from another dstream. The specific approach implemented here is the "equivariant knockoff" of Barber and Candes (2014). As with any other dstream transform, do not retain the source dstream after creating a knockoff from it.
func NewKnockoff ¶
NewKnockoff creates a knockoff data stream from the given source data stream. A knockoff variable is constructed for each variable in 'kovars'. All knockoff variables (both the original and the knockoff version of the variable) are standardized. Variables not listed in kovars are retained but are not standardized or otherwise altered. The returned Knockoff struct value satisfies the dstream interface.
func (*Knockoff) Close ¶
func (ko *Knockoff) Close()
Close returns the underlying reader for the dstream.
func (*Knockoff) CrossProdMinEig ¶
CrossProdMinEig returns the minimum eigenvalue of the knockoff cross product matrix.
func (*Knockoff) Next ¶
Next advances the dstream to the next chunk and returns true, or returns false if the dstream has been fully read.
type KnockoffResult ¶
type KnockoffResult struct {
// contains filtered or unexported fields
}
KnockoffResult contains the results of fitting a regression model using the knockoff method.
func NewKnockoffResult ¶
func NewKnockoffResult(result BaseResultser, plus bool) *KnockoffResult
NewKnockoffResult creates a knockoff result from a fitted regression model that has been fit to a Knockoff dataset.
func (*KnockoffResult) FDR ¶
func (kr *KnockoffResult) FDR() []float64
FDR returns the estimated false discovery rate values for the variables in the regression model.
func (*KnockoffResult) Names ¶
func (kr *KnockoffResult) Names() []string
Names returns the names of the variables in the knockoff analysis. For each original/knockoff variable pair, only the original name is included.
func (*KnockoffResult) Params ¶
func (kr *KnockoffResult) Params() []float64
Params returns the estimated coefficients for the non-knockoff variables in the regression model.
func (*KnockoffResult) Stat ¶
func (kr *KnockoffResult) Stat() []float64
Stat returns the knockoff statistic values for the variables in the regression model. These statistics are obtained by comparing the coefficient for an actual variable to the coefficient for its knockoff counterpart, so one number is returned for each actual/knockoff pair of variables.
type Parameter ¶
type Parameter interface { // Get the coefficients of the covariates in the linear // predictor. The returned value should be a reference so // that changes to it lead to corresponding changes in the // parameter itself. GetCoeff() []float64 // Set the coefficients of the covariates in the linear // predictor. SetCoeff([]float64) // Clone creates a deep copy of the Parameter struct. Clone() Parameter }
Parameter is the parameter of a model.
type RegFitter ¶
type RegFitter interface { // Number of parameters in the model. NumParams() int // Number of observations in the data set NumObs() int // Positions of the covariates Xpos() []int Dataset() [][]Dtype // The log-likelihood function LogLike(Parameter, bool) float64 // The score vector Score(Parameter, []float64) // The Hessian matrix Hessian(Parameter, HessType, []float64) }
RegFitter is a regression model that can be fit to data.
type SummaryTable ¶
type SummaryTable struct { // Title Title string // Column names ColNames []string // Formatters for the column values ColFmt []Fmter // Cols[j] is the j^th column. It's concrete type should // be an array, e.g. of numbers or strings. Cols []interface{} // Values at the top of the summary Top []string // Messages displayed below the table Msg []string // contains filtered or unexported fields }
SummaryTable holds the summary values for a fitted model.
func (*SummaryTable) String ¶
func (s *SummaryTable) String() string
String returns the table as a string.