Changelog
Source:NEWS.md
frmtmb.spatial 0.3.0
Needs frmtmb 0.76.0, which takes frmtmb_register_autocor(jacobian =) and accepts a bound at an end of a residual correlation parameter’s interval.
New features
-
sar()gives its whitening map’s Jacobian,(I - rho W) / sigma, as a sparse matrix. So frmtmb.sample’slog_lik()returns brms 2.23.0’s leave-one-out conditional density for both types, gaussian and student. It equals brms’slog_lik()at the same parameters to 6.3e-16 relative. One draw on a 40 x 40 lattice (1600 rows) takes 1.9 ms; brms’s dense algorithm takes 4.1 s for the same draw.
Bug fixes
- The
default_prior()table of asar()model passes back asprior =. Itslagsarorerrorsarrow lists the ends of the interval aslbandub, as brms’s does.frm()refused them as outside the interval. The fix is in frmtmb, which now accepts a bound at an end of the interval as no bound. Underfrm_sample(), a bounds-only prior onlagsarkeeps the flat default density; see frmtmb.sample’s NEWS.
frmtmb.spatial 0.2.0
Needs frmtmb 0.75.0, which exports frmtmb_register_autocor(), the seam through which this package registers sar().
New features
sar(M, type = ), brms’s spatial simultaneous autoregressive term, in its lag and error forms. As in brms 2.23.0, it is forgaussian()andstudent()with a constantsigmaandnu. It is registered throughfrmtmb::frmtmb_register_autocor(). brms leaves out-N/2 log(2 pi)(-N/2 log(pi)for student). Less that constant, the log-likelihood equals brms’s Stan program to 1.4e-14 (gaussian, at frmtmb’s estimates) and 4e-15 (student, at set parameter values withnu = 5). brms fits of 64 rows agree with the maximum likelihood fits to within 0.44 standard errors in every parameter.fitted()reports brms’sposterior_epred(),(I - rho W)^-1 mufor the lag form.summary()andconfint_varcorr()reportlagsarorerrorsar, andset_prior()takes them as classes: a density onrho, carried to the internal parameter.fitted(),predict()andsimulate()takenewdatawith one row per row ofM, read as the locations in their order, as brms reads it. When the fit dropped rows for missing values,newdatacovers them too, andI - rho Mis then over every row ofM. A counterfactual such asx + 1everywhere then gives the lag model’s spillover,(I - rho W)^-1 mu_new. That equals brms’sposterior_epred()on the samenewdataat the same parameter values. Othernewdatais refused, as brms refuses it withoutnewdata2.rhois estimated on(1 / min eigenvalue, 1 / max eigenvalue)ofM, whereI - rho Mhas a positive determinant. brms bounds it by(min eigenvalue, max eigenvalue). For a row-standardizedMthat cuts off negative values below the smallest eigenvalue. So frmtmb can estimaterhobeyond brms’s bound, and the two are then different models. An example is a row-standardized 8 x 8 queen lattice (eigenvalues -0.5006 to 1) with data drawn atrho = -0.8. frmtmb’s estimate is -1.103, with a logLik 3.74 above the best inside brms’s interval. brms’s posterior median is -0.443, with a fifth of its draws within 0.02 of its bound. For a matrix that is not row-standardized, brms’s interval reaches past1 / max eigenvalue, where its log-determinant is not a number and Stan rejects the proposal. So brms’s support there is frmtmb’s interval, at the cost of rejected proposals.A matrix whose smallest or largest eigenvalue repeats for all rows but one, such as a complete graph, gives a warning. At that end of the interval
I - rho Mkeeps one direction only. With an intercept the likelihood has no maximum there, sorhoruns to the end. The model is not refused, because without an intercept it has its maximum.A row-standardized
Mof an irregular graph, spdep’s default, has real eigenvalues thateigen()returns with a rounding imaginary part. brms 2.23.0 passes them to Stan as they come and its fit fails (“variable does not exist; … eigenMsar”); frmtmb takes the real part when the imaginary part is below 1e-8 of the largest modulus, and refuses a matrix with complex eigenvalues.spdep’s
nbandlistwobjects are read as brms reads them (nb2mat()row-standardized,listw2mat()) without needing spdep.
frmtmb.spatial 0.1.0
The first release. Load it with library(frmtmb.spatial), which attaches frmtmb as well. Needs frmtmb 0.74.0, which exports frmtmb_register_covstruct().
New features
- New package. Two fields moved here from frmtmb.
car(M, gr = g, type = )is brms’s conditional autoregressive field in its four types ("escar","esicar","icar","bym2").spde(fem, gr = node)is a Matern field over a finite-element mesh. Both are registered throughfrmtmb::frmtmb_register_covstruct(), and the package reads no frmtmb internal. Fits are unchanged. On the moved tests’ models, these are identical to frmtmb 0.73.0’s: the log-likelihood, every estimate and standard error,fitted()with and without an unseen location,ranef()conditional standard deviations,confint_varcorr()andsimulate().frmtmb.sample::frm_sample()gives the same draws from the same seed.frm_compat()givescarandspdethe statuses frmtmb gave them.