0
$\begingroup$

I have a dataset where I'm trying to gauge the importance of certain drivers (X and Y) over various time periods. I'd like to look at the importance of certain ranges of times, which will overlap with each other.

I'm assuming that there may be a time window that is more important than others. As an example, given a range of 15 days before an event, I weighted the 5-8th days, so I'm assuming the 8th day mean will have the highest importance score. But given that there is a lot of overlap between the windows, is this a legitimate way to characterize the data?

As an example dataset (using the randomForest library in R), my dataset would look like this.

library(randomForest)

#Results can be either Big or Small
Result<-as.factor(c("Big", "Small", "Big", "Small"))

#Event 1
X1<-c(1,2,1,1,20,30,42,20,3,4,5,6,5,2,2)
Y1<-c(1,3,1,1,20,30,40,21,3,4,4,6,5,3,2)

#Event 2
X2<-c(1,1,1,1,2,3,4,2,3,4,3,3,5,3,2)
Y2<-c(1,1,2,1,2,3,4,2,3,4,5,6,5,2,2)

#Event 3
X3<-c(2,2,1,1,20,33,40,20,3,4,5,6,3,3,2)
Y3<-c(1,0,1,1,22,30,40,20,3,4,5,4,5,3,2)

#Event 4
X4<-c(1,3,1,2,2,3,4,2,3,4,5,6,3,3,2)
Y4<-c(2,1,1,3,2,3,4,2,3,4,5,6,5,2,2)


#Calculate 2,4,8,12,15 day means for each event
MeanDay2X1<-mean(X1[1:2])
MeanDay2Y1<-mean(Y1[1:2])
MeanDay4X1<-mean(X1[1:4])
MeanDay4Y1<-mean(Y1[1:4])
MeanDay8X1<-mean(X1[1:8])
MeanDay8Y1<-mean(Y1[1:8])
MeanDay12X1<-mean(X1[1:12])
MeanDay12Y1<-mean(Y1[1:12])
MeanDay15X1<-mean(X1[1:15])
MeanDay15Y1<-mean(Y1[1:15])


MeanDay2X2<-mean(X2[1:2])
MeanDay2Y2<-mean(Y2[1:2])
MeanDay4X2<-mean(X2[1:4])
MeanDay4Y2<-mean(Y2[1:4])
MeanDay8X2<-mean(X2[1:8])
MeanDay8Y2<-mean(Y2[1:8])
MeanDay12X2<-mean(X2[1:12])
MeanDay12Y2<-mean(Y2[1:12])
MeanDay15X2<-mean(X2[1:15])
MeanDay15Y2<-mean(Y2[1:15])


MeanDay2X3<-mean(X3[1:2])
MeanDay2Y3<-mean(Y3[1:2])
MeanDay4X3<-mean(X3[1:4])
MeanDay4Y3<-mean(Y3[1:4])
MeanDay8X3<-mean(X3[1:8])
MeanDay8Y3<-mean(Y3[1:8])
MeanDay12X3<-mean(X3[1:12])
MeanDay12Y3<-mean(Y3[1:12])
MeanDay15X3<-mean(X3[1:15])
MeanDay15Y3<-mean(Y3[1:15])


MeanDay2X4<-mean(X4[1:2])
MeanDay2Y4<-mean(Y4[1:2])
MeanDay4X4<-mean(X4[1:4])
MeanDay4Y4<-mean(Y4[1:4])
MeanDay8X4<-mean(X4[1:8])
MeanDay8Y4<-mean(Y4[1:8])
MeanDay12X4<-mean(X4[1:12])
MeanDay12Y4<-mean(Y4[1:12])
MeanDay15X4<-mean(X4[1:15])
MeanDay15Y4<-mean(Y4[1:15])

DF1<-data.frame(MeanDay2X1,MeanDay2Y1,MeanDay4X1,MeanDay4Y1,MeanDay8X1,MeanDay8Y1,MeanDay12X1,MeanDay12Y1,MeanDay15X1,MeanDay15Y1)
colnames(DF1)<-c("MeanDay2X","MeanDay2Y","MeanDay4X","MeanDay4Y","MeanDay8X","MeanDay8Y","MeanDay12X","MeanDay12Y","MeanDay15X","MeanDay15Y")
DF2<-data.frame(MeanDay2X2,MeanDay2Y2,MeanDay4X2,MeanDay4Y2,MeanDay8X2,MeanDay8Y2,MeanDay12X2,MeanDay12Y2,MeanDay15X2,MeanDay15Y2)
colnames(DF2)<-c("MeanDay2X","MeanDay2Y","MeanDay4X","MeanDay4Y","MeanDay8X","MeanDay8Y","MeanDay12X","MeanDay12Y","MeanDay15X","MeanDay15Y")
DF3<-data.frame(MeanDay2X3,MeanDay2Y3,MeanDay4X3,MeanDay4Y3,MeanDay8X3,MeanDay8Y3,MeanDay12X3,MeanDay12Y3,MeanDay15X3,MeanDay15Y3)
colnames(DF3)<-c("MeanDay2X","MeanDay2Y","MeanDay4X","MeanDay4Y","MeanDay8X","MeanDay8Y","MeanDay12X","MeanDay12Y","MeanDay15X","MeanDay15Y")
DF4<-data.frame( MeanDay2X4,MeanDay2Y4,MeanDay4X4,MeanDay4Y4,MeanDay8X4,MeanDay8Y4,MeanDay12X4,MeanDay12Y4,MeanDay15X4,MeanDay15Y4)
colnames(DF4)<-c("MeanDay2X","MeanDay2Y","MeanDay4X","MeanDay4Y","MeanDay8X","MeanDay8Y","MeanDay12X","MeanDay12Y","MeanDay15X","MeanDay15Y")

DF<-rbind(DF1,DF2)
DF<-rbind(DF,DF3)
DF<-rbind(DF,DF4)

#1 single data frame
DF$Result<-Result




RF <- randomForest(Result~., importance = TRUE, data = DF, ntrees=20) #nodesize=5

RF

RF$importance
RFImp <- importance(RF, type = 1)
RFImp

varImpPlot(RF)

Given the above data and results, is it possible to use the importance values provided from this model when there is such overlap between the time periods? Or is it more proper to break up the data into distinct (non overlapping) time periods?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.