1
$\begingroup$

I have this interesting data where I would like to estimate possibly a parameter of the difference (between $A+B$ and $A+C$, inference using both) that would allow me to infer the development of $A$ (whether there is a propensity to decrease or increase).

Any hint as to how to approach it included type of modeling/estimation procedure?

Here is part of the data: The data itself is a rate of observing number of species in days.

These have been calculated in R based on this formula for $A$:

A = obs / mean(obs.window)

The values of $B$ and $C$ in R are based on the formulas:

B = obs / min(obs.window)

and

C = obs / max(obs.window)

where obs is a observed number of species per day and obs.window is a average value of a sliding window of $10$ days (moving average).

 x <- "A B C 
 1  0.63 0.67 0.61
 2  0.62 0.64 0.60
 3  0.64 0.65 0.59
 4  0.70 0.70 0.63
 5  0.71 0.73 0.68
 6  0.70 0.75 0.69
 7  0.71 0.75 0.70
 8  0.74 0.76 0.71
 9  0.79 0.81 0.74
10 0.80 0.83 0.76
11 0.82 0.84 0.78
12 0.82 0.84 0.80
13 0.83 0.85 0.81
14 0.81 0.88 0.80
15 0.78 0.84 0.77
16 0.75 0.79 0.74
17 0.73 0.77 0.72
18 0.72 0.75 0.71
19 0.73 0.75 0.71
20 0.73 0.75 0.71
21 0.74 0.76 0.72
22 0.72 0.76 0.71
23 0.71 0.74 0.69
24 0.73 0.75 0.70
25 0.78 0.79 0.71
26 0.82 0.84 0.77
27 0.80 0.84 0.78
28 0.77 0.81 0.76
29 0.79 0.81 0.75
30 0.83 0.84 0.78
31 0.86 0.87 0.82
32 0.85 0.87 0.83
33 0.83 0.84 0.82
34 0.78 0.85 0.77
35 0.74 0.80 0.72
36 0.72 0.76 0.71
37 0.74 0.77 0.70
38 0.75 0.75 0.70
39 0.78 0.81 0.72
40 0.78 0.82 0.75" 

And here some adjustment:

data <- read.table(text=x, header = TRUE)

data$diff_AC <- with(data, (A-C))
data$diff_AB <- with(data, (A-B))

with(data, plot(A~1, col=1))
with(data, points(B~1, col=2))
with(data, points(C~1, col=3))

EDIT: I'm interested in estimation of the relationship of the interval and its overall with A as an idicator.

However, I was thinking using Beta distribution and simulation on rolling window of 20 days, would this be anyhing meaningful?

windw <- 20; # rolling windows size

for(i in 1:10){
    dt <- data[(1:i):(i+windw), ] 
    # mean & variance
    dt$mu_A <- with(dt, mean(A))
    dt$sig_A <- with(dt, var(A))
    # estimate alpah & beta via moments
    moment_alpha_A <- with(dt, mu_A*(mu_A*(1-mu_A)/sig_A-1))
    moment_beta_A <- with(dt, (1-mu_A)*(mu_A*(1-mu_A)/sig_A-1))
    # simulate
    rb_A <- rbeta(10000, unique(moment_alpha_A), unique(moment_beta_A))
    # plot
    with(dt, plot(A~1, col=1))
    abline(h=median(rb_A), col="blue3", lwd=3)
    abline(h=tail(dt$A,1), col="red3", lwd=1)
    Sys.sleep(1)
}
$\endgroup$
1
  • $\begingroup$ You say "i'm interested in the relationship of the interval and its over all with A as an indicator." 1) Its overall WHAT? 2) What is "the interval" in these data? 3) What is A supposed to be an indicator for? $\endgroup$ Commented Mar 30, 2017 at 3:18

1 Answer 1

1
$\begingroup$

I'm not sure but here is the best solution I can provide:

I feel sort of optimization should be used to solve this issue, or definitely better model (rather then linear OLS model) but nonlinear...

data$retA <- with(data, as.numeric(c(0,diff(A))/lag(A,1)))


diff_binAB <- with(data, unique(diff_AB))
mse <- numeric(length(diff_binAB))

for(i in 1:length(diff_binAB)){
    pwise <- with(data, lm(retA ~ diff_AB*(diff_AB < diff_binAB[i]) + diff_AB*(diff_AB >= diff_binAB[i])))
    mse[i] <- summary(pwise)[6]
   }

mse <- as.numeric(mse)
mse 

diff_binAB[which(mse==min(mse))]
# -0.07

diff_binAC <- with(data, unique(diff_AC))
mse1 <- numeric(length(diff_binAC))

for(i in 1:length(diff_binAC)){

    pwise <- with(data, lm(retA ~ diff_AC*(diff_AC < diff_binAC[i]) + diff_AC*(diff_AB >= diff_binAC[i])))
    mse1[i] <- summary(pwise)[6]
   }

mse1 <- as.numeric(mse1)
mse1 

diff_binAC[which(mse1==min(mse1))]
# 0.04 

Here the results would suggest that the return (rate of change) is explained if the difference between A and B is at -0.07 (negative difference) and 0.04 with possitive difference between A and C.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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