Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cache_readonly
def null(self):
y = np.reshape(self.y, (-1,1))
model = self.model
X = np.ones((len(y), 1))
null_mod = GLM(y, X, family=self.family, offset=self.offset, constant=False)
return null_mod.fit().mu
@cache_readonly
def df_model(self):
return None
@cache_readonly
def llnull(self):
return self.family.loglike(self.y, self.null, scale=self.scale)
@cache_readonly
def normalized_cov_params(self):
return la.inv(spdot(self.w.T, self.w))
@cache_readonly
def resid_working(self):
return None
@cache_readonly
def sigma2_v1(self):
"""
residual variance
Methods: p214, (9.6),
Fotheringham, A. S., Brunsdon, C., & Charlton, M. (2002).
Geographically weighted regression: the analysis of spatially varying
relationships.
only use v1
"""
return (self.resid_ss/(self.n-self.tr_S))
@cache_readonly
def resid_working(self):
raise NotImplementedError('Not implemented for GWR')
@cache_readonly
def ENP(self):
"""
effective number of parameters
Defaults to tr(s) as defined in :cite:`yu:2019`
but can alternatively be based on 2tr(s) - tr(STS)
and the form depends on the specification of sigma2
"""
if self.model.sigma2_v1:
return self.tr_S
else:
return 2 * self.tr_S - self.tr_STS
@cache_readonly
def resid_deviance(self):
return (self.family.resid_dev(self.y, self.mu))
@cache_readonly
def sigma2_v1v2(self):
"""
residual variance
Methods: p55 (2.16)-(2.18)
Fotheringham, A. S., Brunsdon, C., & Charlton, M. (2002).
Geographically weighted regression: the analysis of spatially varying
relationships.
use v1 and v2 #used in GWR4
"""
if isinstance(self.family, (Poisson, Binomial)):
return self.resid_ss/(self.n - 2.0*self.tr_S +
self.tr_STS) #could be changed to SWSTW - nothing to test against
else:
return self.resid_ss/(self.n - 2.0*self.tr_S +