Description Usage Arguments Details Value Author(s) References Examples
Prediction function for panel neural networks
1 2 |
obj |
The panelNNET object to be predicted from |
newX |
New X's. If empty, return the in-sample prediction. |
fe.newX |
A factor of cross-sectional units. Cross-sectional units must be a subset of those supplied at fitting. |
new.param |
New parametric variables corresponding to the new X's. |
se.fit |
If TRUE, calculate standard errors of the fitted values. This involves computing the Jacobian for the fitted values, and can be slow. Currently only numerical Jacobian computation is implemented. Pointwise standard errors are computed to each paramater covariance matrix stored in the fitted panelNNET object. |
Prediction function for panelNNET
The predicted values. If se.fit = TRUE, a matrix with predicted values in the first column, and pointwise standard errors corresponding to each covariance matrix in the object in the subsequent columns.
Andrew Crane-Droesch
Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. The elements of statistical learning. Vol. 1. Springer, Berlin: Springer series in statistics, 2001.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | set.seed(1)
#Fake dataset
N <- 1000
p <- 20
X <- as.data.frame(mvrnorm(N, rep(0, p), diag(rep(1, p))))
id <- factor(0:(N-1)%%20+1)
id.eff <- rnorm(nlevels(id), sd = 5)
time <- 0:(N - 1)%/%20+1
u <- rnorm(N, sd = 5)
y <- sin(3*X$V1) - cos(4*X$V2) + 3*tanh((-2*X$V1+X$V2+X$V4)*X$V3) + X$V6/(X$V7+8) + id.eff[id] +
.5*time - .005*time^2 + u
hist(y)
#Parametric and nonparametric terms
X <- X
P <- cbind(time, time^2)
#Traiing and test set
tr <- time<35
te <- tr == FALSE
#Fitting a two-layer neural net with 5 and 3 hidden units
pnn <- panelNNET(y[tr], X[tr,], hidden_units = c(5,3)
, fe_var = id[tr], lam = 1
, time_var = time[tr], param = P[tr,], verbose = FALSE
, bias_hlayers = TRUE, gravity = 1.01
, RMSprop = TRUE, convtol = 1e-5, maxit = 10000
, activation = 'tanh', doscale = TRUE, parapen = c(0,0)
)
plot(pnn)
summary(pnn)
##Predicting for the test set
pr <- predict(pnn, newX = as.matrix(X[te,]), fe.newX = id[te], new.param = P[te,])
plot(y[te], pr)
mean((y[te] - pr)^2)
abline(0,1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.