Time series analysis for predicting a binary outcome I'm fairly new to time series analysis. I want to analyze two series of variables in a span of time to predict a binary outcome.
For example i collect data over time at my home of two variables:
VarA the temperature over time
VarB the humidity over time
Then at 12:00 am i stop collecting this data and i see at 4:00 pm if it rains or not.
With a big dataset i want to predict given the time seres data collected till 12:00 am if it will rain at 4:00 pm. How can i accomplish this?
I was thinking about a k-nearest neighbors regression type analysis but i'm not sure how can i implement this.
EDIT:
Here a fictional data set, i don't have already the data because i'm still defining the details. I want to know if studying the two time series (the difference from the start or other parameters) is there a way to predict the outcome of the day

 A: There are many models that you can use for binary classification problems, such as logistic regressions, linear discriminant analysis, K-nearest-neighbours, trees, random forest, support vector machines, etc. You can review some of these methods in the book An Introduction to Statistical Learning from James, G. et al, specially chapter 4.
If you want to implement a K-nearest-neighbour in R with your data you first need to make sure you have a training set, a test set and classifications for the training set. Then you can do it with the class package. Below you can see an example. I am generating 8 random observations of temperatures and relative humidity for 1000 days and then classifying as "rain" or "sun" using a simple rule (I suppose that always rains when the mean of humidity in each day is higher than 52). Once I generate the data I split it into a train set (750 first observations) and a test set (the other 250). Then I generate predictions for the test set using the classification of the first 750 observations and check the results:
library(class)

## Generate random temp and hum for 1000 days (rains when mean(hum) > 52)
input <- matrix(0, 1000, 16)
output <- character(1000)
for (i in 1:1000){
  input[i,1:8] <- sample(20:35, 8, replace = TRUE)
  input[i,9:16] <- sample(40:60, 8, replace = TRUE)
  if (mean(input[i,9:16]) > 52) {
    output[i] <- "rain"
  } else {
    output[i] <- "sun"
  }
}
data <- data.frame(input, as.factor(output))
names(data) <- c(paste("temp_", 1:8), paste("hum_", 1:8), "output")

## Split data into train, test and classification
train <- data[1:750, 1:16]
test <- data[751:1000, 1:16]
cl <- data[1:750, 17]

## Run K-Nearest Neighbour with k=1 to predict last 250 obs
(kn <- knn(train, test, cl, k = 1))
(success <- sum(data[751:1000, 17] == kn))

