1
$\begingroup$

Consider the following equation:
enter image description here

where,
OPDV = speed difference between a vehicle and its lead vehicle in the same lane
(delta x - L) = H = distance between the front center of vehicle and rear end of its lead vehicle
CC6 and delta.CC5 are parameters.

Sample data

Now, consider the following data frame, that contains all parameters of the equation:

df <- data.frame(w = rep(1.83, 17),
                 vrate = 0.0006,
                 CC4 = -0.35,
                 dCC5 = 0.35,
                 H = c(300, 200, 100, 70, 60, 50, 40, 30, 20,
                       10, 5, 2, 1, 0.5, 0.005, 0.0005, 0))
library(dplyr)

df <- df %>% 
  mutate(CC6 = 1*vrate/w) %>% 
  mutate(          
         OPDV = -CC6*H^2-dCC5,
         DV2 = -CC6*H^2)  

Note that I'm considering CC6/17000 as one parameter CC6.

This will result in following plot:

library(ggplot2)
ggplot(data = df)+   
  geom_line(aes(x = (OPDV), y = H, color = "OPDV"))  

enter image description here

Here, I assumed the values of CC6 and CC5. But in observed data I don't know the values of these parameters

Observed Data

I have observed values of OPDV and H. When I plot them, I want to use a smoothing method that is similar to this equation, i.e. a quadratic part and a constant subtracted from it. Following is what I get if I use quadratic equation only:

ggplot(data = ud8 %>% filter(svelkm.level == "(15,20]",
                              abs(slo_v)>0.1, 
                             abs(slo_p)>0.1))+
  geom_point(aes(x = OPDV, y = frspacing_OPDV)) +
  geom_smooth(aes(x = OPDV, y = frspacing_OPDV),
              method="lm", formula = y ~ x + I(x^2))  

enter image description here

Question

Which smoothing method is best to use that can replicate the equation? I use R.

$\endgroup$
2
$\begingroup$

Your equation appears to posit a straight line relationship between $y$ (i.e. $\text{OPDV}$) and $x$ (=$H^2$).

In that case the most obvious first thing to consider as a way to estimate the parameters would be linear regression (though there may be an argument for fitting a linear model via means other than least squares, such as via a GLM perhaps), depending on the properties of the (unstated) error term.

It's not clear what you intend to do with smoothing beyond just fitting the equation), unless you're considering whether your model might be incorrect, in which case some locally linear model in $H^2$ might be a good thing to lok at. It's also not clear why you're progressing the way you are -- it suggests there may be missing context.

Much about the question is unclear (but this was getting too long for a comment) and should be clarified.


As a side comment, a data frame is not a suitable object to hold vectors of different lengths, along with scalars. A list would be a suitable R data type for bundling up different-shaped components.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.