bhat.func: Compute PWD Regression Coefficients Given alpha

Description Usage Arguments Value Examples

View source: R/functions-code.R

Description

This function computes PWD regression coefficients for response y and predictors X given a particular value of alpha.

Usage

1
bhat.func(y, X, alpha)

Arguments

y

T-length time series vector. y[1] represents the beginning of the time eries.

X

[T x p] dimensional matrix of covariates. This should not include the intercept column. If X is FALSE, intercept model is run.

alpha

PWD parameter we are calculating the marginal predictive loglikelihood for.

Value

(p+1)-length vector representing the regression coefficients associated with a PWD regression of y upon X given PWD parameter alpha.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(12)
N=80
err = rnorm(N)
X = 1:N
slopes = c(rep(1.5,40),rep(2,N-40))
y = rep(5,N) + slopes*X + err                  
alpha1 = 1.0
coeffs1 = bhat.func(y,X,alpha1)
alpha2 = .9
coeffs2 = bhat.func(y,X,alpha2)
plot(x=X,y=y)
abline(a=coeffs2[1],b=coeffs2[2],lty=2,col="red")
abline(a=coeffs1[1],b=coeffs1[2],lty=2)
legend("right", legend=c("OLS","PWD"), col=c(1,2), lty=c(2,2), lwd=c(1,1))

Example output



PWD documentation built on May 2, 2019, 10:21 a.m.