[R] creat list
Hi, I have a list named lista, which has 50 vectors and each vector has the length about 1200. I would like to creat a matrix out of lista. What I try now is cbind(lista[[1]],lista[[2]],...,lista[[50]]). I guess there would be an easy way of doing this. Could anyone give me some advice? -- View this message in context: http://www.nabble.com/creat-list-tf4391162.html#a12519637 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] creat list
Many thanks. Uwe Ligges wrote: livia wrote: Hi, I have a list named lista, which has 50 vectors and each vector has the length about 1200. I would like to creat a matrix out of lista. What I try now is cbind(lista[[1]],lista[[2]],...,lista[[50]]). I guess there would be an easy way of doing this. Could anyone give me some advice? matrix(unlist(lista), ncol=50) Uwe Ligges __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/creat-list-tf4391162.html#a12520728 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Histogram Title SizeFont
Hello, I would like to plot a histogram with title Return, and I would like the font for the title to be Bold and the size to be 8( as in Excel). I tried the following code, but it does not make any change. Could anyone give me some advice? hist (preturn, seq(-0.05,0.05,0.005),freq = FALSE, main=Return, font=2, cex=8,xlab=return,xlim=c(-0.05,0.05)) Many thanks. -- View this message in context: http://www.nabble.com/Histogram-Title-Size-Font-tf4347319.html#a12385630 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fit t Copula
Hi, I am trying to fit t copula to some data, and I am using the following function in the library(QRMlib). Udatac - apply(datac, 2, edf,adjust=1) tcopulac - fit.tcopula.rank(Udatac) But the error message come out Error in fit.tcopula.rank(Udatac) : Non p.s.d. covariance matrix Could anyone give me some advice? In fact, I am not sure what the adjust=1 is used for. Many thanks. -- View this message in context: http://www.nabble.com/Fit-t-Copula-tf4152818.html#a11814432 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fit t distribution
Hi all, I am trying to fit t distribution using the function tFit in the library(fBasics). I am using the code tFit(datac[[2]]) and it returns the following list. Title: Student-t Parameter Estimation Call: tFit(x = datac[[2]]) Model: Student-t Distribution Estimated Parameter(s): df 78.4428 I just wonder how can I refer to the estimated parameters. I tried tFit(datac[[2]]) $df,tFit(datac[[2]])@df, but neither of them work. Could anyone give me some advice? -- View this message in context: http://www.nabble.com/Fit-t-distribution-tf4136445.html#a11764680 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fit t distribution
It works. Many thanks Henrique Dallazuanna wrote: Hi, tFit(datac[[2]])@fit$estimate -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 24/07/07, livia [EMAIL PROTECTED] wrote: Hi all, I am trying to fit t distribution using the function tFit in the library(fBasics). I am using the code tFit(datac[[2]]) and it returns the following list. Title: Student-t Parameter Estimation Call: tFit(x = datac[[2]]) Model: Student-t Distribution Estimated Parameter(s): df 78.4428 I just wonder how can I refer to the estimated parameters. I tried tFit(datac[[2]]) $df,tFit(datac[[2]])@df, but neither of them work. Could anyone give me some advice? -- View this message in context: http://www.nabble.com/Fit-t-distribution-tf4136445.html#a11764680 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Fit-t-distribution-tf4136445.html#a11764994 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] fSeries GARCH(1,1)
Hello all, I am trying to use the garchFit function in the fSeries Package to fit a Garch(1,1) Model with t distribution. I am using the following codes. fit - garchFit(~garch(1,1),data,cond.dist=dstd) fitted(fit) I was expecting the fitted(fit) would return the fitted volatility, but the result turns out to be a series of repeated same value. I tried to change the distribution to normal, and the same thing happened. Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/fSeries-GARCH%281%2C1%29-tf4109574.html#a11686281 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Plot time series data
Hi all, I have got a list named data, and data[[1]] is the Date(dd-mm-), data[[2]] is the time series data. I would like to plot the data in the time series format with xlab be the date.I am using the function in the library(QRMlib). tfin - timeSeries(data[[2]]) plot.timeSeriesIts(tfin) How can I add some argument to make the xlab to be date accordingly? -- View this message in context: http://www.nabble.com/Plot-time-series-data-tf4088285.html#a11620372 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Time Series Data
Hi all, I have got some time series data. Data[[1]] is the data in the format 1975-12-05 1975-12-12 1975-12-19..., data[[2]] is the time series data. I would like to generate the time series format as 1975-12-05 1.5 1975-12-12 2.3etc. I am thinking about cbind(data[[1]],data[[2]]), but it results in [,1] [,2] [1,]1 1.5 [2,]2 2.3 Could anyone give me some advice? -- View this message in context: http://www.nabble.com/Time-Series-Data-tf4088688.html#a11621776 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] correlation matrix difference
Hi, I have got four correlation matrix. They are the same set of variables under different conditions. Is there a way to test whether the correlation matrix are significently different among each other? Could anyone give me some advice? -- View this message in context: http://www.nabble.com/correlation-matrix-difference-tf4073868.html#a11578046 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] matrix of scatterplots
Hi, I would like to use the function pairs() to plot a matrix of scatterplots. For each scatterplot, the data are plotted in circles, can I add some argument to change the circles into dots? Could anyone give me some advice?Many thanks -- View this message in context: http://www.nabble.com/matrix-of-scatterplots-tf4067527.html#a11558049 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] matrix of scatterplots
Thank you very much for your help. Adaikalavan Ramasamy wrote: m - matrix( rnorm(300), nc=3 ) pairs(m, pch=20) or pairs(m, pch=.) See help(par) for more details. livia wrote: Hi, I would like to use the function pairs() to plot a matrix of scatterplots. For each scatterplot, the data are plotted in circles, can I add some argument to change the circles into dots? Could anyone give me some advice?Many thanks __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/matrix-of-scatterplots-tf4067527.html#a11558687 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] ECDF, distribution of Pareto, distribution of Normal
Thank you very much for your reply. I am afraid I have no idea what is wrong with the pgpg function. The parameters are generated from pre-fitted GPD distribution. 1.544 is the location parameter, 0.4373 is the scale parameter and -0.2398 is the shape parameter. Cound you please give me some hint? Stefan Grosse-2 wrote: Original Message Subject: [R] ECDF, distribution of Pareto, distribution of Normal From: livia [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 18:35:04 GMT+0200 Hello all, I would like to plot the emperical CDF, normal CDF and pareto CDF in the same graph and I amusing the following codes. z is a vector and I just need the part when z between 1.6 and 3. plot(ecdf(z), do.points=FALSE, verticals=TRUE, xlim=c(1.6,3),ylim=c(1-sum(z1.6)/length(z), 1)) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) There is something wrong with your pgpd function, see ?pgpd for help and parameters... (I wonder how you got something plotted here...) y - seq(1.6, 3, 0.1) lines(y,pnorm(y, mean(z),sqrt(var(z))), col=blue) The emperical CDF and normal CDF look rather resonable, but the pareto CDF looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. in the right yaxs or any other mistake? At the same time, let t represents the vector whose values are larger than 1.6(the part we want). If I implement the following codes and plot the emperical CDF and pareto CDF, the pareto CDF seems fit. plot(ecdf(t), do.points=FALSE, verticals=TRUE) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) Could anyone give me some advice on this? Many thanks. __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/ECDF%2C-distribution-of-Pareto%2C-distribution-of-Normal-tf4056943.html#a11536305 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] CDF for pareto distribution
Hi, I would like to use the following codes to plot the CDF for pareto distribution. Before doing this, I have plot the emperical one. x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4477557,), col=red) Could anyone give me some advice whether the above codes are correct? Many thanks. -- View this message in context: http://www.nabble.com/CDF-for-pareto-distribution-tf4061253.html#a11538272 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] CDF for pareto distribution
Hi, thank you very much for your reply. The function pgpd() is from the package POT, and the 1.544 is the location parameter, 0.4477557 is the scale parameter and -0.50113 is the shape parameter, which can be both negtive or positive. Vincent Goulet wrote: Le 07-07-11 à 07:56, livia a écrit : Hi, I would like to use the following codes to plot the CDF for pareto distribution. Before doing this, I have plot the emperical one. x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4477557,-0.50113), col=red) Could anyone give me some advice whether the above codes are correct? Many thanks. livia, You seem to be struggling with the Pareto distribution... The above code seems correct, but you do not say where you took the pdpd() function from. This makes it harder for us to help you. In you other message (https://stat.ethz.ch/pipermail/r-help/2007-July/ 136137.html) you quote a negative scale parameter. The Pareto I know has strictly positive shape and scale parameters. Perhaps can you retry with functions ppareto() or pgenpareto() of package actuar. --- Vincent Goulet, Associate Professor École d'actuariat Université Laval, Québec [EMAIL PROTECTED] http://vgoulet.act.ulaval.ca __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/CDF-for-pareto-distribution-tf4061253.html#a11540928 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fraction ECDF
Hi all, I would like to plot part of the emperical CDF. Suppose the variable is x, I just need the part when x1,therefore, I am using the following codes. tail - x1 plot(ecdf(x[tail]), do.points=FALSE, verticals=TRUE) The x value starts from 1, but the yaxs still begins from 0, not the corresponding value when x is 1. How can I make it match? Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/Fraction-ECDF-tf4056229.html#a11522204 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fraction ECDF
Thank you very much. Duncan Murdoch-2 wrote: On 7/10/2007 10:36 AM, livia wrote: Hi all, I would like to plot part of the emperical CDF. Suppose the variable is x, I just need the part when x1,therefore, I am using the following codes. tail - x1 plot(ecdf(x[tail]), do.points=FALSE, verticals=TRUE) The x value starts from 1, but the yaxs still begins from 0, not the corresponding value when x is 1. How can I make it match? Could anyone give me some advice? Many thanks. Rather than subsetting the x, I'd just use xlim and ylim arguments to plot() to change the range. For example, plot(ecdf(x), do.points=FALSE, verticals=TRUE, xlim=c(1, max(x)), ylim=c(1-sum(x1)/length(x), 1)) Duncan Murdoch __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Fraction-ECDF-tf4056229.html#a11524206 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] ECDF, distribution of Pareto, distribution of Normal
Hello all, I would like to plot the emperical CDF, normal CDF and pareto CDF in the same graph and I amusing the following codes. z is a vector and I just need the part when z between 1.6 and 3. plot(ecdf(z), do.points=FALSE, verticals=TRUE, xlim=c(1.6,3),ylim=c(1-sum(z1.6)/length(z), 1)) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) y - seq(1.6, 3, 0.1) lines(y,pnorm(y, mean(z),sqrt(var(z))), col=blue) The emperical CDF and normal CDF look rather resonable, but the pareto CDF looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. in the right yaxs or any other mistake? At the same time, let t represents the vector whose values are larger than 1.6(the part we want). If I implement the following codes and plot the emperical CDF and pareto CDF, the pareto CDF seems fit. plot(ecdf(t), do.points=FALSE, verticals=TRUE) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) Could anyone give me some advice on this? Many thanks. -- View this message in context: http://www.nabble.com/ECDF%2C-distribution-of-Pareto%2C-distribution-of-Normal-tf4056943.html#a11524560 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop and function
Hi All, I am trying to make a loop for a function and I am using the following codes. p and var are some matrix obtained before. I would like to apply the function gpdlow for i in 1:12 and get the returnlow for i in 1:12. But when I ask for returnlow there are warnings and it turns out some strange result. for (i in 1:12){ gpdlow - function(u){ p[,i]$beta -u*p[,i][[2]] } returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) } -- View this message in context: http://www.nabble.com/Loop-and-function-tf4028854.html#a11443955 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop and function
Thanks a lot. I have corrected this. But it still does not work. Any thought? Stephen Tucker wrote: You do not have matching parentheses in this line returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) most likely there is a syntax error that halts the execution of the assignment statement? --- livia [EMAIL PROTECTED] wrote: Hi All, I am trying to make a loop for a function and I am using the following codes. p and var are some matrix obtained before. I would like to apply the function gpdlow for i in 1:12 and get the returnlow for i in 1:12. But when I ask for returnlow there are warnings and it turns out some strange result. for (i in 1:12){ gpdlow - function(u){ p[,i]$beta -u*p[,i][[2]] } returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) } -- View this message in context: http://www.nabble.com/Loop-and-function-tf4028854.html#a11443955 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11445807 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop and function
I tried str(gpdlow(var[,i][var[,i](p[,i][[2]])) and it returns num [1:49] -1.92 -1.69 -2.20 -1.65 -2.13 ... It is the number when i=1, I guess it does not loop. In fact, the number should be different when loop between i. jim holtman wrote: What does gpdlow(var[,i][var[,i](p[,i][[2]]) return? Is it a vector; if so, how long? Your declaration of returnlow- matrix(,12) str(returnlow) logi [1:12, 1] NA NA NA NA NA NA ... is a matrix of 12 rows and one column. You may be getting the error message is gpdlow is returning a vector longer than one. Do str(gpdlow(var[,i][var[,i](p[,i][[2]])) so that we can see what the data looks like. You still haven't provided a self-contained example, so we can only guess at what is happening. On 7/5/07, livia [EMAIL PROTECTED] wrote: Thanks a lot. I have corrected this. But it still does not work. Any thought? Stephen Tucker wrote: You do not have matching parentheses in this line returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) most likely there is a syntax error that halts the execution of the assignment statement? --- livia [EMAIL PROTECTED] wrote: Hi All, I am trying to make a loop for a function and I am using the following codes. p and var are some matrix obtained before. I would like to apply the function gpdlow for i in 1:12 and get the returnlow for i in 1:12. But when I ask for returnlow there are warnings and it turns out some strange result. for (i in 1:12){ gpdlow - function(u){ p[,i]$beta -u*p[,i][[2]] } returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) } -- View this message in context: http://www.nabble.com/Loop-and-function-tf4028854.html#a11443955 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11445807 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11446873 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop and function
Thanks. Yes, gpdlow is indeed return a vector longer than one. The length of the vector is different for i in 1:12, each equals to length(var[,i][var[,i](p[,i][[2]]). jim holtman wrote: What does gpdlow(var[,i][var[,i](p[,i][[2]]) return? Is it a vector; if so, how long? Your declaration of returnlow- matrix(,12) str(returnlow) logi [1:12, 1] NA NA NA NA NA NA ... is a matrix of 12 rows and one column. You may be getting the error message is gpdlow is returning a vector longer than one. Do str(gpdlow(var[,i][var[,i](p[,i][[2]])) so that we can see what the data looks like. You still haven't provided a self-contained example, so we can only guess at what is happening. On 7/5/07, livia [EMAIL PROTECTED] wrote: Thanks a lot. I have corrected this. But it still does not work. Any thought? Stephen Tucker wrote: You do not have matching parentheses in this line returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) most likely there is a syntax error that halts the execution of the assignment statement? --- livia [EMAIL PROTECTED] wrote: Hi All, I am trying to make a loop for a function and I am using the following codes. p and var are some matrix obtained before. I would like to apply the function gpdlow for i in 1:12 and get the returnlow for i in 1:12. But when I ask for returnlow there are warnings and it turns out some strange result. for (i in 1:12){ gpdlow - function(u){ p[,i]$beta -u*p[,i][[2]] } returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) } -- View this message in context: http://www.nabble.com/Loop-and-function-tf4028854.html#a11443955 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11445807 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11446408 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] sequences
Hi all, thank you very much. livia wrote: Hi, I would like to generate a series in the following form (0.8^1, 0.8^2, ..., 0.8^600) Could anyone tell me how can I achieve that? I am really new to R. -- View this message in context: http://www.nabble.com/sequences-tf4019146.html#a11428415 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop and cbind
Hi, I would like to apply the following function for i between 1 and 12, and then construct a list of the return series. for (i in 1:12){ ewma[i] - emaTA(calm[[i]]^2,0.03) standard[i]- calm[[i]]/sqrt(ewma[i]) standard - cbind(standard[i]) } But it does not work. Could anyone give me some advice how can I achieve this? Many thanks -- View this message in context: http://www.nabble.com/Loop-and-cbind-tf4024291.html#a11430500 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Exponentially Weighted Moving Average
Hi, I have got a series of data x and some parameter a, and I would like to take some Exponentially Weighted Moving Average to the data in the following fomula, and obtain the return series y y1=a^265*x[2]+a^264*x[3]+a^263*x[4]+...+a^0*x[267] y2=a^264*x[4]+a^263*x[5]+a^263*x[6]+...+a^0*x[268] y265=a^1*x[530]+a^0*x[531] y266=a^0*x[532] Could anyone give me some advice how can I achieve this? Many thanks -- View this message in context: http://www.nabble.com/Exponentially-Weighted-Moving-Average-tf4017572.html#a11409874 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] EWMA procedure to forecast variance
Hello, I would like to use the Exponential Weighted Moving Average procedure to get the variance. Is there any R function for doing this? Many thanks. -- View this message in context: http://www.nabble.com/EWMA-procedure-to-forecast-variance-tf4018317.html#a11412324 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] EWMA in fMultivar
Hello, I would like to use the function EWMA() in the fMultivar Package and I have a series of data x, which is the returns series. Basically, I would like to get the variance estimation using EWMA. I am trying something like EWMA(x, lambda) and I have a couple of questions: Should x be the returns series or price series in my case? When I get the result, there are the same numbers of data points as in the returns series. I was expecting there would be one less data points than the original data series, or are they one period lagged data? Could anyone give me some advice? Many thanks -- View this message in context: http://www.nabble.com/EWMA-in-fMultivar-tf4018921.html#a11414114 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] sequences
Hi, I would like to generate a series in the following form (0.8^1, 0.8^2, ..., 0.8^600) Could anyone tell me how can I achieve that? I am really new to R. -- View this message in context: http://www.nabble.com/sequences-tf4019146.html#a11414836 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] cbind
Hi, I have a series of return data, a and b are factors. I would like to build a matrix which contains each vector of returns. I am thinking about something as following, but I guess there should be a sensible way of doing this. returns - split(return, list(regimef, assetf)) cbind(returns[[1]], returns[[2]],...,returns[[n]]) Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/cbind-tf3999805.html#a11359949 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Optimization
It is of great help for your advice. Thanks a lot to you all. livia wrote: Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01, x1 is the quantile of normal distribution (0.0032,x) with probability of 0.7, and the changing value should be x. Initial value for x is 0.0207. I am using the following codes, but it does not work. fr - function(x) { x1-qnorm(0.7,0.0032,x) x2=0.01 x1-x2 } xsd - optim(0.0207, fr, NULL,method=BFGS) It is the first time I am trying to use optimization. Could anyone give me some advice? -- View this message in context: http://www.nabble.com/Optimization-tf3941212.html#a11196890 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Function -return value
Hi, I am trying to write a function with the following codes and I would like it to return the values for alpha beta para parab seperately. Then I would like to use this funstion for variable with factor a and b. But the result turns out to be a matrix with element like Numeric,2 ... I guess they are just the values for parab, and we can not even see the two parameters in parab. parameter - function(v) { v1 - v[vmean(v)+0.5*sd(v)] v2 - v[vmean(v)-0.5*sd(v)] alpha=min(v1) beta=max(v2) para - fitgpd(v1,alpha, method=pwmu)$param parab - fitgpd((-v2), (-beta), method=pwmu)$param v1.fit - qgpd(ppoints(v1, a=0.5), alpha, para[1], para[2]) v2.fit - qgpd(ppoints((-v2), a=0.5), (-beta), para[1], para[2]) alpha beta para parab } tapply(variable, list(a, b),parameter) I would be grateful if anyone can give me some advice. Many thanks -- View this message in context: http://www.nabble.com/Function--return-value-tf3947134.html#a11197159 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Histogram
Hello, I am using the following codes to plot a histogram and density line for x. For the density line, I just want it to show the two tails, eg, for x larger than 0.05 ans smaller than -0.05 hist (x, seq(-0.1,0.1,0.01),freq = FALSE) lines (density(x,bw=SJ), x 0.05 x (-0.05), col = red) But is does not work, can anyone give me some advice? -- View this message in context: http://www.nabble.com/Histogram-tf3947281.html#a11197644 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Optimization
Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01, x1 is the quantile of normal distribution (0.0032,x) with probability of 0.7, and the changing value should be x. Initial value for x is 0.0207. I am using the following codes, but it does not work. fr - function(x) { x1-qnorm(0.7,0.0032,x) x2=0.01 x1-x2 } xsd - optim(0.0207, fr, NULL,method=BFGS) It is the first time I am trying to use optimization. Could anyone give me some advice? -- View this message in context: http://www.nabble.com/Optimization-tf3941212.html#a11178663 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Loop for test statistic
I would like to obtain the statistic of A2 for ycf between the value 0.0032 and 0.09, and I am using the following codes. while (0.0032 ycf 0.09) { A2 - A2_GOFlaio(ycf, dist=GEV)[1] print(A2) } Could anyone give me some advice as it does not work. Many thanks. -- View this message in context: http://www.nabble.com/Loop-for-test-statistic-tf3927249.html#a11137549 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fitted Value Pareto Distribution
Thank you very much and that is exactly what I am looking for. Another question would be how can I test the goodness of fit for the Pareto distribution? J. Hosking wrote: livia wrote: I would like to fit a Pareto Distribution and I am using the following codes. I thought the fitted (fit1) should be the fitted value for the data, is it correct? As the result of the fitted turns out to be a single value for all. fit=vglm(ycf1 ~ 1, pareto1(location=alpha), trace=TRUE, crit=c) fitted(fit) The result is fitted(fit) [,1] [1,] 0.07752694 [2,] 0.07752694 [3,] 0.07752694 [4,] 0.07752694 [5,] 0.07752694 [6,] 0.07752694 [7,] 0.07752694 [8,] 0.07752694 [9,] 0.07752694 [10,] 0.07752694 [11,] 0.07752694 [12,] 0.07752694 [13,] 0.07752694 Could anybody give me some advice? I don't have whatever package function 'vglm' comes from (did you follow the instructions in the last two lines of your post?), but you can fit a GPD and get fitted values for it by some such approach as this: library(POT) threshold - 0 # probably para - fitgpd(ycf1, threshold, method=pwmu)$param ycf1.fit - qgpd( ppoints(ycf1, a=0.44), threshold, para[1], para[2]) Note that the above code contains my own preferences for fitting method and plotting positions: yours may differ. J. R. M. Hosking __ R-help@stat.math.ethz.ch 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. -- View this message in context: http://www.nabble.com/Fitted-Value-Pareto-Distribution-tf3914151.html#a9224 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Goodness of fit- Pareto distribution
Hello, I have fitted a Pareto Distribution for some data, I would appreciate if anyone can tell me how to evaluate the goodness of fit for the distribution. What I do now is rather subjective. I just compare the emprcical density distribution and the fitted density distribution. -- View this message in context: http://www.nabble.com/Goodness-of-fit--Pareto-distribution-tf3922663.html#a11123100 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fitted value
I would like to fit a Pareto Distribution and I am using the following codes. I thought the fitted (fit1) should be the fitted value for the data, is it correct? As the result of the fitted turns out to be a single value for all. fit=vglm(ycf1 ~ 1, pareto1(location=alpha), trace=TRUE, crit=c) coef(fit, matrix=TRUE) summary(fit) fitted(fit) Could anybody give me some advice? -- View this message in context: http://www.nabble.com/Fitted-value-tf3913388.html#a11095344 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Fitted Value Pareto Distribution
I would like to fit a Pareto Distribution and I am using the following codes. I thought the fitted (fit1) should be the fitted value for the data, is it correct? As the result of the fitted turns out to be a single value for all. fit=vglm(ycf1 ~ 1, pareto1(location=alpha), trace=TRUE, crit=c) fitted(fit) The result is fitted(fit) [,1] [1,] 0.07752694 [2,] 0.07752694 [3,] 0.07752694 [4,] 0.07752694 [5,] 0.07752694 [6,] 0.07752694 [7,] 0.07752694 [8,] 0.07752694 [9,] 0.07752694 [10,] 0.07752694 [11,] 0.07752694 [12,] 0.07752694 [13,] 0.07752694 Could anybody give me some advice? -- View this message in context: http://www.nabble.com/Fitted-Value-Pareto-Distribution-tf3914151.html#a11097749 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Pareto Distribution
I would like to fit a Pareto Distribution and I am using the following codes. First, I thought the fitted (fit1) should be the fitted value for the data, is it correct? As the result of the fitted turns out to be the same value. fit=vglm(ycf1 ~ 1, pareto1(location=alpha), trace=TRUE, crit=c) coef(fit, matrix=TRUE) summary(fit) fitted(fit) Secondly, how can I plot the density for the fitted distribution? Many thanks. -- View this message in context: http://www.nabble.com/Pareto-Distribution-tf3908751.html#a11082669 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] extract data from Access
Hi, I have imported an Access Database into R. There are three variables in the Access database, return, a and b. Among them a and b are factors. I would like to extract return from it, i.e return of a in level 1 and b in level 2. I would appreciate any advice. Many thanks. -- View this message in context: http://www.nabble.com/extract-data-from-Access-tf3870487.html#a10965714 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] plot histogram and print
I have got a dataset with two factors, and I would like to print the histograms of the variable return for each combination of the two factors. I do not know how can I name the figure title to sth like main=alevel blevel according to the data. par(ask=TRUE) myhistogram - function(x) { hist (x, freq = FALSE) lines (density(x), col = red) rug (x) } tapply(return, list(a, b), myhistogram) Could anyone help me with this? Many thanks. -- View this message in context: http://www.nabble.com/plot-histogram-and-print-tf3871150.html#a10967630 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] standard error of skewness
Hi, I just wonder how can I calculate the standard error of skewness? Basiclly, I would like to test whether it is too skewed or not? Many thanks -- View this message in context: http://www.nabble.com/standard-error-of-skewness-tf3872201.html#a10970956 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] tapply
Hello, I want to conduct normality test to a series of data and get the p-value for each subset. I am using the following codes, but it does not work. tapply(re, list(reg, ast), pvalue(shapiro.test)) Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/tapply-tf3851631.html#a10910748 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] tapply histogram
Dear members, I would like to pass the histogram settings to each subset of the dataframe, and generate a multiple figures graph. First, can anyone tell me how to generate a multiple figures environment? I am trying mfrow=c(2,4) and nothing appears. Secondly, I want to pass the following function in tapply() hist(x, freq=FALSE) lines(density(x), col=red) rug(x) how can I manage it? Many thanks -- View this message in context: http://www.nabble.com/tapply-histogram-tf3852186.html#a10912441 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Import data from Access
Hi, I want to import some data from Access and I am using the following codes: testdb - file.path(c/../db1) channel - odbcConnect(testdb) sqlFetch(channel,tbl,colnames = TRUE, rownames = FALSE) It comes out the error message: 1: [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 2: ODBC connection failed in: odbcDriverConnect(st, ...) Anyone can help me sort it out? Many thanks. -- View this message in context: http://www.nabble.com/Import--data-from-Access-tf3847342.html#a10896743 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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.