Description Usage Arguments Author(s) References Examples
View source: R/gibbs_cs_wish_tfd.R
Fitting function for function-on-scalar regression for cross-sectional data. This function estimates model parameters using a Gibbs sampler and estimates the residual covariance surface using a Wishart prior. As an alteration of 'refund::gibbs_cs_wish', this function takes in a dataframewith tfd column as an input.
1 2 3 |
formula |
a formula indicating the structure of the proposed model. |
Kt |
number of spline basis functions used to estimate coefficient functions |
data |
an data frame, list or environment containing the variables in the model. This includes the response variable of the formula which should be a tfd class. |
verbose |
logical defaulting to |
N.iter |
number of iterations used in the Gibbs sampler |
N.burn |
number of iterations discarded as burn-in |
alpha |
tuning parameter balancing second-derivative penalty and zeroth-derivative penalty (alpha = 0 is all second-derivative penalty) |
min.iter |
minimum number of iterations |
max.iter |
maximum number of iterations |
Aw |
hyperparameter for inverse gamma controlling variance of spline terms for population-level effects |
Bw |
hyperparameter for inverse gamma controlling variance of spline terms for population-level effects |
v |
hyperparameter for inverse Wishart prior on residual covariance |
SEED |
seed value to start the sampler; ensures reproducibility |
Gaeun Kim gk2501@columbia.edu and Jeff Goldsmith ajg2202@cumc.columbia.edu
Goldsmith, J., Kitago, T. (2016). Assessing Systematic Effects of Stroke on Motor Control using Hierarchical Function-on-Scalar Regression. Journal of the Royal Statistical Society: Series C, 65 215-236.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
library(ggplot2)
library(reshape2)
data(dti)
dti.ols = ols_cs_tfd(cca ~ pasat, data = dti, Kt = 10)
gibbs_dti = gibbs_cs_fpca_tfd(cca ~ pasat, data = dti, Kt = 10, N.iter = 500, N.burn = 200)
gibbs_dti_wish = gibbs_dti_wish = gibbs_cs_wish_tfd(cca ~ pasat, data = dti, Kt = 10, N.iter = 500, N.burn = 200)
models = c("dti.ols", "gibbs_dti", "gibbs_dti_wish")
intercepts = sapply(models, function(u) get(u)$beta.hat[1,])
slopes = sapply(models, function(u) get(u)$beta.hat[2,])
## graph of estimated coefficient functions (intercept, slope)
plot.dat = melt(intercepts); colnames(plot.dat) = c("grid", "method", "value")
ggplot(plot.dat, aes(x = grid, y = value, group = method, color = method)) +
geom_path() + theme_bw() + ylab("intercept")
plot.dat = melt(slopes); colnames(plot.dat) = c("grid", "method", "value")
ggplot(plot.dat, aes(x = grid, y = value, group = method, color = method)) +
geom_path() + theme_bw() + ylab("slope")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.