Closed ehsan-hz closed 10 months ago
I am getting the output indicated in the readme.
I think you need to install a linear programming package in step 2 here: https://github.com/jkcshea/ivmte#installation-and-requirements
Hello; I have installed it completely, but I still get the same error.
Alexander Torgovitsky @.***> در تاریخ چهارشنبه ۱۵ نوامبر ۲۰۲۳ ساعت ۵:۴۱ نوشت:
I am getting the output indicated in the readme.
I think you need to install a linear programming package in step 2 here: https://github.com/jkcshea/ivmte#installation-and-requirements
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1811690569, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7B2L3ISKKQ4ERS4I5CDYEQQEVAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJRGY4TANJWHE . You are receiving this because you authored the thread.Message ID: @.***>
which LP package did you install?
During the timeframe since you replied to my email, I've worked on addressing errors, and the initial issue has been resolved. Now, my only challenge is installing the "gurobi" and "cplexAPI" packages.
On Fri, Nov 17, 2023, 17:57 Alexander Torgovitsky @.***> wrote:
which LP package did you install?
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1816527694, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7BZINTGYKIS5FYP63TLYE5X3TAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJWGUZDONRZGQ . You are receiving this because you authored the thread.Message ID: @.***>
Good news: you only need one of those packages. I recommend you install Gurobi. It will allow you to use more features of the package.
Thank you for your attention. However, I encountered another error when running the following code :
args[["m1"]] <- ~ u + factor(yob)55 + factor(yob)60Error: unexpected numeric constant in "args[["m1"]] <- ~ u + factor(yob)55"
jkcshea @.***> در تاریخ جمعه ۱۷ نوامبر ۲۰۲۳ ساعت ۱۸:۳۹ نوشت:
Good news: you only need one of those packages. I recommend you install Gurobi. It will allow you to use more features of the package.
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1816598329, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7BYNLZWVF56LNHPKUULYE542LAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJWGU4TQMZSHE . You are receiving this because you authored the thread.Message ID: @.***>
It looks like you're running the example code from our vignette. That's great, thanks!
Unfortunately, R can't parse factor(yob)55
(although that's how R names dummy variables in regressions).
The work around is to declare the dummy as (yob == 55)
.
E.g., args[["m1"]] <- ~ u + (yob == 55) + (yob == 60)
Check out the vignette for more examples of how to declare MTRs.
Yes, I am researching the instrumental variable topic, and your joint paper with Mr. Torgovitsky caught my interest. Currently, whenever I invoke the loopivmte function, I encounter an error, for example:
Function for computing genlate bounds at different values ###> loopivmte <- function(args, alphalist) {+ df.lb <- data.frame(alpha = alphalist, value = NA, type = "lb")+ df.ub <- data.frame(alpha = alphalist, value = NA, type = "ub")+ for (i in 1:length(alphalist)) {+ args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0)+ args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)+ r <- do.call(ivmte, args)+ df.lb$value[i] <- r$bound[1]+ df.ub$value[i] <- r$bound[2]+ }+ return(rbind(df.lb, df.ub))+ }> ### Run the quadratic case ###> plotquadratic <- loopivmte(args, alphalist)Error in args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0) :
object of type 'closure' is not subsettable
jkcshea @.***> در تاریخ شنبه ۱۸ نوامبر ۲۰۲۳ ساعت ۱:۴۶ نوشت:
It looks like you're running the example code from our vignette. That's great, thanks!
Unfortunately, R can't parse factor(yob)55 (although that's how R names dummy variables in regressions). The work around is to declare the dummy as (yob == 55).
E.g., args[["m1"]] <- ~ u + (yob == 55) + (yob == 60)
Check out the vignette for more examples of how to declare MTRs.
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1817185986, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7B2L2FLZTS4RWZP5NT3YE7O2ZAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGE4DKOJYGY . You are receiving this because you authored the thread.Message ID: @.***>
sorry i Excuse me, but the error in the previous message was a mistake. Here is the correct error message:
Error: 'genlate.lb' must be strictly less than 'genlate.ub'.
Seyyed Ehsan Hoseinzadeh @.***> در تاریخ شنبه ۱۸ نوامبر ۲۰۲۳ ساعت ۱۵:۳۵ نوشت:
Yes, I am researching the instrumental variable topic, and your joint paper with Mr. Torgovitsky caught my interest. Currently, whenever I invoke the loopivmte function, I encounter an error, for example:
Function for computing genlate bounds at different values ###> loopivmte <- function(args, alphalist) {+ df.lb <- data.frame(alpha = alphalist, value = NA, type = "lb")+ df.ub <- data.frame(alpha = alphalist, value = NA, type = "ub")+ for (i in 1:length(alphalist)) {+ args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0)+ args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)+ r <- do.call(ivmte, args)+ df.lb$value[i] <- r$bound[1]+ df.ub$value[i] <- r$bound[2]+ }+ return(rbind(df.lb, df.ub))+ }> ### Run the quadratic case ###> plotquadratic <- loopivmte(args, alphalist)Error in args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0) :
object of type 'closure' is not subsettable
jkcshea @.***> در تاریخ شنبه ۱۸ نوامبر ۲۰۲۳ ساعت ۱:۴۶ نوشت:
It looks like you're running the example code from our vignette. That's great, thanks!
Unfortunately, R can't parse factor(yob)55 (although that's how R names dummy variables in regressions). The work around is to declare the dummy as (yob == 55).
E.g., args[["m1"]] <- ~ u + (yob == 55) + (yob == 60)
Check out the vignette for more examples of how to declare MTRs.
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1817185986, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7B2L2FLZTS4RWZP5NT3YE7O2ZAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGE4DKOJYGY . You are receiving this because you authored the thread.Message ID: @.***>
It looks like this is what you are trying to run:
loopivmte <- function(args, alphalist) {
df.lb <- data.frame(alpha = alphalist, value = NA, type = "lb")
df.ub <- data.frame(alpha = alphalist, value = NA, type = "ub")
for (i in 1:length(alphalist)) {
args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0)
args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)
r <- do.call(ivmte, args)
df.lb$value[i] <- r$bound[1]
df.ub$value[i] <- r$bound[2]
}
return(rbind(df.lb, df.ub))
}
### Run the quadratic case
plotquadratic <- loopivmte(args, alphalist)
But then you get the following error:
Error: 'genlate.lb' must be strictly less than 'genlate.ub'.
The arguments genlate.lb
and genlate.ub
determine the region of integration
(lb
stands for "lower bound," ub
stands for "upper bound").
The ivmte
function is going to integrate the MTRs from genlate.lb
up to genlate.ub
.
So you must set genlate.lb
to be strictly less than genlate.ub
.
The error is telling you that you did not do this.
The error likely stems from these two lines of code, whrere you set genlate.lb
and genlate.ub
.
args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0)
args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)
So take a look there and see what values you actually assigned.
Thank you very much for your help. Now, in your opinion, what is the reason for this error? [image: image.png]
jkcshea @.***> در تاریخ یکشنبه ۱۹ نوامبر ۲۰۲۳ ساعت ۱:۲۲ نوشت:
It looks like this is what you are trying to run:
loopivmte <- function(args, alphalist) { df.lb <- data.frame(alpha = alphalist, value = NA, type = "lb") df.ub <- data.frame(alpha = alphalist, value = NA, type = "ub") for (i in 1:length(alphalist)) { args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0) args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1) r <- do.call(ivmte, args) df.lb$value[i] <- r$bound[1] df.ub$value[i] <- r$bound[2] } return(rbind(df.lb, df.ub)) }### Run the quadratic caseplotquadratic <- loopivmte(args, alphalist)
But then you get the following error:
Error: 'genlate.lb' must be strictly less than 'genlate.ub'.
The arguments genlate.lb and genlate.ub determine the region of integration (lb stands for "lower bound," ub stands for "upper bound"). The ivmte function is going to integrate the MTRs from genlate.lb up to genlate.ub. So you must set genlate.lb to be strictly less than genlate.ub. The error is telling you that you did not do this.
The error likely stems from these two lines of code, whrere you set genlate.lb and genlate.ub.
args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0) args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)
So take a look there and see what values you actually assigned.
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1817658312, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7B3QERNPPVRVJ2HFDGLYFEUY3AVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGY2TQMZRGI . You are receiving this because you authored the thread.Message ID: @.***>
I'm afraid your picture wasn't properly attached. It looks like you're responding via email. Maybe you can successfully attach the photo by responding on GitHub.
Hello, I'm encountering an error when running this section of codes, and I'm seeing the following error message. What could be the reason for this error? Also, can you explain what the variable 'late.Z' represents for?
args <- list(+ data = AE,+ ivlike = worked ~ morekids + samesex + morekids * samesex,+ target = "genlate",+ m0 = ~ u + I(uˆ2),+ m1 = ~ u + I(uˆ2),+ propensity = morekids ~ samesex,+ audit.nu = 200+ )> p <- predict(lm(data = AE, morekids ~ samesex),+ newdata = data.frame(samesex = c(0, 1)),+ type = "response"+ )> alphalist <- seq(from = 0, to = max(p[1], (1 - p[2])), by = .01)> loopivmte <- function(args, alphalist) {+ df.lb <- data.frame(alpha = alphalist, value = NA, type = "lb")+ df.ub <- data.frame(alpha = alphalist, value = NA, type = "ub")+ for (i in 1:length(alphalist)) {+ args[["genlate.lb"]] <- max(p[1] - alphalist[i], 0)+ args[["genlate.ub"]] <- min(p[2] + alphalist[i], 1)+ r <- do.call(ivmte, args)+ df.lb$value[i] <- r$bound[1]+ df.ub$value[i] <- r$bound[2]+ }+ return(rbind(df.lb, df.ub))+ }> plotquadratic <- loopivmte(args, alphalist) [image: image.png] Show Traceback [image: image.png] Rerun with Debug Error in (function (data, target, late.from, late.to, late.X, genlate.lb, : object 'late.Z' not found
jkcshea @.***> در تاریخ دوشنبه ۲۰ نوامبر ۲۰۲۳ ساعت ۲:۳۴ نوشت:
I'm afraid your picture wasn't properly attached. It looks like you're responding via email. Maybe you can successfully attach the photo by responding on GitHub.
— Reply to this email directly, view it on GitHub https://github.com/jkcshea/ivmte/issues/235#issuecomment-1818007509, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLG7B4R7ZH7WQGV7QJ7CQDYFKF7ZAVCNFSM6AAAAAA7IXAPI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJYGAYDONJQHE . You are receiving this because you authored the thread. Message ID: @.***>
When running the codes of the section estimate bounds on the ATE, I encountered the error as follows: