Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/car #322

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open

feature/car #322

wants to merge 69 commits into from

Conversation

imadmali
Copy link
Collaborator

This is almost ready to go. But before it gets merged there are a couple of issues that I need help with.

  • loo doesn't work for binomial(link="log") but it works for the other link functions in the binomial family.
  • some of the tests are failing (e.g. test_pp_validate.R)

imadmali added 30 commits July 10, 2017 18:04
@imadmali
Copy link
Collaborator Author

I forgot to drop that requirement. It was being used for INLA::qinv but I am doing the non-sparse version here:
https://github.com/stan-dev/rstanarm/blob/feature/car/R/stan_spatial.fit.R#L390-L423

vector[order == 2 ? Q_n[1] : 0] w;
int v[order == 2 ? Q_n[1] : 0];
int u[order == 2 ? N+1 : 0];
// prior stuff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this all be handled by a #include /data/hyperparameters.stan like many of the other Stan programs?

else if (model_type == 3)
psi = tau*(sqrt(1-rho[1])*theta_raw + sqrt(rho[1]/scaling_factor)*phi);
// for regression coefficients
// "tparameters.stan"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be subsumed with a #include?

}
/* else prior_dist is 0 and nothing is added */

// Log-prior for intercept
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be subsumed with a #include /model/priors_glm.stan ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to separate out the intercept part of a GLM prior

vignettes/spatial.Rmd Outdated Show resolved Hide resolved
$$
where $\alpha$ is the intercept, $\mathbf{X}$ is an $N$-by-$K$ matrix of predictors ($N$ being the number of observations and $K$ being the number of predictors), $\boldsymbol{\beta}$ is a $K$-dimensional vector of regression coefficients, and $\boldsymbol{\psi}$ is a $N$-dimensional vector representing the spatial effect. The construction of $\boldsymbol{\psi}$ depends on the model, which is discussed in the relevant sections below.

Depending on the choice of likelihood there may or may not be an additional auxiliary parameter $\gamma$ in the model (e.g. in a Gaussian likelihood this would be the variation of the data). With all these components, for some probability density/mass function $f$, we can state the general form of the likelihood as,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is $\gamma$ actually $\sigma$ in the output?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's aux in the stan model but I think this maps to different things depending on the likelihood (e.g. it's sigma in the gaussian case).


## GMRF Hierarchical Component

CAR models require that you define the spatial component as a Gaussian Markov Random Field (GMRF). The random vector $\boldsymbol{\phi}$ is a GMRF with respect to the graph $\mathcal{G} = (\mathcal{V} = \{1,\ldots,n\},\mathcal{E})$ with mean vector $\boldsymbol{\mu}$ and precision matrix $\mathbf{W}$ if its probability density function takes the precision form of the multivariate normal distribution,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include an image for a small graph like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like you want to include a plot of the lattice? I have that in there if you build the vignette.


## An Example Using Simulated Data on a Lattice

As an example we use spatial units defined on a lattice. Below we plot a GMRF of 900 spatial units available in the rstanarm package.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rstanarm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in bold I mean

@bgoodri
Copy link
Contributor

bgoodri commented Oct 28, 2018

Got a bunch of things from R CMD check particularly if --run-dontrun --run-donttest is specified

@bgoodri
Copy link
Contributor

bgoodri commented Oct 28, 2018 via email

@imadmali
Copy link
Collaborator Author

@bgoodri thanks for bringing this up-to-date. I'll try to take a look over the weekend to see if I've left anything hanging.

@jgabry
Copy link
Member

jgabry commented Nov 30, 2020

Just checking in on this. Any status update?

@bgoodri
Copy link
Contributor

bgoodri commented Nov 30, 2020 via email

@jgabry
Copy link
Member

jgabry commented Nov 30, 2020

Does that mean we can also finally merge the survival stuff?

@bgoodri
Copy link
Contributor

bgoodri commented Nov 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants