#can also be 'di' output of sim_trajectory_joint (set gen_irreg=TRUE)
di <- data.frame(X=runif(n=9), Y=runif(n=9),
time_to_next=c(2,4,15,8,5,18,3,5,NA))
di$date_as_sec <- c(0, cumsum(di$time_to_next[-9]))
region_centroids <- cbind(X=runif(2), Y=runif(2))
#one log observation with dt =18 > 16 will be omitted
spl <- spline_interp(di=di, area_map=NULL, reg_dt=3, max_dt_wo_obs=16, maxStep=NULL,
centroids=region_centroids, nstates=2, spline_deg=3, split_logv=-3)
plot(di[,c("X","Y")], xlim=c(0,1), ylim=c(0,1), type="b", las=1,
"Observations interpolated by regular interval spline")
lines(spl$d_ds[,c("X","Y")], type="l", col="red")
legend("topleft", col=1:2, legend=c("observations","spline"), lty=1)
Run the code above in your browser using DataLab