32 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
57
views
Generating Samples from Customized Distribution - Stuck with Range Limitation
I'm struggling to generate samples from a custom distribution defined by its CDF but facing a persistent limitation. The issue boils down to:
Limited Range of Samples: Despite having a theoretical ...
0
votes
1
answer
439
views
f() values at end points not of opposite sign
I am trying to get the inverse of cdf and use it for the QQ plot as follows.
cdf<-function(x,b){
1 - (1+(b*x*(b*x+2)/(b^2+2)))*exp(-b*x)
}
qf<-function(p,b){
uniroot(function(x) cdf(x,b) - ...
3
votes
2
answers
175
views
Find the x that gives a specific value of a function
I have this function:
a <- 1
b <- 2
get_y <- function (x,a,b) {
a * b * x
}
And I want to create a function that takes in get_y and returns the x that makes y = 4 for example.
How would ...
1
vote
1
answer
112
views
How to optimize an equation in R
Suppose f(u,v)=v(1+theta(1-v)(1-2u))=t, where u and t are uniform(0,1) random samples and theta=0.5. How can I optimize the value of v in R?
I tried to make a code using uniroot in r, but it gave me ...
0
votes
0
answers
66
views
Error in integrate : evaluation of function gave a result of wrong length after Vectorize
I am trying to simulate survival data from a Weibull PH model with a time varying covariate.
I wrote a function invS that integrates the hazard function containing the time-varying component.
Then I ...
3
votes
2
answers
309
views
Error in uniroot while calculating XIRR in R
Reproducible example:
v <- c(-400000.0,-200000.0, 660636.7)
d <- c("2021年10月27日","2022年12月23日","2023年01月04日")
d1 <- as.Date(d, format="%Y-%m-%d")
tvm::...
0
votes
2
answers
112
views
Update value in function using uniroot
Just some smaller changes which do not need to be considered.
0
votes
1
answer
419
views
how to predict x given y for nls model?
I am using the nls SSlogis function in R to make a model expressing water absorption in a plant, where y=water absorption (g per m^2), and x=minutes in water. For a given y value (in this case max ...
1
vote
1
answer
104
views
Solve improper double integral using integrate and uniroot functions
We have a function. t ~ Weibull(alpha, lambda) and c ~ Exponential(beta):
Given p = 0.10, alpha = 1, lambda = 4. Find the value of beta.
We want to integrate this function for t then to c. Then find ...
0
votes
1
answer
131
views
How can I combine uniroot and lapp/overlay function from terra package to perform raster calculation?
I am trying to lapp from terra package to solve an equation with raster cells and uniroot function. I am stuck on how to get the final raster output from combining lapp and uniroot functions.
I would ...
0
votes
1
answer
56
views
Solving a single variable equation in R using unitroot
I have a complicated equation for which I have written the code as follows:
sigma = 1.336449027;
f_t = 0.500185113;
alpha = 0.364; #elasticity of capital
beta = 0.115; #elasticity of labor
R = 3....
1
vote
1
answer
100
views
Identifying uniroot for multiple independent variables in R
I am trying to calculate the value of x where y = 0. I could able to do it for single x using the following code
lm.model <- lm(y ~ x)
cc <- coef(lm.model)
f <- function(x) cc[2]*x + cc[1]
...
1
vote
0
answers
47
views
Dplyr calculation gives an error and stops running the calculations
I'm trying to calculate IRRs with cashflow datas that I have for my data's funds. I try this with following code:
install.packages("tvm")
library(dplyr)
library(tvm)
var1 <- my_data %>%...
0
votes
1
answer
129
views
Why can't I use uniroot with plot?
I am working on code that uses the uniroot function to approximate the root of an equation. I am trying to plot the behaviour of the function being passed through uniroot as the value of a free ...
0
votes
1
answer
55
views
Uniroot solution two equatations
I posted similar question a few days later, but now I have more complex problem.
I have this dataset
product = data.frame(length = c(100, 200, 300, 400), qty = c(1, 2, 1, 3))
And price is defined by ...