CrawlWrap wont fit #186
Unanswered
Thomascelie
asked this question in
Q&A
Replies: 1 comment
-
It looks like you're missing parameters for the measurement error model in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a large dataset with some temporal irregularity and about 30% of my GPS points are missing. I have identified the missing data points and these are present in my dataset as rows with NA values and a timestamp for when the location should have been send. I want to use Crawlwrap to create more regular data and estimate the missing values. However I cant get the model to fit. I have tried loads of different values for theta but that just does not seem to work. Does my data have too many missing datapoints or is there something else I have been missing?
This is my current code:
library(readr)
library(dplyr)
library (momentuHMM)
library(sf)
#reading the data
DATA <- read_csv("D:/filepath.csv")
Convert to a simple feature object with WGS 84 (EPSG 4326), handling missing coordinates
sf_data <- st_as_sf(DATA %>% filter(!is.na(x) & !is.na(y)), coords = c("x", "y"), crs = 4326)
Transform to UTM zone 31N (EPSG 32631)
sf_data_utm <- st_transform(sf_data, crs = 32631)
Extract the UTM coordinates
utm_coords <- st_coordinates(sf_data_utm)
Create new columns for UTM coordinates in the original DATA frame
DATA <- DATA %>%
mutate(x_utm = ifelse(!is.na(x) & !is.na(y), utm_coords[, 1], NA),
y_utm = ifelse(!is.na(x) & !is.na(y), utm_coords[, 2], NA))
#use crawlwrap to add missing data point to create regular data
DATA$t <-as.POSIXct(DATA$t)
Calculate the natural logarithm of 50
ln_sd_50m <- log(50)
error_corr <- 0 # Assuming no correlation for simplicity
Define the constant error model
err.model <- list(
x = ~ ln_sd_50m - 1,
y = ~ ln_sd_50m - 1,
rho = ~ error_corr
)
Fit the model and predict locations at 5-minute intervals
crwout <- crawlWrap(
obsData = DATA,
timeStep = "5 min",
theta = c(7, -0.1),
fixPar = c( NA, NA), # Adding fixPar as an example
err.model = err.model, # error model
attempts = 500,
coord = c("x_utm", "y_utm"),
Time.name = "t",
retryFits = 10, retrySD = 20
)
I have addes this screenshot of my dataset, where I have not yet added the missing datapoints.
Does anyone know what I can do here?
Beta Was this translation helpful? Give feedback.
All reactions