spreg.NSLX¶
- class spreg.NSLX(y, x, coords, params=[(10, inf, 'exponential')], distance_metric='Euclidean', leafsize=30, slx_vars='All', var_flag=1, conv_flag=0, verbose=False, options=None, vm=False, name_y=None, name_x=None, name_ds=None, name_coords=None, latex=False)[source]¶
Estimation of the nonlinear SLX model - inverse distance power function and negative exponential distance function supported Includes output of all results.
- Parameters:
- y
numpy.ndarrayorpandas.Series nx1 array for dependent variable
- x
numpy.ndarrayorpandasobject Two dimensional array with n rows and one column for each independent (exogenous) variable, excluding the constant
- coords
annby2arrayoraselectionoftwocolumnsfromadataframe - params
alistoftuplescontainingthetwoparametersfortheconstruction of the distance weights and the transformation: (k,distance_upper_bound,transformation) if the list consists of a single element, the same parameters are applied to all transformations default is [(10,np.inf,”exponential”)] for 10 knn neighbors, variable bandwidth and exponential transformation (see make_wnslx in UTILS)
- distance_metric: metric for distance computations, either “Euclidean” (default) or “Arc”
(for decimal lat-lon degrees)
- leafsize
parameterusedtocreatKDTree,defaultis30 - slx_vars
listwithTrue,FalseforselectionofXvariablestowhichSLXshouldbeapplied default is “All”
- var_flag
flagforvariancecomputation,default= 1 -usesanalyticalderivation, = 0 - uses numerical approximation with inverse hessian
- conv_flag
flagforconvergencediagnostics,default= 0fornodiagnostics = 1 - prints our minimize convergence summary
- verbosebool
forintermediateresultsinnonlinearoptimization,defaultisFalse - options
optionsspecifictoscipyminimize,suchas{“disp”:True} (see scipy minimize docs)
- vmbool
if True, include variance-covariance matrix in summary results
- name_y
str Name of dependent variable for use in output
- name_x
listofstrings Names of independent variables for use in output
- name_coords
listofstrings Names of coordinate variables used in distance matrix
- name_ds
str Name of dataset for use in output
- latexbool
Specifies if summary is to be printed in latex format
- y
- Attributes:
- output
dataframe regression results pandas dataframe
- summary
str Summary of regression results and diagnostics (note: use in conjunction with the print command)
- y
nby1numpyarraywithdependentvariable - x
nbykarraywithexplanatoryvariables,includesconstant - xw
nbyharraywithselectedcolumnsofXthatwillhavethe W(alpha) transformation applied to them
- w
listofsparseCSRarraystouseinlagtransformation,if list has a single element, same weights applied for all
- n
numberofobservations - k
numberofexplanatoryvariablesinX(includesconstant) - transform
tupleoftransformations,either“power” or “exponential” when same transformation applies to all, tuple is a single element tuple (default is “power”)
- verbose
optionfornonlinearoptimization,eitherFalse(default)or True
- options
optionsspecifictoscipyminimize,suchas{“disp”:True} (see scipy minimize docs)
- betas
numpyarraywithparameterestimates - utu
sumofsquaredresiduals - ihess
inverseofHessianmatrix - sign
estimateofresidualvariance(dividedbyn) - sig2
sameassign - vm
coefficientvariance-covariancematrix(signxihess) - predy
vectorofpredictedvalues - u
vectorofresiduals - ll
float Log likelihood
- aic
float Akaike information criterion
- schwarz
float Schwarz information criterion
- name_x
variablenamesforexplanatoryvariables - name_ds
datasetname - name_y
nameofdependentvariable - title
outputheader
- output
- __init__(y, x, coords, params=[(10, inf, 'exponential')], distance_metric='Euclidean', leafsize=30, slx_vars='All', var_flag=1, conv_flag=0, verbose=False, options=None, vm=False, name_y=None, name_x=None, name_ds=None, name_coords=None, latex=False)[source]¶
Methods
__init__(y, x, coords[, params, ...])Attributes
- property mean_y¶
- property std_y¶