[R] Skew Normal CDF using psn (package sn)
Dear R-users, I have been using the code below in order to verify how the CDF of a skew-normal distribution was calculated: library(sn) s=seq(-30,30,by=0.1) a-matrix(nrow=length(s),ncol=5) lambda=1 for(i in 1:length(s)){ a[i,1]=pnorm(s[i],mean=0,sd=1); a[i,2]=T.Owen(s[i],lambda); a[i,3]=a[i,5]-2*a[i,6]; a[i,4]=pnorm(s[i])-2*T.Owen(s[i],lambda); a[i,5]=psn(s[i],shape=lambda); } From the literature I was expecting the column 3, 4 and 5 to give me the exact same results but it actually doesn't. There seem to be some approximations for small values of x. Does anyone know where does this come from? Any help would be greatly appreciated, Cheers, Boris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Skew-Normal CDF using psn
Dear R-users, I have been using the code below in order to verify how the CDF of a skew-normal distribution was calculated: library(sn) s=seq(-30,30,by=0.1) a-matrix(nrow=length(s),ncol=5) lambda=1 for(i in 1:length(s)){ a[i,1]=pnorm(s[i],mean=0,sd=1); a[i,2]=T.Owen(s[i],lambda); a[i,3]=a[i,5]-2*a[i,6]; a[i,4]=pnorm(s[i])-2*T.Owen(s[i],lambda); a[i,5]=psn(s[i],shape=lambda); } From the literature I was expecting the column 3, 4 and 5 to give me the exact same results but it actually doesn't. There seem to be some approximations for small values of x. Does anyone know where does this come from? Any help would be greatly appreciated, Cheers, Boris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Converiting longitude/latitude to utm
Dear all, I have been trying to convert coordinates from longitude/latitude to utm but I got an error. As soon as the longitude coordinate is greater than 90, I get the folloowing error message: error in pj_transform: latitude or longitude exceeded limits Here is what I did: SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat)) coordinatesUTM-spTransform(SP,CRS(+proj=utm)) Error in spTransform(SP, CRS(+proj=utm)) : error in pj_transform: latitude or longitude exceeded limits Can someone explain me what I did wrong? I am using coordinates of Australia so the range of my longitudes is around [110,150] and the one of my latitudes [-10,-45]. Thanks in advance, Cheers, Boris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Converiting longitude/latitude to utm
Thank you David Michael for your answers. It makes more sense now! Cheers, Boris 2012/6/6 David L Carlson dcarl...@tamu.edu You might try R-Sig-Geo for the reasons, but you need to include the UTM zone to convert: SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat)) SP SpatialPoints: coords.x1 coords.x2 [1,]126.59 -14.3 Coordinate Reference System (CRS) arguments: +proj=longlat +ellps=WGS84 coordinatesUTM-spTransform(SP,CRS(+proj=utm +zone=52)) coordinatesUTM SpatialPoints: coords.x1 coords.x2 [1,] 240015.6 -1582256 Coordinate Reference System (CRS) arguments: +proj=utm +zone=52 +ellps=WGS84 -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Boris Beranger Sent: Tuesday, June 05, 2012 3:29 AM To: R-help@r-project.org Subject: [R] Converiting longitude/latitude to utm Dear all, I have been trying to convert coordinates from longitude/latitude to utm but I got an error. As soon as the longitude coordinate is greater than 90, I get the folloowing error message: error in pj_transform: latitude or longitude exceeded limits Here is what I did: SP-SpatialPoints(cbind(126.59,- 14.30),proj4string=CRS(+proj=longlat)) coordinatesUTM-spTransform(SP,CRS(+proj=utm)) Error in spTransform(SP, CRS(+proj=utm)) : error in pj_transform: latitude or longitude exceeded limits Can someone explain me what I did wrong? I am using coordinates of Australia so the range of my longitudes is around [110,150] and the one of my latitudes [-10,-45]. Thanks in advance, Cheers, Boris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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 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] generate randomly a value of a vector
Hi everyone, I have a zero vector of length N and I would like to randomly allocate the value 1 to one of the values of this vector. I presume I have to use the uniform distribution but could someone tell me how I should process? Thanks in advance, Boris -- View this message in context: http://r.789695.n4.nabble.com/generate-randomly-a-value-of-a-vector-tp3798190p3798190.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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] generate randomly a value of a vector
Thank you very much Andrija, I have been do some research and was about to post the same solution. Boris -- View this message in context: http://r.789695.n4.nabble.com/generate-randomly-a-value-of-a-vector-tp3798190p3798595.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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] Weights using Survreg
Sorry when we talk about about MLE estimates does that mean WLE?I am trying to understand if the survreg function is allowing a weight for each density function when calculating the likelihood. In my second question I was trying to explain that my problem is that I have pipes of different length and I want to know their probability to break per metre. My idea was to weight each of my observations to get estimate probabilities per metre.Does that sound realistic? Thank you very much, Boris -- View this message in context: http://r.789695.n4.nabble.com/Weights-using-Survreg-tp3781803p3793462.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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] Weights using Survreg
Thank you for your reply, it has been helpful. Do you know if the parameters estimators are MLE estimators? One more question: In my case study I have failures that occured on different objects that have different age and length, could I use weight to find the estimates of a weibull law and so to find the probabilty of failure per unit of length for example? Thank you very much again for your help, Boris -- View this message in context: http://r.789695.n4.nabble.com/Weights-using-Survreg-tp3781803p3785931.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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] Weights using Survreg
Dear R users, I have been trying to understand what the Weights arguments is doing in the estimation of the parameters when using the Surreg function. I looked through the function's code but I am not sure if I got it or not. For example, if I inclue the Surv function in it: survreg(Surv(vector, status)~1,weights=vector2,dist=Weibull) will it try to maximize the likelihood with a weight on each density function f (when non-censored) and 1-distribution, 1-F (censored case)? Can anyone tell me if I'm in the right way? Thank you very much, Boris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.