Description Usage Arguments Value Examples
View source: R/functions-code.R
This function computes PWD regression coefficients for response y and predictors X given a particular value of alpha.
1 | bhat.func(y, X, alpha)
|
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. |
(p+1)-length vector representing the regression coefficients associated with a PWD regression of y upon X given PWD parameter alpha.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.