0

I have daily data by latitude and longitude on some weather variables such as maxT and minT. I wish to re-sample from this data such that if a lat/long on a day is selected to be in the sample then all lat/longs within 300 Kms of this lat/long (neighbours) should also be a part of the sample. I am not sure how to do this.So far I have used the command dnearneigh from the spdep package to identiy the lat/longs within 300 kms of each lat/long.

Thanks in advance for your help. Here is my sample data and the R code.

dput(head(rad_aod_temp_daily,1))

structure(list(latitude = 23L, longitude = 68L, year = 2000L, 
month = 11L, day = 21L, xygrid_id = 632L, solar_rad = 2.070422, 
aod = 0.27, day_of_season = 1L, cntry = structure(1L, .Label = "India", class = "factor"), 
state = structure(2L, .Label = c("Bihar", "Gujarat", "Haryana", 
"Madhya Pradesh", "Maharashtra", "Punjab", "Rajasthan", "Uttar Pradesh"
), class = "factor"), log_sr = 0.7277523, time = 1L, time2 = 1L, 
date = structure(1275L, .Label = c("01-Apr-01", "01-Apr-02", 
"01-Apr-03", "01-Apr-04", "01-Apr-05", "01-Apr-06", "01-Apr-07", 
"01-Apr-08", "01-Apr-09", "01-Apr-10", "01-Apr-11", "01-Apr-12", 
"01-Apr-13", "01-Dec-00", "01-Dec-01", "01-Dec-02", "01-Dec-03", 
"01-Dec-04", "01-Dec-05", "01-Dec-06", "01-Dec-07", "01-Dec-08", 
"01-Dec-09", "01-Dec-10",class = "factor"), maxt = 31.22, mint = 16.11, 
meant = 23.67), .Names = c("latitude", "longitude", "year", 
"month", "day", "xygrid_id", "solar_rad", "aod", "day_of_season", 
"cntry", "state", "log_sr", "time", "time2", "date", "maxt", 
"mint", "meant"), row.names = 1L, class = "data.frame")

library(spdep)
coords <- as.matrix(cbind(rad_aod_temp_daily$longitude,rad_aod_temp_daily$latitude))
nlist <- dnearneigh(coords, d1=0,d2=300,longlat=TRUE)
Siguza
  • 21,155
  • 6
  • 52
  • 89
Ridhima
  • 177
  • 3
  • 18

1 Answers1

1

After you identify the cases that meet your criteria, create a new data frame and bootstrap that one.

#create data frame
X1=rnorm(1000,0,1)
X2=rnorm(1000,0,1)
df=cbind(X1,X2)
#create indicator to bootstrap
df$indicator=ifelse(X1>.75,1,0) #I select only cases greater than .75 on X1
df.new=df[df$indicator==1,]

After you created df.new boostrap those data.

User7598
  • 1,658
  • 1
  • 15
  • 28