[R] Newton-RaphsonMethod

2019-02-24 Thread malika yassa via R-help
HELLOplease I want to approximate the solution of the equation 
f(x)=x*(x-2)+log(x)=0
for that i did this program

f <- function(x){x*(x-2)+log(x)}
x <- c(1 : 2)
f(x)
h <- 1e-7
df.dx <- function(x){(f(x + h) - f(x)) / h}
df.dx(3/2);df.dx(2)
 newton <- function(f, tol = 1e-7, x0 = 3/2, N = 100){
 h = 1e-7
 i = 1; x1 = x0
 p = numeric(N)
 while (i <= N) {
 df.dx = (f(x + h) - f(x)) / h
 x1 = (x0 - (f(x0) / df.dx))
 p[1] = x1
 i = i + 1
 if (abs(x1 - x0) < tol) break
 x0 = x1
 }
 return(p[1 : (i-1)])
 }
 app <- newton(f, x0 = 3/2)

but i cann't find this approximation
please can you help me?






[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2019-02-02 Thread malika yassa via R-help
Please, can you help me I have a equation to solve by newton method but I can 
not do it
for example

f<-function(x) {


2+X2-X3=0}
this equation have un solution in [1,2]
is there a function in R for solve it or i have to programme it




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] sustraction of two vectors of matrix

2018-12-05 Thread malika yassa via R-help
helloplease   I want to make a sustration of two vectors of a matrix
i have this program

aa<-matrix(outer(0:3,0:4,function(x,y) x+y*2),nrow=4,ncol=5)
for(i in 1:4)
+ {for(j in 2:5)
+ {bb[i,j-1]=aa[i,j]-aa[i,j-1]
+ }
+ }
at the end i obtain the bb=matrix( nrow=4,ncol=4)
but i cann't obtain this matrix
thank you very much




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] extrat non diagonal

2018-11-14 Thread malika yassa via R-help
hello
for examplei have this matrix
w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)aa<-matrix(w1,nrow=3,ncol=3)aa
 [,1] [,2] [,3]
[1,]  0.4  0.4  0.4
[2,]  0.1  0.1  0.1
[3,]  0.2  0.2  0.2

if i use this code 
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)

i will obtaine this matrix[,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]   NA   NA   NA

but me i want this matrix[,1] [,2] [,3]
[1,]  0.1  0.4  0.4
[2,]  0.2  0.2  0.1

thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] extrat non diagonal

2018-11-14 Thread malika yassa via R-help
helloi didn't obtaine the matrix after extrat non diagonalmy 
programx<-rnorm(6,0,1)

aa<-matrix(x,nrow=6,ncol=6)
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)

nrow=5ncol=6thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] extrat non diagonal value

2018-11-14 Thread malika yassa via R-help
helloplease i have this matrixx<-rnorm(6,0,1)

aa<-matrix(x,nrow=6,ncol=6)

i have to extrat non diagonal value, i use this code
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)

but i didn't get the resultthank you 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] calculate the integral

