[R] Bug in myintegrate in Elliptic package
Hello, I was using my integrate today and spend a couple of hours trying to figure out why I was getting some weird results in my code when using myintegrate function to do complex integration, after some time decided just to change the name of the integration dummy variable in the code from 'x' to 'y' and the code worked perfectly, here is the outpus of what I was using: #Find the CDF to find the call prices CDF_Merton = function(y,psi_measure){ + integrand_cdf = function(u_vec,y,psi_measure) Im(exp(-1i*u_vec*y)*psi_measure(u_vec))/u_vec + return(1/2 - 1/pi*Re(myintegrate(integrand_cdf,0,100,y=y,psi_measure=psi_measure))) + } CDF_Merton(y=0.1,psi_measure=psi) [1] 0.9368239 CDF_Merton = function(x,psi_measure){ + integrand_cdf = function(u_vec,x,psi_measure) Im(exp(-1i*u_vec*x)*psi_measure(u_vec))/u_vec + return(1/2 - 1/pi*Re(myintegrate(integrand_cdf,0,100,x=x,psi_measure=psi_measure))) + } CDF_Merton(x=0.1,psi_measure=psi) [1] 59.03344 where you can see that both codes are exactly the same except for the dummy variable used to integrate, does any body know what might be going on here? Thanks Felipe Parra -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] Problem with convergence in optim
Hello to all, I have been using an optim with the following call: optim(param_ini,fun_errores2,Precio_mercado=Precio,anos_pagosE2=anos_pagos,control=list(maxit=1,reltol=1e-16)) depending on the intial values I'm getting the same solution but once I get the convergence message=10 (no convergence) and for the others I get convergence message = 0 Solution1: $par beta1 beta2 beta3 lambda beta1 0.06537061 0.001474821 -0.07592360.5 $e2 [1] 74.84273 $conv [1] 0 $v [1] 74.84273 Solution2: $par beta1 beta2 beta3 lambda 1 0.06537061 0.001474822 -0.07592360.5 $e2 [1] 74.84273 $conv [1] 10 $v [1] 74.84273 My intuition tells me the correct solution is no convergence. Does anybody know why this might be happening. Thank you Felipe Parra [[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] Problem with convergence in optim
Thanks Rui, i already tried changin the reltol, but it didn't change the outcome On Wed, May 15, 2013 at 1:32 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, It's impossible to tell what is happening without the function and the values for the other variables (including the initial parameters) but your setting of reltol is too small. Try using the default. It's sqrt(.Machine$double.eps), about 1e-8, you are using 1e-16. Hope this helps, Rui Barradas Em 15-05-2013 17:02, Luis Felipe Parra escreveu: Hello to all, I have been using an optim with the following call: optim(param_ini,fun_errores2,**Precio_mercado=Precio,anos_** pagosE2=anos_pagos,control=**list(maxit=1,reltol=1e-16)**) depending on the intial values I'm getting the same solution but once I get the convergence message=10 (no convergence) and for the others I get convergence message = 0 Solution1: $par beta1 beta2 beta3 lambda beta1 0.06537061 0.001474821 -0.07592360.5 $e2 [1] 74.84273 $conv [1] 0 $v [1] 74.84273 Solution2: $par beta1 beta2 beta3 lambda 1 0.06537061 0.001474822 -0.07592360.5 $e2 [1] 74.84273 $conv [1] 10 $v [1] 74.84273 My intuition tells me the correct solution is no convergence. Does anybody know why this might be happening. Thank you Felipe Parra [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] splines package
Hello all, I have been working with b-splines and noted that the splines package is not available in CRAN. Does any body know what happened with it? Or, is there any package that replaces it? Thank you Felipe Parra [[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] Difference in function arima estimation between 2.11.1 and R 2.12.2
Hello , I have estimated the following model, a sarima: p=9 d=1 q=2 P=0 D=1 Q=1 S=12 In R 2.12.2 Call: arima(x = xdata, order = c(p, d, q), seasonal = list(order = c(P, D, Q), period = S), optim.control = list(reltol = tol)) Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 0.3152 0.8762 -0.4413 0.0152 0.1500 0.0001 -0.0413 -0.1811 0.0646 s.e. 0.0865 0.0885 0.1141 0.1181 0.1196 0.1220 0.1120 0.0908 0.0865 ma1 ma2 sma1 -0.0221 -0.9779 -0.7635 s.e. 0.0539 0.0534 0.0834 sigma^2 estimated as 1.965e+17: log likelihood = -3316.07, aic = 6658.13 and in In R 2.11.1 Call: arima(x = xdata, order = c(p, d, q), seasonal = list(order = c(P, D, Q), period = S), optim.control = list(reltol = tol)) Coefficients: ar1 ar2 ar3 ar4 ar5ar6 ar7 ar8 ar9 0.3152 0.8761 -0.4413 0.0153 0.1500 0.000 -0.0413 -0.1810 0.0646 s.e. 0.0865 0.0885 0.1141 0.1181 0.1196 0.122 0.1120 0.0908 0.0865 ma1 ma2 sma1 -0.0221 -0.9779 -0.7635 s.e. 0.0539 0.0534 0.0834 sigma^2 estimated as 1.965e+17: log likelihood = -3316.07, aic = 6658.13 and as you can see in the results some coefficients (for example ar2 and ar8) are different in the different R versions. does anybody know what might be going on. Was there any change in the arima function between the two versions? Thank you Felipe Parra [[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] Different results with arima in R 2.12.2 and R 2.11.1
Hello , I have estimated the following model, a sarima: p=9 d=1 q=2 P=0 D=1 Q=1 S=12 In R 2.12.2 Call: arima(x = xdata, order = c(p, d, q), seasonal = list(order = c(P, D, Q), period = S), optim.control = list(reltol = tol)) Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 0.3152 0.8762 -0.4413 0.0152 0.1500 0.0001 -0.0413 -0.1811 0.0646 s.e. 0.0865 0.0885 0.1141 0.1181 0.1196 0.1220 0.1120 0.0908 0.0865 ma1 ma2 sma1 -0.0221 -0.9779 -0.7635 s.e. 0.0539 0.0534 0.0834 sigma^2 estimated as 1.965e+17: log likelihood = -3316.07, aic = 6658.13 and in In R 2.11.1 Call: arima(x = xdata, order = c(p, d, q), seasonal = list(order = c(P, D, Q), period = S), optim.control = list(reltol = tol)) Coefficients: ar1 ar2 ar3 ar4 ar5ar6 ar7 ar8 ar9 0.3152 0.8761 -0.4413 0.0153 0.1500 0.000 -0.0413 -0.1810 0.0646 s.e. 0.0865 0.0885 0.1141 0.1181 0.1196 0.122 0.1120 0.0908 0.0865 ma1 ma2 sma1 -0.0221 -0.9779 -0.7635 s.e. 0.0539 0.0534 0.0834 sigma^2 estimated as 1.965e+17: log likelihood = -3316.07, aic = 6658.13 and as you can see in the results some coefficients (for example ar2 and ar8) are different in the different R versions. does anybody know what might be going on. Was there any change in the arima function between the two versions? Thank you Felipe Parra -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] Problems installing SJava
Uggs, as I understand rJava is for calling Java from within R and what I need is to call R within Java. Am I wrong? 2011/8/17 Uwe Ligges lig...@statistik.tu-dortmund.de Are you sure rJava is not fine for you? Uwe Ligges On 16.08.2011 17:16, Luis Felipe Parra wrote: Hello, I am trying to install SJava but I haven't been able to complete it successfully. I have tried to install it from bioconductor using the followin code and got the following output: source(http://www.**bioconductor.org/biocLite.Rhttp://www.bioconductor.org/biocLite.R ) BioC_mirror = http://bioconductor.org Change using chooseBioCmirror(). biocLite(SJava) Using R version 2.12.2, biocinstall version 2.7.7. Installing Bioconductor version 2.7 packages: [1] SJava Please wait... Installing package(s) into C:\Users\Hp\Documents/R/win-**library/2.12 (as lib is unspecified) Mensajes de aviso perdidos In getDependencies(pkgs, dependencies, available, lib) : package SJava is not available And I have also tried the instructions: found in http://www.omegahat.org/**RSJava/ http://www.omegahat.org/RSJava/. cd *$RHOME*/src/library unzip SJava_0.69-0.zip cd SJava ./configure.win $RHOME cd *$RHOME*/src/gnuwin32 make pkg-SJava But when I tried the line unzip SJava_0.69-0.zip it tells me the command cannot be recognized. If I unzip the file manually and then try the line ./configure.win $RHOME I get . ccannot be recognized. Does somebody know what might I be doing wrong. Or which is an easier way to install this package? My computer is on Window 7 professional (32 bits) Thank you Felipe Parra [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] Problems installing SJava
Hello, I am trying to install SJava but I haven't been able to complete it successfully. I have tried to install it from bioconductor using the followin code and got the following output: source(http://www.bioconductor.org/biocLite.R;) BioC_mirror = http://bioconductor.org Change using chooseBioCmirror(). biocLite(SJava) Using R version 2.12.2, biocinstall version 2.7.7. Installing Bioconductor version 2.7 packages: [1] SJava Please wait... Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) Mensajes de aviso perdidos In getDependencies(pkgs, dependencies, available, lib) : package SJava is not available And I have also tried the instructions: found in http://www.omegahat.org/RSJava/. cd *$RHOME*/src/library unzip SJava_0.69-0.zip cd SJava ./configure.win $RHOME cd *$RHOME*/src/gnuwin32 make pkg-SJava But when I tried the line unzip SJava_0.69-0.zip it tells me the command cannot be recognized. If I unzip the file manually and then try the line ./configure.win $RHOME I get . ccannot be recognized. Does somebody know what might I be doing wrong. Or which is an easier way to install this package? My computer is on Window 7 professional (32 bits) Thank you Felipe Parra [[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] problems with predict in fGarch
Hello I am trying to use predict from an arma-Garch model (arma(2, 2) + garch(1, 1)) and I am getting the following error: Error en arima(x = object@data, order = c(max(u, 1), 0, max(v, 1)), init = c(ar, : non-stationary AR part from CSS Does anybody know what can be the reason of this error? The model I have estimated is the following: Title: GARCH Modelling Call: garchFit(formula = fmla, data = X[, i], trace = F) Mean and Variance Equation: data ~ arma(2, 2) + garch(1, 1) environment: 060ec530 [data = X[, i]] Conditional Distribution: norm Coefficient(s): mu ar1 ar2 ma1 ma2omega alpha1beta1 -0.00079014 0.44934211 0.64374977 -0.46541382 -0.23879607 0.00028933 0.52056245 0.0001 Std. Errors: based on Hessian Error Analysis: Estimate Std. Error t value Pr(|t|) mu -7.901e-04 5.649e-04 -1.399 0.16187 ar1 4.493e-01 1.498e-013.000 0.00270 ** ar2 6.437e-01 1.453e-014.429 9.46e-06 *** ma1-4.654e-01 1.494e-01 -3.115 0.00184 ** ma2-2.388e-01 1.318e-01 -1.812 0.07006 . omega 2.893e-04 3.899e-057.420 1.17e-13 *** alpha1 5.206e-01 NA NA NA beta1 1.000e-08 NA NA NA --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Log Likelihood: 297.5401normalized: 2.438853 Thank you Felipe Parra [[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] ARIMA simulations
Hello, I have estimated an ARIMA model and I would like to make simulations from this estimated model 1,5 and 10 steps ahead. Does anybody know how to do this? Thank You Felipe Parra [[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] Problems saving an Object called by get
Hello. I am trying to save an object which I created using assign as following: assign(paste(NombreAlgoritmo,_Portafolio,sep=),PortafolioInicial) save(get(paste(Algoritmo,_Portafolio,sep=)),file=paste(camino,\\Libreria\\Portafolio\\Port_,NombreAlgoritmo,\\,NombreAlgoritmo,_Portafolio.Rdata,sep=)) but I am getting the following error: Error in save(get(paste(NombreAlgoritmo, _Portafolio, sep = )), file = paste(camino, : object 'get(paste(NombreAlgoritmo, _Portafolio, sep = ))' not found Does anybody know how can this be done? Thank you Felipe Parra [[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] Problems saving an Object called by get
Sorry David, I understand what you mean but could you help with how it would be done more specifically. Thanks On Wed, Apr 27, 2011 at 11:27 AM, David Winsemius dwinsem...@comcast.netwrote: On Apr 26, 2011, at 7:37 PM, Luis Felipe Parra wrote: Hello. I am trying to save an object which I created using assign as following: assign(paste(NombreAlgoritmo,_Portafolio,sep=),PortafolioInicial) save(get(paste(Algoritmo,_Portafolio,sep=)),file=paste(camino,\\Libreria\\Portafolio\\Port_,NombreAlgoritmo,\\,NombreAlgoritmo,_Portafolio.Rdata,sep=)) but I am getting the following error: Error in save(get(paste(NombreAlgoritmo, _Portafolio, sep = )), file = paste(camino, : object 'get(paste(NombreAlgoritmo, _Portafolio, sep = ))' not found Does anybody know how can this be done? You need to save the names rather than the got()-ten objects. -- David Winsemius, MD West Hartford, CT [[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] Matching a vector with a matrix row
Hello Niels, I am trying to find the rows in Matrix which contain all of the elements in LHS. Thank you Felipe Parra On Fri, Apr 22, 2011 at 10:30 PM, Niels Richard Hansen niels.r.hansen+li...@math.ku.dk wrote: Joshua and Luis Neither of you is exactly solving the problem as stated, see below. Luis, could you clarify if you want rows that are _equal_ to a vector or rows with entries _contained_ in a vector? If m - matrix(c(A, B, C, B, A, A), 3, 2) LHS - c(A, B) then LHS equals the first row only, while apply(m, 1, function(x) all(x %in% LHS)) [1] TRUE TRUE FALSE finds the rows with entries contained in LHS and which(m %in% LHS) [1] 1 2 4 5 6 finds all entries in m that equals an entry in LHS. While you can turn the latter into the former, this will have some computational costs too. The R-code apply(m, 1, function(x) all(x == LHS)) [1] TRUE FALSE FALSE finds the rows that are equal to LHS. - Niels On 22/04/11 00.18, Joshua Wiley wrote: Hi Felipe, Since matrices are just a vector with dimensions, you could easily use something like this (which at least on my system, is slightly faster): results- which(Matrix %in% LHS) I'm not sure this is the fastest technique thought. It will return a vector of the positions in Matrix that match LHS. You can easily convert to row numbers if you want since all columns have the same number of rows. HTH, Josh On Thu, Apr 21, 2011 at 8:56 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello I am trying to compare a vector with a Matrix's rows.The vector has the same length as the number of columns of the matrix, and I would like to find the row numbers where the matrix's row us the same as the given vector. What I am doing at the moment is using apply as follows: apply(Matrix,1,function(x)all(x%in%LHS)) but this isn't too fast actually. I would like to know if any body knows an efficient (fast) way of doing this? The matrix contains stings (not numbers). Thank you Felipe Parra [[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. -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +1 510 502 8161 2100 Copenhagen Ø Denmark [[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] Matching a vector with a matrix row
Hello I am trying to compare a vector with a Matrix's rows.The vector has the same length as the number of columns of the matrix, and I would like to find the row numbers where the matrix's row us the same as the given vector. What I am doing at the moment is using apply as follows: apply(Matrix,1,function(x)all(x%in%LHS)) but this isn't too fast actually. I would like to know if any body knows an efficient (fast) way of doing this? The matrix contains stings (not numbers). Thank you Felipe Parra [[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] Memory allocation problem
Hello, I am runnning a program on R with a big number of simulations and I am getting the following error: Error: no se puede ubicar un vector de tamaño 443.3 Mb I don't understand why because when I check the memory status in my pc I get the following: memory.size() [1] 676.3 memory.size(T) [1] 1124.69 memory.limit() [1] 4000 which should in theory allow to have a vector of size 443.Mb. I am running it on a pc on windows, 4gb RAM and intel core i7 processor. Does anybody know what might be going on? Thank you Felipe Parra -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] predict fGarch doubt
Hello I am using the predict method in fGarch. I tried to replicate what I supposed it was doing when I estimated an ARMA(2,2)+GARCH(1,1) by doing: (temp is my ouput form garchFit) fit = temp@fit$par Nobs = length(temp@data) # Predecir media fit[mu]+sum(fit[2:(2+2-1)]*temp@data[length(temp@data):(length(temp@data )-2+1)]),0)+ sum(fit[(2+2):(2+2+o2-1)]*temp@residuals[length(temp@residuals ):(length(temp@residuals)-2+1)]),0) and I got -0.005585084 while the output from the predict method gave me -0.00752829. Does anybody know what might be going on? am I using the wrong slots in the output? Thank you Felipe Parra [[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] solveRsocp in fPortfolio
Hello I am trying to use solveRsocp to optimize a Portfolio maximizing return. I was checking the code since I would like to solve it for a short Portfolio and I found this: # C - Cone Constraints: C1 - rep(0, nAssets) # xCx C2 - eqsumW[2, -1] # sum(x) C3 - rbind(diag(nAssets), -diag(nAssets) ) # x[i]0 # d - Cone Constraints: d1 - targetRisk # xCx = risk d2 - eqsumW[2, 1]# sum(x) = 1 d3 - c(rep(0, nAssets), rep(-1, nAssets))# x[i] 0 I was wondering if the conditions C3 and d3 aren't forcing the portfolio to be always a LongOnly portfolio? I tried modifying the code to take out these conditions and got the following error: Error en .socp.phase1(f, A, b, N, control) : Phase 1 failed, alpha=0 Does anybody knkow what might be going on? Is there any problem with this solver for negative weights? Thank you Felipe Parra [[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] RmetricsTools.R
Hello I read on the Rmetrics webpage that all the development packages could be intalled using the following command source(RmetricsTools.R) install.RmetricsDev([Rmetrics package to be installed] I would like to know where I could get this RmetricsTools.R . I suppose it might be somewhere on R-Forge but I haven't been able to find it. Thank you Felipe Parra [[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] Problems reading excel file with RODBC connect
Hello, I am trying to read an Excel file using RODBC connect (its attached) using the following code: Data-odbcConnectExcel2007('acciones_col.xlsx',readOnly=T,) datos-sqlFetch(Data,'Bloomberg') odbcClose(Data) The file contains stock data downloaded from bloomberg, and it contains five variables per stock (so every five columns there is an empty column) . As the bloomberg output comes, in the first row there are the stock names (but in between each stock name there are five empty cells). The second row contains the variables names (every 5 cells there is an empty cell). From the third row onwards the actual data appears. The actual file has 473 columns but i am only getting R to read 255. I know files with to many missings can be troublesome. Is there a way to tell R how many colums to read? Or does anybody know how can I sort out this problem. Thank you Felipe Parra __ 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] Installing a Package tar.gz in windows
Brian and Duncan. Thank you for your help. What I actually am trying to install is fPortfolioSolver, and symphony is the only package I am missing in order to be able to complete the installation. Do you know by any chance what could I do about this? Thank you Felipe Parra On Tue, Mar 29, 2011 at 8:07 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On Tue, 29 Mar 2011, Duncan Murdoch wrote: On 11-03-28 6:41 PM, Luis Felipe Parra wrote: Duncan I have been trying to work out the solution you gave me but I haven't really got to sort it out. I tried first the option with install packages and got this: filename - file.choose() filename [1] C:\\Users\\Hp\\Documents\\R\\win-library\\2.12\\Rsymphony_0.1-12.tar.gz install.packages(filename, type=source, repos=NULL) Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) * installing *source* package 'Rsymphony' ... ERROR: configuration failed for package 'Rsymphony' This is the important message. It says Rsymphony can't be installed on your system, because you're missing something it needs. You might get more information if you run this on the command line, but basically you need to read the system requirements for the package and follow them. The one I see when I look at it on CRAN is: SYMPHONY for Windows (sources included for other OSes) If you don't have that, then you won't be able to install this package on Windows. And for 32-bit Windows, no one has succeeded in building SYMPHONY with the current toolchain. We did succeed with an earlier toolchain, but as SYMPHONY is a C++ API, that is incompatible. It is possible to build Rsymphony on 64-bit Windows, using the binary build of SYMPHONY at http://www.stats.ox.ac.uk/pub/Rtools/goodies/Win64No_/ (which needed source modifications). Duncan Murdoch * removing 'C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony' Mensajes de aviso perdidos 1: running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD INSTALL -l C:\Users\Hp\Documents/R/win-library/2.12 C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony_0.1-12.tar.gz' had status 1 2: In install.packages(filename, type = source, repos = NULL) : installation of package 'C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony_0.1-12.tar.gz' had non-zero exit status Then about the CMD window I also tried to use it but I cannot get it to recognize the command for me. It always tells me R it is an unrecognized command. I am new to all this about tar.gz files and running commands directly in the CMD windowf, so could you please be more specific with me. Thank you Felipe Parra On Mon, Mar 28, 2011 at 8:47 PM, Duncan Murdoch murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com wrote: On 28/03/2011 8:04 AM, Luis Felipe Parra wrote: Thanks Duncan, I already installed Rtools but I don't know well how to sort it out. I tried the command you gave me and got the following error: install.packages(fPortfolioSolver.tar.gz, type=source, repos=NULL) Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) Aviso: invalid package 'fPortfolioSolver.tar.gz' Error: ERROR: no packages specified Mensajes de aviso perdidos 1: running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD INSTALL -l C:\Users\Hp\Documents/R/win-library/2.12 fPortfolioSolver.tar.gz' had status 1 2: In install.packages(fPortfolioSolver.tar.gz, type = source, : installation of package 'fPortfolioSolver.tar.gz' had non-zero exit status Do you know what might be going on or where I can find a manual of how to use Rtools? Thank you The likely problem is that you didn't give the full path to the tar.gz file. If it is not in the working directory, that install.packages command will fail. An easy way to get the path is to use filename - file.choose() which brings up a Windows dialog; go search for the file, and its name will be saved in the filename variable. Then use install.packages(filename, type=source, repos=NULL). Duncan Murdoch Felipe Parra On Mon, Mar 28, 2011 at 7:52 PM, Duncan Murdochmurdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.comwrote: On 28/03/2011 7:30 AM, Luis Felipe Parra wrote: Hello I have downloaded the fPortfolioSolver package from R-forge but I have not been able to install it. I don't know exactly where I should place the file and which commands to give R. Could somebody please help me with this. Thank you A .tar.gz file contains the source for the package, so you need to process
[R] Problems installing fPortfolioSolver
Hello. I have been a couple of days trying to install fPortfolioSolver and have been able to do it. I am getting the following error: * installing to library 'R:/lib/R/CRAN/2.12' ERROR: dependency 'Rsymphony' is not available for package 'fPortfolioSolver' * removing 'R:/lib/R/CRAN/2.12/fPortfolioSolver' Run time: 0.55 seconds. which is the same that is in the R-Forge page under patched. I tried to install Rsymphony without succes. I actually got help form the mailing list telling me that apparently many people have tried to do this on windows and haven't been able to. Does anybody know what can I do to be able to use the package? thank you Felipe Parra [[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] Installing a Package tar.gz in windows
Hello I have downloaded the fPortfolioSolver package from R-forge but I have not been able to install it. I don't know exactly where I should place the file and which commands to give R. Could somebody please help me with this. Thank you Felipe Parra [[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] Installing a Package tar.gz in windows
Thanks Duncan, I already installed Rtools but I don't know well how to sort it out. I tried the command you gave me and got the following error: install.packages(fPortfolioSolver.tar.gz, type=source, repos=NULL) Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) Aviso: invalid package 'fPortfolioSolver.tar.gz' Error: ERROR: no packages specified Mensajes de aviso perdidos 1: running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD INSTALL -l C:\Users\Hp\Documents/R/win-library/2.12 fPortfolioSolver.tar.gz' had status 1 2: In install.packages(fPortfolioSolver.tar.gz, type = source, : installation of package 'fPortfolioSolver.tar.gz' had non-zero exit status Do you know what might be going on or where I can find a manual of how to use Rtools? Thank you Felipe Parra On Mon, Mar 28, 2011 at 7:52 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 28/03/2011 7:30 AM, Luis Felipe Parra wrote: Hello I have downloaded the fPortfolioSolver package from R-forge but I have not been able to install it. I don't know exactly where I should place the file and which commands to give R. Could somebody please help me with this. Thank you A .tar.gz file contains the source for the package, so you need to process it into a binary format to install it. For simple packages you can do this in recent versions of R using install.packages(fPortfolioSolver.tar.gz, type=source, repos=NULL) but if it contains compiled code, you'll probably need to install tools first. See the R Installation and Administration Manual for full details; the tools are downloadable from http://www.murdoch-sutherland.com/Rtools. Once the tools are properly installed, the above line should work. The other way to do it is from a CMD window (not in R), running R CMD INSTALL fPortfolioSolver.tar.gz This is equivalent to the R command above, but is sometimes easier to set up, because you can easily modify your PATH variable in the CMD window. Duncan -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] Problems installing fPortfolioSolver
Hello, I am trying to install fPortfolioSolver using the following commands and I am getting the following error: filename [1] C:\\Users\\Hp\\Documents\\R\\win-library\\2.12\\fPortfolioSolver_271.75.tar.gz install.packages(filename, type=source, repos=NULL) ERROR: dependencies 'fEcofin', 'RlpSolve', 'RlpSolveAPI', 'Rsymphony', 'Ripop', 'Rdonlp2' are not available for package 'fPortfolioSolver' * removing 'C:/Users/Hp/Documents/R/win-library/2.12/fPortfolioSolver' Mensajes de aviso perdidos Does somebody know what might be going on? thank you Felipe Parra [[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] Problems installing fPortfolioSolver
Thank you. The problem is that I tryed to use the repository provided in R-forge and it didn't work. Do you know by any chance a repository where I could find this package? thank you 2011/3/28 Uwe Ligges lig...@statistik.tu-dortmund.de On 28.03.2011 15:58, Luis Felipe Parra wrote: Hello, I am trying to install fPortfolioSolver using the following commands and I am getting the following error: filename [1] C:\\Users\\Hp\\Documents\\R\\win-library\\2.12\\fPortfolioSolver_271.75.tar.gz install.packages(filename, type=source, repos=NULL) ERROR: dependencies 'fEcofin', 'RlpSolve', 'RlpSolveAPI', 'Rsymphony', 'Ripop', 'Rdonlp2' are not available for package 'fPortfolioSolver' * removing 'C:/Users/Hp/Documents/R/win-library/2.12/fPortfolioSolver' Mensajes de aviso perdidos Does somebody know what might be going on? The dependencies are missing and since you are not using a repository that provides the otehr dependencies, you will have to install them prior to the fPortfolioSolver isntallation. Probably easier to use an internet connection with a repository and ask R to install from such a complete repository. Uwe Ligges thank you Felipe Parra [[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. -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] Installing a Package tar.gz in windows
Duncan I have been trying to work out the solution you gave me but I haven't really got to sort it out. I tried first the option with install packages and got this: filename - file.choose() filename [1] C:\\Users\\Hp\\Documents\\R\\win-library\\2.12\\Rsymphony_0.1-12.tar.gz install.packages(filename, type=source, repos=NULL) Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) * installing *source* package 'Rsymphony' ... ERROR: configuration failed for package 'Rsymphony' * removing 'C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony' Mensajes de aviso perdidos 1: running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD INSTALL -l C:\Users\Hp\Documents/R/win-library/2.12 C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony_0.1-12.tar.gz' had status 1 2: In install.packages(filename, type = source, repos = NULL) : installation of package 'C:/Users/Hp/Documents/R/win-library/2.12/Rsymphony_0.1-12.tar.gz' had non-zero exit status Then about the CMD window I also tried to use it but I cannot get it to recognize the command for me. It always tells me R it is an unrecognized command. I am new to all this about tar.gz files and running commands directly in the CMD windowf, so could you please be more specific with me. Thank you Felipe Parra On Mon, Mar 28, 2011 at 8:47 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 28/03/2011 8:04 AM, Luis Felipe Parra wrote: Thanks Duncan, I already installed Rtools but I don't know well how to sort it out. I tried the command you gave me and got the following error: install.packages(fPortfolioSolver.tar.gz, type=source, repos=NULL) Installing package(s) into C:\Users\Hp\Documents/R/win-library/2.12 (as lib is unspecified) Aviso: invalid package 'fPortfolioSolver.tar.gz' Error: ERROR: no packages specified Mensajes de aviso perdidos 1: running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD INSTALL -l C:\Users\Hp\Documents/R/win-library/2.12 fPortfolioSolver.tar.gz' had status 1 2: In install.packages(fPortfolioSolver.tar.gz, type = source, : installation of package 'fPortfolioSolver.tar.gz' had non-zero exit status Do you know what might be going on or where I can find a manual of how to use Rtools? Thank you The likely problem is that you didn't give the full path to the tar.gz file. If it is not in the working directory, that install.packages command will fail. An easy way to get the path is to use filename - file.choose() which brings up a Windows dialog; go search for the file, and its name will be saved in the filename variable. Then use install.packages(filename, type=source, repos=NULL). Duncan Murdoch Felipe Parra On Mon, Mar 28, 2011 at 7:52 PM, Duncan Murdochmurdoch.dun...@gmail.com wrote: On 28/03/2011 7:30 AM, Luis Felipe Parra wrote: Hello I have downloaded the fPortfolioSolver package from R-forge but I have not been able to install it. I don't know exactly where I should place the file and which commands to give R. Could somebody please help me with this. Thank you A .tar.gz file contains the source for the package, so you need to process it into a binary format to install it. For simple packages you can do this in recent versions of R using install.packages(fPortfolioSolver.tar.gz, type=source, repos=NULL) but if it contains compiled code, you'll probably need to install tools first. See the R Installation and Administration Manual for full details; the tools are downloadable from http://www.murdoch-sutherland.com/Rtools. Once the tools are properly installed, the above line should work. The other way to do it is from a CMD window (not in R), running R CMD INSTALL fPortfolioSolver.tar.gz This is equivalent to the R command above, but is sometimes easier to set up, because you can easily modify your PATH variable in the CMD window. Duncan -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information [[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] portfolioBacktest in fPortfolio
Hello. I am trying to use the portfolio backtesting function in fPortfolio package, but I don't now why in my version of fPortfolio I don't have either the portfolioBactest nor the portfolioBacktesting functions. Does anybody knows what might be going on? thank you Felipe Parra [[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] Problems with predict in fGarch
Hello. I am using fGarch to estimate the following model: Call: garchFit(formula = fmla, data = X[, i], trace = F) Mean and Variance Equation: data ~ arma(1, 1) + garch(1, 1) Conditional Distribution: norm Coefficient(s): mu ar1 ma1 omegaalpha1 beta1 -0.94934 1.0 -0.23211 54.06402 0.45709 0.61738 Std. Errors: based on Hessian Error Analysis: Estimate Std. Error t value Pr(|t|) mu -0.949336 11.600072 -0.082 0.93477 ar1 1.000.005947 168.139 2e-16 *** ma1-0.2321110.068638 -3.382 0.00072 *** omega 54.064022 16.5787353.261 0.00111 ** alpha1 0.4570870.0931254.908 9.19e-07 *** beta1 0.6173780.044561 13.855 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 when I use predict I am getting the following error: Error en optim(init[mask], armafn, method = optim.method, hessian = TRUE, : non-finite finite-difference value [1] does anybody know what might be going on? Thank you Felipe Parra [[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] trunc function
Hello. I would like to know if there exists in R a function like trunc but where i can choose how many decimal places can I stay with in the number I have (sort of the same as the trunc function in excel). I would like, for example if I have the number 0.974678 and I choose to stay with 3 decimal places to have as ouput 0.974. Thank you Felipe Parra [[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] Problems with a function warning
Hello. I have the following funtion: fechasEntrega = function(FechasEntrega,fecha){ if(length(which(FechasEntregafecha))0){ tkmessageBox(title = Error en Fecha de Valoracion,message=Hay una fecha de entrega anterior a la fecha de valoracion. Todas las fechas de entrega deben ser posteriores a la fecha de valoración para el correcto funcionamiento del programa., icon=error, type=ok) stop(Hay una fecha de entrega anterior a la fecha de valoracion. Todas las fechas de entrega deben ser \n posteriores a la fecha de valoración para el correcto funcionamiento del programa.) } } which has two entries. The first one is a vector of dates and the second one is a date. It verifies a condition and gives a warning and an error message in the R gui if the condition is satisfied. I am having trouble because I have two run the function twice before the warning or the error message appear. I dont know why if I just run the function once none of them appear. Does any body know what can be going on? Thank you Felipe Parra [[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] Difference in numeric Dates between Excel and R
Hello. I am using some dates I read in excel in R. I know the excel origin is supposed to be 1900-1-1. But when I used as.Date with origin=1900-1-1 the dates that R reported me where two days ahead than the ones I read from Excel. I noticed that when I did in R the following: as.Date(2011-3-4)-as.Date(1900-1-1) Time difference of 40604 days but if I do the same operation in Excel the answer is 40605. Does anybody know what can be going on? Thank you Felipe Parra [[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] Transforming list into an array
Hello. I have the following object which is a list of length NumSim with each entry being a matrix of dimensions Ncurvas x 3: dW = replicate(NumSim,cbind(rnorm(Ncurvas),rnorm(Ncurvas),rnorm(Ncurvas)),simplify=F) I would like to transform it into an array of dimension Ncurvas x 3 x NumSim. Does anybody does how to do this? or how to generate directly and array composed of independent random nomrmal numbers of dimensions Ncurvas x 3 x NumSim. Thank you Felipe Parra [[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] Nested logit
Hello. Does anybody know how to estimate nested logit models in R? I know that the package mlogit does it, but It doesn´t report the logsum parameters. I would like to have the logsum parameters, and the elasticites if possible. Thank you Felipe Parra [[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] Stopping between multiple graphs
Hello. I would like to know if there is a command for stopping between multiple grpahs. I have a for in which I create a graph in each iteration. I would like R to wait for a click or an enter to pass to the next graph. Does anybody know how can this be done. Thank you Felipe Parra [[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] Problems plotting the efficient frontier with fPortfolio
Hello, I have some simulations of financial data, I have 17 variables simulated 1000 times to three horizons. I am tring to plot the efficient frontier which I already obtained using th fPortfolio package. I am using the following commands: Data=timeSeries(X[1,,]) lppSpec - portfolioSpec() longFrontier - portfolioFrontier(Data, lppSpec) plot(longFrontier) Selección: 1 Error en dimnames(x) - dn : la longitud de 'dimnames' [1] no es igual a la extensión del arreglo tailoredFrontierPlot(object = longFrontier, mText = MV Portfolio - LongOnlyConstraints,risk = Cov) Error en dimnames(x) - dn : la longitud de 'dimnames' [1] no es igual a la extensión del arreglo and getting the error that appears. I also tried to do the same with the same data changing the solver to solveRshortExact and using the Short constraints and got the same error. Does anybody know what might be going on? Thank you [[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] Defining and objective function in fPortfolio package
Hello I am using the fPortfolio package and I see there is the option in the model slot objRisk which permits the user to define its own objective function. I have the ebook Portfolio Optimization with Rmetrics and there it says examples on this option are on the advanced version of the book, which I looked on the Rmetrics webpage and apparently it doesn't exist yet. Does anybody have an example or knows where can I find an example of the usage of this option? How can I define my own objective function to optimize? Thank you Felipe Parra [[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] Defining an objective function in fPortfolio
Hello I am using the fPortfolio package and I see there is the option in the model slot objRisk which permits the user to define its own objective function. I have the ebook Portfolio Optimization with Rmetrics and there it says examples on this option are on the advanced version of the book, which I looked on the Rmetrics webpage and apparently it doesn't exist yet. Does anybody have an example or knows where can I find an example of the usage of this option. How can I define my own objective function to optimize? Thank you Felipe Parra* * [[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] Numbers in a string
Hello, I have stings which have all sort of characters (numbers, letters, punctuation marks, etc) I would like to stay only with the numbers in them, does somebody know how to do this? Thank you Felipe Parra [[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] Replacing a period in a string
Hello I have a sting of the form 12.084.547,17 which I would like R to understand as a number which has , as the decimal separator, does anybody know how to do this? thank you Felipe Parra [[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] Changing the day of the month in a date
Hello, I want to change the day of the month in a date object. What I am doing at the moment is: x=as.POSIXlt(x) x$mday=13 x=as.Date(x) Does anybody know if there is a more natural (eficient) way to do this Thank you Felipe Parra [[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] Rexcel
Hello I am new to RExcel and I would like to run a source code form the excel worksheet. I would like to run the following code source(C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r) from the excel wroksheet. Does anybody know how to do this? Thank you Felipe Parra [[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] Rexcel
Hello, I am trying to use RExcel and I would like to know if it is possible to use in excel the following function I made for R Pron = function(path=C:\\Quantil Aplicativos\\Genercauca\\V5\\){ library(timeSeries) library(maSigPro) ### CARGAR FUNCIONES source(paste(path,\\fUtilidades\\BackwardSelectionNC.r,sepfile://futilidades//BackwardSelectionNC.r%22,sep =)) source(paste(path,\\fUtilidades\\CriteriosDeComparacion.r,sepfile://futilidades//CriteriosDeComparacion.r%22,sep =)) dataTSORG-read.csv('entrada.csv', header = TRUE, sep = ,, quote=\, dec=.,fill = TRUE, comment.char=) dataTSORG = ts(dataTSORG, start=c(1950,1), frequency=12) dataTSORG = as.timeSeries(dataTSORG) X = prcomp(dataTSORG[,2:40])$x return(X) } Does somebody know if its possible? and if so how can I do it? Thank you Felipe Parra [[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] Making a line in a legend shorter
Hello, I am putting a legend with lines in a line plot and I would like to make the lines in the legend shorter. Does anybody knows how to do this? Thank you Felipe Parra [[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] portfolioConstraints
Hello, I am trying to use portfolioConstraints from the fPortfolio package and y would like to write a constraint of the form t(w)*A=z where w is the weight vector I am optimizing on, A is another vector and a is a scalar (which can take zero value). Does somebody know how to setup this constraint? thank you Felipe Parra [[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] non linear constraints for a portfolio in fPortfolio package
Hello, I would like to setup a non-linear constraint for a portfolio using the portfolioConstraint function. Does somebody now how to do this? thank you Felipe Parra [[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] mgui
Hello I am using the mgui function in the following way: mgui ( graf_cuenta_margen_interfaz,title=c(Gráficas,Histogramas valoración (No lineal) Cuenta de Margen),exec=Graficar,argText=list(fecha_adelante=Fecha adelante),closeOnExec=TRUE,output=NULL,,helps=list(fecha_adelante=paste(La valoración de cuantos días adelante se desea graficar. Las opciones son los días que se hayan escogido en las simulacion:,guiGetSafe(horizontes_text if you notice for the help I am making a string which uses a variable that I can modify helps=list(fecha_adelante=paste(La valoración de cuantos días adelante se desea graficar. Las opciones son los días que se hayan escogido en las simulacion:,guiGetSafe(horizontes_text))) The problem is when I modify this variable if I have already used this option in my program when I use it again the variable seems not be actualized even though if I call it on the R console using guiGetSafe(horizontes_text) I can see the change. If for example I change the without using this option in my program before the changes DO appear. And if I want the change in my variable to appear in the program having used the option before I have to close it and open it again. Does anybody know how can I have the changes in my variable incorporated in the program eventhough I have used the option before without opening and closing it again?. Thank you Felipe Parra [[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] Problems with mgui
Hello I am using the mgui function in the following way: mgui ( graf_cuenta_margen_interfaz,title=c(Gráficas,Histogramas valoración (No lineal) Cuenta de Margen),exec=Graficar,argText=list(fecha_adelante=Fecha adelante),closeOnExec=TRUE,output=NULL,,helps=list(fecha_adelante=paste(La valoración de cuantos días adelante se desea graficar. Las opciones son los días que se hayan escogido en las simulacion:,guiGetSafe(horizontes_text if you notice for the help I am making a string which uses a variable that I can modify helps=list(fecha_adelante=paste(La valoración de cuantos días adelante se desea graficar. Las opciones son los días que se hayan escogido en las simulacion:,guiGetSafe(horizontes_text))) The problem is when I modify this variable if I have already used this option in my program when I use it again the variable seems not be actualized even though if I call it on the R console using guiGetSafe(horizontes_text) I can see the change. If for example I change the without using this option in my program before the changes DO appear. And if I want the change in my variable to appear in the program having used the option before I have to close it and open it again. Does anybody know how can I have the changes in my variable incorporated in the program eventhough I have used the option before without opening and closing it again?. Thank you Felipe Parra [[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] Problems creating an xts object
Hello I am trying to create an xts object from a data frame that has numeric and string variables. when I create the object all my variables are converted to string, this is my original data frame: head(DatosF) FECHA CIERRE HORA DE CIERRE SESION/RUEDA PLAZO (De regreso para SIML, Repos e INTB) INSTRUMENTO TASA/ PRECIO TASA/ PRECIO EQUIV# VR# NOMINAL CONTRAVALOR 1 20090803 080943 CONH 0 TFIT06140514 103.558 8.301 5e+09 5280535000 2 20090803 080944 CONH 0 TFIT06140514 103.562 8.300 2e+09 2112294000 3 20090803 081108 CONH 0 TUVT06200313 103.948 4.050 2e+07 3957262935 4 20090803 082116 CONH 0 TFIT05241110 103.488 4.663 5e+09 5433305000 5 20090803 082116 CONH 0 TFIT05241110 103.488 4.663 5e+09 5433305000 6 20090803 082116 CONH 0 TFIT05241110 103.489 4.662 5e+09 5433355000 and this is what I am getting: head(XX) FECHA CIERRE HORA DE CIERRE SESION/RUEDA PLAZO (De regreso para SIML, Repos e INTB) INSTRUMENTO 2009-08-03 08:09:43 20090803 080943 CONH 0 TFIT06140514 103.558 8.301 2009-08-03 08:09:44 20090803 080944 CONH 0 TFIT06140514 103.562 8.300 2009-08-03 08:11:08 20090803 081108 CONH 0 TUVT06200313 103.948 4.050 2009-08-03 08:21:16 20090803 082116 CONH 0 TFIT05241110 103.488 4.663 2009-08-03 08:21:16 20090803 082116 CONH 0 TFIT05241110 103.488 4.663 2009-08-03 08:21:16 20090803 082116 CONH 0 TFIT05241110 103.489 4.662 Does anybody know what can be happening? thank you Felipe Parra [[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] boxplot
Hello, does somebody know in a boxplot, what does each element in the boxplot represent? 1. lines at the extremes of the dotted lines? 2. Extremes of the boxes 3. Black line in the middle of the box? 4. notches? Thank you Felipe Parra [[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] Problem with unlist
Hello I want to unlist the attached element getting only the first element in each element of the list. The last element of the list looks as this: [[5065]] [[5065]]$Pluv3Meses [1] 274.4 [[5065]]$PluvMesesMedio [1] 378.2667 [[5065]]$Pluv2UltimosMeses [1] 23.3 So I would like to get for each element of the list the element called Pluv3Meses. The whole list has 5065 elements but when I try to unlist it I am getting 5081 elements I don't know why: length(unlist(sapply(SumaPluvi,[,1))) [1] 5081 Does anybody know what can be happening? Thank You Felipe Parra __ 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] Problem with unlist
Henrik, thank you for your help, but I tried your code, and this is what I get x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x, FUN=length); print(table(n)); n 1 5065 print(which(n != 1)); integer(0) length(unlist(lapply(SumaPluvi, FUN=[, 1))) [1] 5081 apparently the problem is still there if I use lapply, I dont now why, but when I unlist it the number of elements changes from 5065 to 5084 if there is no list element with length greater than one. Do you know what can be happening? Thank you Felipe Parra On Mon, Sep 27, 2010 at 8:05 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x, FUN=length); print(table(n)); print(which(n != 1)); My $.02 /H On Sun, Sep 26, 2010 at 4:12 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello I want to unlist the attached element getting only the first element in each element of the list. The last element of the list looks as this: [[5065]] [[5065]]$Pluv3Meses [1] 274.4 [[5065]]$PluvMesesMedio [1] 378.2667 [[5065]]$Pluv2UltimosMeses [1] 23.3 So I would like to get for each element of the list the element called Pluv3Meses. The whole list has 5065 elements but when I try to unlist it I am getting 5081 elements I don't know why: length(unlist(sapply(SumaPluvi,[,1))) [1] 5081 Does anybody know what can be happening? Thank You Felipe Parra __ 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] Problem with unlist
Hello, I am trying to unlist a list, which is attached, and I am having the problem that when I unlist it the number of elements changes from 5065 to 5084 x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x, FUN=length); print(table(n)); n 1 5065 print(which(n != 1)); integer(0) length(unlist(lapply(SumaPluvi, FUN=[, 1))) [1] 5081 I dont now why, but when I unlist it the number of elements changes from 5065 to 5084 even if there is no list element with length greater than one. Do you know what can be happening? Thank you Felipe Parra On Mon, Sep 27, 2010 at 8:05 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x, FUN=length); print(table(n)); print(which(n != 1)); My $.02 /H On Sun, Sep 26, 2010 at 4:12 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello I want to unlist the attached element getting only the first element in each element of the list. The last element of the list looks as this: [[5065]] [[5065]]$Pluv3Meses [1] 274.4 [[5065]]$PluvMesesMedio [1] 378.2667 [[5065]]$Pluv2UltimosMeses [1] 23.3 So I would like to get for each element of the list the element called Pluv3Meses. The whole list has 5065 elements but when I try to unlist it I am getting 5081 elements I don't know why: length(unlist(sapply(SumaPluvi,[,1))) [1] 5081 Does anybody know what can be happening? Thank You Felipe Parra __ 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] Problems creating a Panel
Hello, I am trying to create a panel with the attached data frame. using the following code: PanelRio = DataRiopaila[which(duplicated(DataRiopaila$SEC_STE)==T),] PanelRio=plm.data(PanelRio,index=c(SEC_STE,FechaSiembra)) series Pluv3Meses,PluvMes4al10,Pluv2UltimosMeses,Rad3Meses,RadMes4al10,Rad2UltimosMeses are NA and have been removed It tells me it removes couple of series because they are NA, and I don't understand why because if I do: PanelRio = DataRiopaila[which(duplicated(DataRiopaila$SEC_STE)==T),] length(which(is.na(PanelRio[,Pluv3Meses])==T)) [1] 474 nrow(PanelRio) [1] 4129 which means there are still around 3500 entries which aren't NA. Does anybody what can be going on? Thank you Felipe Parra __ 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] 3d graph surface
Hello I have and 11 by 2 by 1200 matrix from which I would like to make a surface graph. the first element of the first column represents the date, which means I've got 1200 dates. I would like to graph the 11 elements of the second column for each date. Does anybody know how can I do this? attached I'm sending the matrix, its called MCurvaCOP, thank you Felipe Parra __ 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] Managing list elements
Hello, I have two lists with the same number of elements tail(LHS) [[1]] [1] antecedentes.factor_riesgo=17 antecedentes.estado=1 antecedentes.medio=4 tarjetas_flagrancia.adquiriente2= [[2]] [1] antecedentes.riesgo=1 antecedentes.estado=1 antecedentes.medio=4 tarjetas_flagrancia.adquiriente2= [[3]] [1] resultado_investig.pto_comp=N antecedentes.riesgo=1 antecedentes.factor_riesgo=17 antecedentes.medio=4 [[4]] [1] resultado_investig.pto_comp=N antecedentes.riesgo=1 antecedentes.factor_riesgo=17 tarjetas_flagrancia.adquiriente2= [[5]] [1] resultado_investig.pto_comp=N antecedentes.factor_riesgo=17 antecedentes.medio=4 tarjetas_flagrancia.adquiriente2= [[6]] [1] resultado_investig.pto_comp=N antecedentes.riesgo=1 antecedentes.medio=4 tarjetas_flagrancia.adquiriente2= tail(RHS) [[1]] [1] antecedentes.riesgo=1 [[2]] [1] antecedentes.factor_riesgo=17 [[3]] [1] tarjetas_flagrancia.adquiriente2= [[4]] [1] antecedentes.medio=4 [[5]] [1] antecedentes.riesgo=1 [[6]] [1] antecedentes.factor_riesgo=17 I would like to create a new list from this two which would have in every list entry one entry with the corresponding elements from LHS and another entry with the corresponding element from RHS (LHS doesn't always have three 4 elements per entry). Do you know how can I do this? Thank you Felipe Parra [[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] rules-class
Hellos I have a rules-class element which I got from the apriori function in the arules package, no I would like to stay just with a subset of the rules. Does anybody know how can I create an object which has only the subset corresponding from some indices I give him. For example if I have the followint rules-class object: lhs rhs support confidence lift 1 {} = {tarjetas_flagrancia.adquiriente2=} 0.9960369 0.9960369 1.000 2 {datafono.marca5=} = {tarjetas_flagrancia.adquiriente2=} 0.8049805 0.9984959 1.0024688 3 {Target=1} = {resultado_investig.pto_comp=N} 0.8134982 0.9991282 1.0427348 4 {Target=1} = {tarjetas_flagrancia.adquiriente2=} 0.8106589 0.9956411 0.9996026 5 {antecedentes.estado=1} = {antecedentes.medio=4} 0.8420383 1.000 1.1392183 6 {antecedentes.estado=1} = {tarjetas_flagrancia.adquiriente2=} 0.8382231 0.9954691 0.9994299 7 {antecedentes.factor_riesgo=17} = {antecedentes.riesgo=1} 0.8507926 1.000 1.1750886 8 {antecedentes.riesgo=1} = {antecedentes.factor_riesgo=17} 0.8507926 0.9997567 1.1750886 I would like my result to be the following rule-class object if I choose to stay with the third and eigth rules lhs rhs support confidence lift 3 {Target=1} = {resultado_investig.pto_comp=N} 0.8134982 0.9991282 1.0427348 8 {antecedentes.riesgo=1} = {antecedentes.factor_riesgo=17} 0.8507926 0.9997567 1.1750886 Thank You Felipe Parra [[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] POSIXlt objects
Hello I am using POSIXlt date format and I am having the following problem, I've got two dates called FechaIni and FechaFin, one in 2008 and the other in 2009 but when I do FechaIni$year and FechaFin$year to call the year I am getting the smae year for both. FechaIni [1] 2008-11-13 UTC FechaFin [1] 2009-06-13 UTC FechaFin$year [1] 108 FechaIni$year [1] 108 does somebody know what is happening? how can I solve this if I need two compare just the years of two dates? Thank you Felipe Parra [[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] Problems with apply
Hello I am tryin to use the apply functions with two data frames I've got and I am getting the following error message Error en HistRio$SecSte : $ operator is invalid for atomic vectors I don't understand why. when I use the apply I am doing: PromP - function(HistRio,AnaQuim){ xx - c(0,0,0) if(length(which(AnaQuim$SecSte==HistRio$SecSte))0){ xx[1]-1 } if(length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FinCorte)))0){ xx[2] - 1} if( length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FechaSiembra)))0){ xx[3]-1 } if( length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FechaSiembra)))0 length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FinCorte)))0 ){ xx[4] - 2} return(xx) } zz- apply(HistRio,1,PromP,AnaQuim) and if I do exactly the same with a for xx - matrix(0,nrow(HistRio),4) for(i in 1:nrow(HistRio)){ if(length(which(AnaQuim$SecSte==HistRio$SecSte[i]))0){ xx[1]-1 } if(length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FinCorte[i])))0){ xx[2] - 1} if( length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FechaSiembra[i])))0){ xx[3]-1 } if( length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FechaSiembra[i])))0 length(which(as.Date(AnaQuim$AÑO1)=as.Date(HistRio$FinCorte[i])))0 ){ xx[4] - 2} } I get no error message. Attached is the data I am using. Any idea of why this is happening? Thank you Felipe Parra __ 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] Predict VAR
Hello, I am using the predict function for VAR in r obtaining the following object for the predictions with the following command PronFac - predict(VARFactores,n.ahead=1) PronFactores$fcst $PC1 fcst lower upper CI PC1.fcst 2.284497 -0.8033048 5.3723 3.087802 $PC2 fcst lowerupper CI PC2.fcst -0.938333 -4.346927 2.470261 3.408594 $PC3 fcst lowerupper CI PC3.fcst -1.035569 -4.282719 2.211582 3.247151 $PC4 fcst lowerupper CI PC4.fcst -0.7063035 -4.027811 2.615204 3.321507 $PC5 fcst lowerupper CI PC5.fcst 0.3664593 -1.689041 2.421959 2.055500 I would like to take the fcst object from each of the list elements and assign it to a vector, do you know how can I do this in an efficient way without having to go trough all the list with a for? At the moment I am doing it the following way for(i in 1:NumFac){PronFactores[i,]-PronFac$fcst[[i]][1] } but I would like to know if there is a commmand to acces to vectors of forecasts without the confidence intervals. Does anybody know how to do this? Thank you Felipe Parra [[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] predict
Hello I am creating a linear model with the command net5 = lm( X[,1] ~ PrinComp[,1:5]) where my vector PrinComp looks like this head(PrinComp[,1:5]) PC1 PC2PC3PC4PC5 [1,] 1.8626055 -3.34190998 -0.5448889 2.8296751 0.3994096 [2,] 3.1124144 -1.68113572 1.7187314 -2.0162583 -0.2935675 [3,] 3.3538049 -0.05471002 -2.9385065 0.6921495 -2.2743761 [4,] 2.349 1.46433537 3.2600091 0.5121311 -2.2212727 [5,] 1.4467501 2.64829347 -2.4559811 -2.4745585 -2.3537081 [6,] 0.1575151 3.35242794 1.9367978 3.0293779 -1.4176263 now I am trying to use the predict command like this y=predict(net5, newdata=data.frame(PrinCompPredict)[,1:5]) where data.frame(PrinCompPredict)[,1:5] PC1 PC2 PC3 PC4 PC5 1 6.473546 7.529725 1.192588 0.1401967 10.81945 and I am getting the following error message, Mensajes de aviso perdidos 'newdata' had 1 rows but variable(s) found have 164 rows Does anybody know what can be wrong with this? thank you Felipe Parra [[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] Calling a list element
Hello, i have the following list strsplit(as.character(Elecciones$Municipios),\\.) [[1]] [1] ANTIOQUIA ABEJORRAL [[2]] [1] METAACACIAS [[3]] [1] CASANARE AGUAZUL [[4]] and I would like to make a vector of the first element of each of the list items, in this case ANTIOQUIA, META, CASANARE, etc . Do you know how can I do this? Thank you Felipe Parra [[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] maSigPro
Hello, I am using the maSigPro package to use the two.ways.stepback command, this command performs backward selection, I would like it to do it wtihout an intercept in the regression, do you know how can I do this, or how can I see the packages code or scripts in order to be able to modify it? thank you Felipe Parra [[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] step function
Hello I am using the step function in order to do backward selection for a linear model of 52 variables with the following commands: object-lm(vars[,1] ~ (vars[,2:(ncol(predictors)+1)]-1)) BackS-step(object,direction=backward) but it isn't dropping any if the variables in the model, but there are lots of not significant variables as you can see here object-lm(vars[,1] ~ (vars[,2:(ncol(predictors)+1)]-1)) summary(object) Call: lm(formula = vars[, 1] ~ (vars[, 2:(ncol(predictors) + 1)] - 1)) Residuals: Min 1Q Median 3Q Max -0.56388 -0.10762 -0.01433 0.08495 0.82477 Coefficients: Estimate Std. Error t value Pr(|t|) vars[, 2:(ncol(predictors) + 1)]SS.1 0.028772 0.025458 1.130 0.260896 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[1] -0.308076 0.096243 -3.201 0.001795 ** vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[2] 0.130134 0.101734 1.279 0.203559 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[3] 0.014345 0.106282 0.135 0.892887 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[4] -0.175958 0.107097 -1.643 0.103268 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[5] 0.016270 0.106081 0.153 0.878391 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[6] -0.089018 0.091132 -0.977 0.330834 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[7] -0.270550 0.075537 -3.582 0.000512 *** vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[8] -0.106691 0.074448 -1.433 0.154694 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[9] 0.118962 0.076886 1.547 0.124699 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[10] -0.055112 0.076225 -0.723 0.471218 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[11] -0.135113 0.076307 -1.771 0.079415 . vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[12] 0.082478 0.075130 1.098 0.274707 vars[, 2:(ncol(predictors) + 1)]Anomalia[0]0.123054 0.213980 0.575 0.566426 vars[, 2:(ncol(predictors) + 1)]Anomalia[1]0.078511 0.507544 0.155 0.877353 vars[, 2:(ncol(predictors) + 1)]Anomalia[2] -0.399726 0.581594 -0.687 0.493357 vars[, 2:(ncol(predictors) + 1)]Anomalia[3] -0.002103 0.583109 -0.004 0.997129 vars[, 2:(ncol(predictors) + 1)]Anomalia[4]0.596937 0.678115 0.880 0.380640 vars[, 2:(ncol(predictors) + 1)]Anomalia[5] -0.547555 0.710687 -0.770 0.442695 vars[, 2:(ncol(predictors) + 1)]Anomalia[6] -0.142452 0.678536 -0.210 0.834106 vars[, 2:(ncol(predictors) + 1)]Anomalia[7]0.506431 0.692960 0.731 0.466455 vars[, 2:(ncol(predictors) + 1)]Anomalia[8] -0.117177 0.662596 -0.177 0.859958 vars[, 2:(ncol(predictors) + 1)]Anomalia[9] -0.550570 0.563421 -0.977 0.330638 vars[, 2:(ncol(predictors) + 1)]Anomalia[10] 0.799499 0.555007 1.441 0.152587 vars[, 2:(ncol(predictors) + 1)]Anomalia[11] -0.577416 0.504046 -1.146 0.254485 vars[, 2:(ncol(predictors) + 1)]Anomalia[12] 0.204479 0.221030 0.925 0.356948 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[0] -0.572351 1.303885 -0.439 0.661561 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[1]0.270387 1.715912 0.158 0.875082 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[2]1.939207 1.806931 1.073 0.285549 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[3]1.501964 1.779253 0.844 0.400432 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[4]1.292790 1.759802 0.735 0.464147 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[5]1.197978 1.760600 0.680 0.497670 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[6]0.338068 1.720709 0.196 0.844608 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[7] -2.197186 1.616212 -1.359 0.176805 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[8] -2.050263 1.542936 -1.329 0.186687 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[9] -0.103823 1.541956 -0.067 0.946441 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[10] 0.349220 1.545823 0.226 0.821693 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[11] -0.654607 1.476141 -0.443 0.658313 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[12] -0.254144 1.193506 -0.213 0.831772 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[0] -1.500119 0.428395 -3.502 0.000671 *** vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[1] -1.058775 0.475011 -2.229 0.027869 * vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[2] 0.818735 0.497920 1.644 0.102994 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[3] 0.057331 0.528216 0.109 0.913769 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[4] -0.529271 0.519284 -1.019 0.310350 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[5] -0.649193 0.508210 -1.277 0.204171 vars[, 2:(ncol(predictors) +
[R] Out of sample forecast
Hello I am trying to use predict, but I am having trouble getting out of sample predictions. I am getting the same output if I use the following three commands: predict(ModeloLineal,predictors[721:768,]) predict(ModeloLineal,predictors[1:768,]) predict(ModeloLineal) where ModeloLineal is the output from ModeloLineal-lm(dataTS[,6] ~ predictors[1:720,]), so the first 720 observations of predictors i would like to use them to build my model and the other 48 I would like to use them to have an out of sample forecast. When I give the three commands I am always getting 161 predictions backwards, not forward as I expect. Do you know how can I do this? Thank you Felipe Parra [[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] predict.lm
Hello I am trying to use predict.lm, but I am having trouble getting out of sample predictions. I am getting the same output if I use the following three commands: predict(ModeloLineal,predictors[721:768,]) predict(ModeloLineal,predictors[1:768,]) predict(ModeloLineal) where ModeloLineal is the output from ModeloLineal-lm(dataTS[,6] ~ predictors[1:720,]), so the first 720 observations of predictors i would like to use them to build my model and the other 48 I would like to use them to have an out of sample forecast, Do you know how can I do this? Thank you Felipe Parra [[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] LDL matrix factorization
Hello, I would like to do Block LDL' factorization for Hermitian indefinite matrices, where D is a block diagonal matrix and L a psychologically lower triangular matrix (i.e a product of unit lower triangular and permutation matrices) in L such that A = L*D*L'. The block diagonal matrix D has 1-by-1 and 2-by-2 blocks on its diagonal. Does anybody know how to do this in R? Thank you Felipe Parra [[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] Creating a timeSeries Object
Hello I have 2000 univariate timeSeries of about 20 observations each, as the following, I would like to store all of them in one object, sort of a data frame or something similar. Do you know how can I do this. Thank you Felipe Parra GMT 2009-10-12 2009-10-12 0.002346171 2009-10-14 0.002346171 2009-10-21 0.002346171 2009-10-28 0.002650307 2009-11-16 0.002391950 2009-11-16 0.003848032 2010-03-16 0.003848032 2010-06-17 0.008644137 2010-09-16 0.010690464 2010-12-15 0.016356718 2011-03-15 0.018496109 2011-06-16 0.023354671 2011-09-15 0.025211351 2011-12-21 0.029029900 2012-03-21 0.031173566 2012-06-21 0.033641977 2012-10-15 0.023078052 2013-04-15 -0.118415755 2013-10-15 -0.010497527 2014-04-14 0.010497527 2014-10-14 -0.010497527 [[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] Arithmethic operations on timeSeries objects
Hello I have a time series object which I created from the following code Fechas-Datos[,1] dat-Datos[,2:ncol(Datos)] datTS-timeSeries(dat,Fechas) I am trying to do know basic arithmethic operations on it as the following datTS[3708,1]*2 Error en e1 * e2 : argumento no-numérico para operador binario datTS2[3708,1]-datTS2[3707,1] Error en datTS2[3708, 1] - datTS2[3707, 1] : positions slot do not match Which is the correct way of doing this? Thank you Felipe PArra [[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] Creating a timeSeries Data Frame
Hello I have 2000 univariate timeSeries of about 20 observations each, as the following, I would like to store all of them in one object, sort of a data frame, and to be able to recall each by its column name, which by the way is the same as the first date. Do you know how can I do this. Thank you Felipe Parra GMT 2009-10-12 2009-10-12 0.002346171 2009-10-14 0.002346171 2009-10-21 0.002346171 2009-10-28 0.002650307 2009-11-16 0.002391950 2009-11-16 0.003848032 2010-03-16 0.003848032 2010-06-17 0.008644137 2010-09-16 0.010690464 2010-12-15 0.016356718 2011-03-15 0.018496109 2011-06-16 0.023354671 2011-09-15 0.025211351 2011-12-21 0.029029900 2012-03-21 0.031173566 2012-06-21 0.033641977 2012-10-15 0.023078052 2013-04-15 -0.118415755 2013-10-15 -0.010497527 2014-04-14 0.010497527 2014-10-14 -0.010497527 [[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] Binding a matrix to a matrix
Hello I have a 2x10x200 matrix and I would like to bind to it another 2x10 matrix in order to end up with an 2x10x2001 matrix, which command should i use in order to do this? Thank you Felipe Parra [[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] Importing Headers from excel files
Hello I am trying to import an Excel file but I am loosing the headers, My headers are in the first to rows of the EXCEL file. In the following R output, the NA are supposed to be the second item in the Header. Is there any way to Import more than one row as headers?. Thank you Felipe Parra Data-odbcConnectExcel('Curva LIBOR.xlsx',readOnly=T,) AbioRep-sqlFetch(Data,'LIBOR-SWAP') head(AbioRep) Date US0001W Index US0002W Index US0001M Index US0002M Index US0003M Index US0004M Index US0005M Index US0006M Index US0007M Index US0008M Index 1 2005-01-04 2.32938 2.335632.4000 2.49000 2.572.64002.71002.7900 2.85000 2.91000 2 2005-01-05 2.32875 2.338752.4000 2.50625 2.592.66252.74252.8275 2.89063 2.95125 3 2005-01-06 2.33000 2.341252.4200 2.52000 2.612.68002.76002.8400 2.90813 2.97000 4 2005-01-07 2.32875 2.340002.4300 2.52000 2.612.68002.76002.8350 2.89625 2.95125 5 2005-01-10 2.32875 2.340632.4400 2.53000 2.622.69002.77002.8500 2.91125 2.97000 6 2005-01-11 2.33000 2.340002.4425 2.53013 2.632.70002.78002.8600 2.92750 2.98625 US0009M Index US0010M Index US0011M Index US0012M IndexF16 USSA1 Curncy USSA2 Curncy USSA3 Curncy 12.9675 3.01750 3.06375 3.11000 NA NA NA NA 23.0150 3.07375 3.13000 3.18063 2005-01-03 3.4345 3.43453.660 33.0300 3.08875 3.14000 3.19000 2005-01-04 3.5355 3.53553.757 43.0100 3.06000 3.11000 3.16000 2005-01-05 3.5395 3.53953.761 53.0300 3.08938 3.14000 3.19125 2005-01-06 3.5050 3.50503.725 63.0500 3.10625 3.15625 3.21000 2005-01-07 3.5450 3.54503.760 [[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] Excel Data Import using RODBC
Hello I am importing data from Excel to R using RODBC and I am ending up with the following data frame: names(AbioRep) [1] Date US0001W Index US0002W Index US0001M Index US0002M Index US0003M Index US0004M Index US0005M Index US0006M Index [10] US0007M Index US0008M Index US0009M Index US0010M Index US0011M Index US0012M Index F16 USSA1 Curncy USSA2 Curncy [19] USSA3 Curncy but when I try to call one of its components for example: AbioRep$US001 Index Error: inesperado símbolo en AbioRep$US001 Index I am getting an error because of the space in the name of the data frame component. I have tried to replace the space with . or _ and none have work. How do I call the components of the data frame which have spaces in there names? Thank you Felipe Parra [[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.