Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pldv issues with upper treshold #60

Open
Tanguy-Richard opened this issue Aug 21, 2024 · 0 comments
Open

pldv issues with upper treshold #60

Tanguy-Richard opened this issue Aug 21, 2024 · 0 comments

Comments

@Tanguy-Richard
Copy link

Hi,

To put it simply, I want to estimate a random effects model with censored data.
I am trying to use the pldv function to do this.

However, I have not been able to implement double threshold censoring.
Every time I try to use right censorship, I'm faced with:
"Error in maxOptim(fn = fn, grad = grad, hess = hess, start = start, method = "BFGS", :
NA in initial gradient"

Here is a toy example to replicate the problems:
(it more or less corresponds to the lab experiment pilot data I tried to use)

Data generation:

library(plm)

# Number of individuals
Nb_simulation = 20

# Individual random effects (temporal invariant)
effect_indivs <- rnorm(Nb_simulation,0,3.5)
# Treatments effects (
effect_temps <- c( 1.5 , 3.8 , 4.0 , 3.7 , 5.4 )
# Dataset creation
data_sim <- data.frame(
  temps1 = effect_indivs + effect_temps[1],
  temps2 = effect_indivs + effect_temps[2],
  temps3 = effect_indivs + effect_temps[3],
  temps4 = effect_indivs + effect_temps[4],
  temps5 = effect_indivs + effect_temps[5]
) 
# Independant error term generation
data_sim <- data_sim + rnorm( Nb_simulation*5 , 0 , 3.5 )

# Both side censorship 
data_sim[data_sim<0] <- 0
data_sim[data_sim>10] <- 10


# Dataset reshaping
Tob_value <- data.frame(
  valeurs_pl = c(
    data_sim$temps1,
    data_sim$temps2,
    data_sim$temps3,
    data_sim$temps4,
    data_sim$temps5
  ),
  temps = as.factor(
    c(
    rep(1,Nb_simulation),
    rep(2,Nb_simulation),
    rep(3,Nb_simulation),
    rep(4,Nb_simulation),
    rep(5,Nb_simulation)
  )
  ),
  inds = as.factor(rep(1:Nb_simulation,5))
)

# Use of pdata.frame
Tob_panel <- pdata.frame(Tob_value, index = c("inds","temps"))

One side censorship

Lower treshold

Tob_mod_inf <- pldv(valeurs_pl ~ 1 + temps, data = Tob_panel, model = "random", R = 128, lower = 0, sample = "cens", method = "bfgs")
summary(Tob_mod_inf)

Everything seems to be working fine.

Upper treshold

Tob_mod_sup <- pldv(valeurs_pl ~ 1 + temps, data = Tob_panel, model = "random", R = 128, upper = 10, sample = "cens", method = "bfgs")
summary(Tob_mod_sup) # /!\ error

Which gives an error

Two sides censorship


Tob_mod <- pldv(valeurs_pl ~ 1 + temps, data = Tob_panel, model = "random", R = 128, lower = 0, upper = 10, sample = "cens", method = "bfgs")
summary(Tob_mod) # /!\ error

Same error

Thank you in advance for your help,

Tanguy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant