ols_cs_tfd: Cross-sectional FoSR using GLS

Description Usage Arguments Author(s) References Examples

View source: R/ols_cs_tfd.R

Description

Fitting function for function-on-scalar regression for cross-sectional data. Edited 'refund::ols_cs', while the inputs did not change, ols_cs_tfd’s argument, data will be a dataframe with a tfd type column, which will be the response of the proposed model.This function estimates model parameters using GLS: first, an OLS estimate of spline coefficients is estimated; second, the residual covariance is estimated using an FPC decomposition of the OLS residual curves; finally, a GLS estimate of spline coefficients is estimated. Although this is in the 'BayesFoSR' package, there is nothing Bayesian about this FoSR.

Usage

1
2
ols_cs_tfd(formula, data = NULL, Kt = 5, basis = "bs",
  verbose = TRUE)

Arguments

formula

a formula indicating the structure of the proposed model.

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.

Kt

number of spline basis functions used to estimate coefficient functions

basis

basis type; options are "bs" for b-splines and "pbs" for periodic b-splines

verbose

logical defaulting to TRUE – should updates on progress be printed?

Author(s)

Gaeun Kim gk2501@columbia.edu and Jeff Goldsmith ajg2202@cumc.columbia.edu

References

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.

Examples

 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)

gekim0519/tidyfunfun documentation built on Aug. 2, 2019, 5:18 a.m.