Hi experts,
I am trying to build a financial model to predict stock price using neuralnet package in R. When executing following code, I am getting an error. It should be noted that in below code train_data is a data frame containing columns "return" and "adj_close". Same columns are available in the data frame test_data as well.
# Train a neural network using the training data
nn <- neuralnet(return ~ adj_close, train_data)
# Use the trained neural network to make predictions on the test data
predictions <- compute(nn, test_data[,"adj_close"])$net.result
The error generated is as follows:
Error in if (ncol(newdata) == length(object$model.list$variables)) { :
argument is of length zero
Please note that test_data as well as train_data both have values in them 402 and 102 rows respectively.
What could be going wrong here with the code. Really appreciate your help and advice to resolve the issue.
Thanks in advance.
TSK