2018-10-24 Thread malika yassa via R-help
helloplease can anyone help me, I find it difficult to calculate this integrali 
have this programmx<-rnorm(10,0,1)y<-rexp(10,2)z<-exp(10,3)s<-vector()for (  j 
in 1:10)s[j]<-x[j+1]+x[j]s1[i]<-s[j]/2f<-function(y,u){exp(y-u)}sapply(x, 
function(i){
 z[j] integrate(f,lower=s1[j],upper=,s1[j+1] x=i)$value
for each value of x I will have a vectori can't calculate thisthank you in 
advance
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] calculate the integral

2018-10-24 Thread malika yassa via R-help
helloplease can anyone help me, I find it difficult to calculate this integrali 
have this programmx<-rnorm(10,0,1)y<-rexp(10,2)z<-exp(10,3)s<-vector()for (  j 
in 1:10)s[j]<-x[j+1]+x[j]s1[i]<-s[j]/2f<-function(y,u){exp(y-u)}sapply(x, 
function(i){
 z[j] integrate(f,lower=s1[j],upper=,s1[j+1] x=i)$value
for each value of x I will have a vectori can't calculate thisthank you in 
advance








[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] integral of the fuction for each value

2018-10-21 Thread malika yassa via R-help
hello
please you help me i have this functionx<-rnorm(10,0,1)f<-fuction(u,x)  
{exp((x-u)}I want to calculate the integral of this function for each value of 
x{for(i in 1:lenght(x)integrate(f,lower=1,upper=4) 
thinks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2018-10-20 Thread malika yassa via R-help
hello
please you help mei have this functionx<-rnorm(10,0,1)f<-fuction(u,x)  
{exp((x-u)}I want to calculate the integral of this function for each value of 
x{for(i in 1:lenght(x)
integrate(f,lower=1,upper=4) 

}but I can not find the vector of resulatwhere is the errorthinks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2018-10-20 Thread malika yassa via R-help
hellowplease,do you help mei have this matrixm<-matrix(( 1:12, nrow = 3 )

I want to delete the diagonal values of this matrix
can anyone do thisthinks 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2018-08-06 Thread malika yassa via R-help
hellothis is my programmeyou can help me, i cann't found a solution for H  and 
this  function i calculate for all value for x1thank you 


x<-rexp(N,2)

z<-rnorm(0,1,n)

g=k)-k*(Z-m<=-k)}

k1<-function(u,x1){-1/(2*pi)exp((x1-u)/h1}

for (i in 1:n)

{k1(u,x1)=integrate(-1/(2*pi)exp((x1-u)/h1,lower=s[i-1],upper=s[i])}

 

 

H<-function(u,x1)

for (i in 1:n)

{H(u,x1)=sum(g[i]*fkS*integrate(k1,lower=s[i-1],upper=s[i])

}


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2018-05-14 Thread malika yassa via R-help
hello
> p(X ≤ V) diffetente zero
> look this
> Let X and V be two independent random variables with unknow
>  distribution functions (d.f.’s) F and G respectively. Under truncation from 
>the right we observe (X, Z) only if X ≤ Z
> I simulate X and Z and I use Lynden bell estimation
> I need now to calculate alpha =p(X ≤ V)but no p(X ≤ V)=0
>  

> > 
> > 
> > 
> > for exampl, i have this programme
> > # Generating data which are right truncated
> > library(DTDA)
> > library(splines)
> > library(survival)
> > n<-25
> > X<-runif(n,0,1)
> > V<-runif(n,0.75,1)
> > for (i in 1:n){
> > while (X[i]>V[i]){
> > X[i]<-runif(1,0,1)
> > V[i]<-runif(1,0.75,1)
> > }}
> > res<-lynden(X=X,U=NA, V=V, boot=TRUE)
> > attach(res)
> > temps = time
> > M_i = n.event
> > L_t = res
> > F_t=1-L_t                                    
> > par(mfrow=c(1,1))
> > plot(L_t$time,L_t$survival,type="s",lty=2:3,lwd=2,las=1,cex.lab=1.1,font.lab=2,col="red",xlab="temps",ylab="L(t)",
> 
> > main="Esitmation de la Fonction de Survie L(t)")

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] (no subject)

2018-05-12 Thread malika yassa via R-help
 
hello
for exampl, i have this programme
# Generating data which are right truncated
library(DTDA)
library(splines)
library(survival)
n<-25
X<-runif(n,0,1)
V<-runif(n,0.75,1)
for (i in 1:n){
while (X[i]>V[i]){
X[i]<-runif(1,0,1)
V[i]<-runif(1,0.75,1)
}}
res<-lynden(X=X,U=NA, V=V, boot=TRUE)
attach(res)
temps = time
M_i = n.event
L_t = res
F_t=1-L_t     
par(mfrow=c(1,1))
plot(L_t$time,L_t$survival,type="s",lty=2:3,lwd=2,las=1,cex.lab=1.1,font.lab=2,col="red",xlab="temps",ylab="L(t)",main="Esitmation
 de la Fonction de Survie L(t)")


i need to calculate the probability p(X>V)
Le jeudi 10 mai 2018 à 17:15:06 UTC+2, John Kane <jrkrid...@yahoo.ca> a 
écrit :  
 
 We need some idea of the problem.

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example


http://adv-r.had.co.nz/Reproducibility.html

 

On Thursday, May 10, 2018, 11:07:30 a.m. EDT, malika yassa via R-help 
<r-help@r-project.org> wrote:  
 
 
Hello 

Do You help me, i have the problem in the package DTDA for  find the 
probability of truncation  (alpha)
thank you

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2018-05-10 Thread malika yassa via R-help

Hello 

Do You help me, i have the problem in the package DTDA for  find the 
probability of truncation  (alpha)
thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.