Re: [R] Moving average with loess
Hi Robert, If you type ?loess It pulls up the documentation. What about that function do you not like? As you said, it needs two variables, but typically the second is just your time index. Try this: n - 50 x - rep(0,n) for(i in 2:n){ x[i] - rnorm(1,x[i-1]) } loess(x ~ seq(1,n)) plot(1:n,x,type='l') lines(predict(loess(x ~ seq(1,n))),col=4,type='l') This might also help: http://research.stowers-institute.org/efg/R/Statistics/loess.htm -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Faryabi, Robert (NIH/NCI) [F] Sent: Thursday, March 08, 2012 6:43 PM To: r-help@r-project.org Subject: [R] Moving average with loess Hello All, I just have a very simple question. I recently switching from Matlab to R, so cannot figure out some of the easy tasks in the new environment. Is there any weighted local regression smoothing in R? Basically, I want to have weighted moving average. All the functions that I know of need two variables for fitting. Best, Robert __ 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-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] Panel models: Fixed effects random coefficients in plm
Hello, I am using {plm} to estimate panel models. I want to estimate a model that includes fixed effects for time and individual, but has a random individual effect for the coefficient on the independent variable. That is, I would like to estimate the model: Y_it = a_i + a_t + B_i * X_it + e_it Where i denotes individuals, t denotes time, X is my independent variable, and B (beta) is the coefficient on that random variable. I want both a coefficients to be estimated with fixed effects because I expect them to be correlated with Y, and B to be estimated using a random effect. I understand how to estimate two way fixed effects models in plm (which have the fixed effects for time and individual, as I want) and how to estimate random coefficient models (which have random effects for all coefficients, including the intercept and the beta). I want to combine these, though, and I cannot figure out how to do that. It seems like the plm package is capable, but I can't figure it out. Below is reproducible code (assuming you have plm installed) taken from the vignette available on cran. It shows the two models I know how to estimate. Any guidance on estimating the third model would be greatly appreciated. -Mitch # Data setup library(plm) data(EmplUK, package=plm) names(EmplUK) E - pdata.frame(EmplUK, index = c(firm, year), drop.index = TRUE, row.names = TRUE) # Two-way fixed effects model with constant beta m1 - plm(wage ~ output,data=E,model=within,effect=twoways) summary(m1) # Random (individual) effects for both intercept and beta m2 - pvcm(wage ~ output,data=E,model=random) summary(m2) __ 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] Find identical pairs
Hi Alex, x - sample.int(4,20,replace=TRUE) y - sample.int(4,20,replace=TRUE) cbind(x,y)[x==y,] Thanks, Mitch -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Thursday, March 08, 2012 11:18 AM To: R help Subject: [R] Find identical pairs Dear all I am having two numerical vector the x and y. I would like to find the identical x,y pairs. How I can do that in R? I would like to thank you in advance B.R Alex [[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-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 binaries from R-Forge
Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ 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 binaries from R-Forge
Hi Uwe, Thanks for your response. I tried your suggestion and got the following error message: install.packages(splm, repos=http://R-Forge.R-project.org,type=source;) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available I have downloaded the Package source (.tar.gz) at the link below, and it is not an empty file. Not sure what this problem means or what I can do about it. Thanks, Mitch -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, November 09, 2011 9:10 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Installing binaries from R-Forge The Windows binary seems not to be there. Since this is a development platform and there may be various reasons a binary does currently not exist, you could install the package from source, just add the argument type=source in your call to install.packages(). How to prepare your environment to allow to install source packages is described in the R Installation and Administration manual. Uwe Ligges On 09.11.2011 13:39, Downey, Patrick wrote: Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ 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-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 binaries from R-Forge
I'm sorry. I made a mistake. I accidentally had 2 versions of R open and got that error message from R-2.10. When I correctly enter the commands you suggest into R-2.14 I get the same as you. However, my installation is filled with errors. I assume the following means that I should install each of these packages prior to trying to install splm from source. Is that correct? Warning: dependencies 'spam', 'ibdreg', 'lmtest', 'deldir', 'coda', 'sandwich' are not available also installing the dependencies 'maptools', 'spdep', 'plm', 'bdsmatrix' trying URL 'http://R-Forge.R-project.org/src/contrib/maptools_0.8-10.tar.gz' Content type 'application/x-gzip' length 813096 bytes (794 Kb) opened URL downloaded 794 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/spdep_0.5-41.tar.gz' Content type 'application/x-gzip' length 1993974 bytes (1.9 Mb) opened URL downloaded 1.9 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/plm_1.2-7.tar.gz' Content type 'application/x-gzip' length 1084173 bytes (1.0 Mb) opened URL downloaded 1.0 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/bdsmatrix_1.1.tar.gz' Content type 'application/x-gzip' length 49623 bytes (48 Kb) opened URL downloaded 48 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/splm_0.9-05.tar.gz' Content type 'application/x-gzip' length 52479 bytes (51 Kb) opened URL downloaded 51 Kb * installing *source* package 'maptools' ... ** libs ERROR: compilation failed for package 'maptools' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/maptools' * installing *source* package 'bdsmatrix' ... ** libs ERROR: compilation failed for package 'bdsmatrix' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/bdsmatrix' ERROR: dependencies 'maptools', 'deldir', 'coda' are not available for package 'spdep' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/spdep' ERROR: dependencies 'bdsmatrix', 'sandwich' are not available for package 'plm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/plm' ERROR: dependencies 'spdep', 'plm', 'bdsmatrix', 'spam', 'ibdreg', 'lmtest' are not available for package 'splm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/splm' The downloaded packages are in 'D:\Documents and Settings\pdowney\Local Settings\Temp\RtmpioblL6\downloaded_packages' Warning messages: 1: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/maptools_0 .8-10.tar.gz' had status 1 2: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'maptools' had non-zero exit status 3: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/bdsmatrix_ 1.1.tar.gz' had status 1 4: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'bdsmatrix' had non-zero exit status 5: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/spdep_0.5- 41.tar.gz' had status 1 6: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'spdep' had non-zero exit status 7: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/plm_1.2-7. tar.gz' had status 1 8: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'plm' had non-zero exit status 9: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/splm_0.9-0 5.tar.gz' had status 1 10: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'splm' had non-zero exit status -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, November 09, 2011 9:24 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Installing binaries from R-Forge On 09.11.2011 15:15, Downey, Patrick wrote: Hi Uwe, Thanks for your response. I tried your suggestion and got the following error message: install.packages(splm, repos=http://R-Forge.R-project.org,type=source;) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available I have downloaded the Package source (.tar.gz) at the link below
[R] 'save' saved object names instead of objects
Hello, I created an array to hold the results of a series of simulations I'm running: d.eta - array(0,dim=c(3,3,200)) simulation goes here and populates the array but it's not important Then I tried to save the results using this: save(d.eta,file=D:/Simulation Results/sim 9-23-11 deta) When I later tried to reload them using this: d.eta - load(file=D:/Simulation Results/sim 9-23-11 deta) I got the following: class(d.eta) [1] character d.eta [1] d.eta Why didn't it load the original object that I tried to save (the array)? Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ 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] 'save' saved object names instead of objects
A more compact example might be helpful: g - array(0,dim=c(4,4)) g save(g,file=D:/g) h - load(file=D:/g) h -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Downey, Patrick Sent: Friday, September 23, 2011 9:32 AM To: r-help@r-project.org Subject: [R] 'save' saved object names instead of objects Hello, I created an array to hold the results of a series of simulations I'm running: d.eta - array(0,dim=c(3,3,200)) simulation goes here and populates the array but it's not important Then I tried to save the results using this: save(d.eta,file=D:/Simulation Results/sim 9-23-11 deta) When I later tried to reload them using this: d.eta - load(file=D:/Simulation Results/sim 9-23-11 deta) I got the following: class(d.eta) [1] character d.eta [1] d.eta Why didn't it load the original object that I tried to save (the array)? Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ 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-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] 'save' saved object names instead of objects
Thank you Jean Christophe and Sarah. You are both, of course, absolutely correct. -Original Message- From: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com] Sent: Friday, September 23, 2011 9:44 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] 'save' saved object names instead of objects Hi, did you try load(file=D:/Simulation Results/sim 9-23-11 deta) without the assignment ? look at ?load 2011/9/23 Downey, Patrick pdow...@urban.org: Hello, I created an array to hold the results of a series of simulations I'm running: d.eta - array(0,dim=c(3,3,200)) simulation goes here and populates the array but it's not important Then I tried to save the results using this: save(d.eta,file=D:/Simulation Results/sim 9-23-11 deta) When I later tried to reload them using this: d.eta - load(file=D:/Simulation Results/sim 9-23-11 deta) I got the following: class(d.eta) [1] character d.eta [1] d.eta Why didn't it load the original object that I tried to save (the array)? Is the problem with how I'm saving or how I'm loading? Any explanation would be greatly appreciated. And to head off this question, I did check after the simulation, before saving, and the d.eta object is an array of numbers. Thanks, Mitch __ 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-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] merge function
Hello, I'm clearly confused about the merge function. In the following r - merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thought the default behavior was only matching rows are included, but that using all.x=T included rows with unmatched x's as well. If all the y's are unique, though, I don't understand how length(r) length(x) is possible. Some clarification would be great. Thanks, Mitch [[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] merge function
I was mistaken. There were duplicates in my y vector. Please ignore my previous message. Sorry. -Original Message- From: Downey, Patrick Sent: Thu 6/30/2011 11:08 PM To: r-help@r-project.org Subject: merge function Hello, I'm clearly confused about the merge function. In the following r - merge(x,y,all.x=T,all.y=F) my y vector has only unique values (no duplicates). So I don't understand how this can ever generate an r which is of greater length than x. I thought the default behavior was only matching rows are included, but that using all.x=T included rows with unmatched x's as well. If all the y's are unique, though, I don't understand how length(r) length(x) is possible. Some clarification would be great. Thanks, Mitch [[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] Simulating SVAR Data
Hello, I'd like to simulate data according to an SVAR model in order to demonstrate how other techniques (such as arima) yield biased estimates. I am interested in a 2 variable SVAR with 2 lags (in the notation of the vars vignette, K = 2, P = 2, where B = I_K). I'm using the {vars} package outlined here: http://cran.r-project.org/web/packages/vars/vignettes/vars.pdf I thought that the following would generate the data and demonstrate the accuracy of an SVAR compared to an arima, but the results are not what I expected. I think the problem is the way that I'm generating the data, but I don't understand what I could be doing wrong. Any guidance would be greatly appreciated. Problems: In the code below, the array means should show that SVAR parameters are unbiased estiamtors, so the second column of means should be near 0, and it's not any closer than the first column (the arima results). So my results are no less biased than the arima results. The first pair of plots should show the same: SVAR results are unbiased. But they don't cluster around the red dots (true parameter values), so they aren't. Finally, the second pair of plots should show the parameters are consistent: that MSE decreases as sample size increases. They don't really show that. Perhaps they would if the smallest sample were smaller than 200, but the SVAR tends not to converge with fewer observations. Further, the MSE tends to be at least as high with the SVAR compared to arima, so it's not any more accurate. Program: # Model # # Y(t) = a0 + a1*Y(t-1) + a2*Y(t-2) + a3*X(t-1) + a4*X(t-2) + e(t) # X(t) = b0 + b1*X(t-1) + b2*X(t-2) + b3*Y(t-1) + b4*Y(t-2) + b5*Y(t) + d(t) # e(t) d(t) ~ N(0,s) # So Y has a contemporaneous impact on X # X only has an impact on future Ys # So this is the setup of a SVAR # Choosing parameters # # Currently, all parameters are just random numbers less than 1 so that # it's a stationary series # The standard deviations of the error terms are also random ~ U(0,2) a0 - runif(1,-1,1) a1 - runif(1,-0.9,0.9) a2 - runif(1,-abs(a1),abs(a1)) a3 - runif(1,-0.9,0.9) a4 - runif(1,-abs(a3),abs(a3)) s.e - runif(1,0,2) b0 - runif(1,-1,1) b1 - runif(1,-0.9,0.9) b2 - runif(1,-abs(b1),abs(b1)) b3 - runif(1,-0.9,0.9) b4 - runif(1,-abs(b3),abs(b3)) b5 - runif(1,-0.9,0.9) s.d - runif(1,0,2) ### A Formal Test: Loop # Z - 100 error - array(0,dim=c(Z,2,6)) N - runif(Z,200,1200) # Let the sample size vary so that we can check for consistency # Generating the data # # Start with 2 initial values and then create a dataset with 1200 observations X - rep(0,1202) Y - rep(0,1202) Y[1] - rnorm(1, a0 + a1*a0 + a2*a0 + a3*b0 + a4*b0, s.e) X[1] - rnorm(1, b0 + b1*b0 + b2*b0 + b3*a0 + b4*a0 + b5*Y[1], s.d) Y[2] - rnorm(1, a0 + a1*Y[1] + a2*a0 + a3*X[1] + a4*b0, s.e) X[2] - rnorm(1, b0 + b1*X[1] + b2*b0 + b3*Y[1] + b4*a0 + b5*Y[2], s.d) for(t in 3:1202){ Y[t] - rnorm(1, a0 + a1*Y[t-1] + a2*Y[t-2] + a3*X[t-1] + a4*X[t-2], s.e) X[t] - rnorm(1, b0 + b1*X[t-1] + b2*X[t-2] + b3*Y[t-1] + b4*Y[t-2] + b5*Y[t], s.d) } L1.Y - rep(NA,1202) L2.Y - rep(NA,1202) for(t in 2:1202){ L1.Y[t] - Y[t-1] L2.Y[t] - L1.Y[t-1] } for(z in 1:Z){ n - N[z] x - X[3:(n+2)] y - Y[3:(n+2)] L1.y - c(NA,L1.Y[4:(n+2)]) L2.y - c(NA,NA,L2.Y[5:(n+2)]) # Modeling x with inclusion of y # m2 - arima(x,order=c(2,0,0),xreg=cbind(L1.y,L2.y,y)) error[z,1,1] - m2$coef[3] - b0 error[z,1,2:3] - m2$coef[1:2] - c(b1,b2) error[z,1,4:6] - m2$coef[4:6] - c(b3,b4,b5) # SVAR of x and y # m3 - VAR(cbind(y,x),p=2) A - matrix(c(1,NA,0,1),ncol=2) m4 - SVAR(m3,Amat=A) error[z,2,1] - m4$var$varresult$x$coeff[5] - b0 error[z,2,2] - m4$var$varresult$x$coeff[2] - b1 error[z,2,3] - m4$var$varresult$x$coeff[4] - b2 error[z,2,4] - m4$var$varresult$x$coeff[1] - b3 error[z,2,5] - m4$var$varresult$x$coeff[3] - b4 error[z,2,6] - m4$A[2,1] - b5 } mse - error^2 means - array(0,dim=c(6,2)) for(i in 1:2){ means[,i] - apply(error[,i,],2,mean) } means par(mfrow=c(2,1)) for(i in 1:2){ plot(1+runif(Z,-0.4,0.4),error[,i,1],xlim=c(0.5,6.5), xaxt='n',ylim=c(-1,1),ylab='',xlab='',main=paste(Model ,i)) for(j in 2:6){ points(j+runif(Z,-0.4,0.4),error[,i,j]) } points(seq(1,6,1),c(b0,b1,b2,b3,b4,b5),col=2) } par(mfrow=c(1,1)) par(mfrow=c(2,1)) for(i in 1:2){ plot(N,mse[,i,1],ylim=c(0,max(mse[,i,2:6])),main=paste(Model ,i)) for(j in 2:6){ points(N,mse[,i,j],col=j) }} par(mfrow=c(1,1)) __ 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] Setting max. iterations for lmer
Hello, I hate to ask a question which is directly addressed in the documentation, but can someone please give me an example of how to change the maximum number of iterations used by lmer. I'm having a hard time understanding this: control a list of control parameters. See below for details. control a named list of control parameters for the estimation algorithm, specifying only the ones to be changed from their default values. Hence defaults to an empty list. Possible control options and their default values are: msVerbose: a logical value passed as the trace argument to nlminb (see documentation on that function). Default is getOption(verbose). maxIter: a positive integer passed as the maxIter argument to nlminb (see documentation on that function). Default is 300. maxFN: a positive integer specifying the maximum number of evaluations of the deviance function allowed during the optimization. Default is 900 Thank you in advance, Mitch __ 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] Minimum value by ID
Hello, I have a longitudinal dataset where each individual has a different number of entries. Thus, it is of the following structure: x - runif(12) id.var - factor(c(rep(D1,4),rep(D2,2),rep(D3,3),rep(D4,3))) dat - as.data.frame(x) dat$id.var - id.var dat dat x id.var 1 0.9611269 D1 2 0.6738606 D1 3 0.9724301 D1 4 0.9787778 D1 5 0.2468355 D2 6 0.7031734 D2 7 0.2458727 D3 8 0.8439799 D3 9 0.5223196 D3 10 0.6930475 D4 11 0.8887677 D4 12 0.5483756 D4 I want to create a vector with length equal to the number of unique id.var and which has the minimum value for each id.var. That is, I want a vector which holds the minimum value for each person in my dataset. The following works, but I'm sure there is something more efficient. I would assume there is a function for this, but couldn't find anything. id - levels(id.var) min - rep(0,length(id)) for(i in 1:length(id)){ min[i] - min(dat$x[dat$id.var==id[i]]) } min min [1] 0.6738606 0.2468355 0.2458727 0.5483756 Thank you in advance, Mitch __ 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] Minimum value by ID
Perfect. Thank you. -Mitch -Original Message- From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] Sent: Tuesday, May 17, 2011 9:51 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Minimum value by ID have a look at help file of function tapply(), and try this: with(dat, tapply(x, id.var, min)) I hope it helps. Best, Dimitris On 5/17/2011 3:44 PM, Downey, Patrick wrote: Hello, I have a longitudinal dataset where each individual has a different number of entries. Thus, it is of the following structure: x- runif(12) id.var- factor(c(rep(D1,4),rep(D2,2),rep(D3,3),rep(D4,3))) dat- as.data.frame(x) dat$id.var- id.var dat dat x id.var 1 0.9611269 D1 2 0.6738606 D1 3 0.9724301 D1 4 0.9787778 D1 5 0.2468355 D2 6 0.7031734 D2 7 0.2458727 D3 8 0.8439799 D3 9 0.5223196 D3 10 0.6930475 D4 11 0.8887677 D4 12 0.5483756 D4 I want to create a vector with length equal to the number of unique id.var and which has the minimum value for each id.var. That is, I want a vector which holds the minimum value for each person in my dataset. The following works, but I'm sure there is something more efficient. I would assume there is a function for this, but couldn't find anything. id- levels(id.var) min- rep(0,length(id)) for(i in 1:length(id)){ min[i]- min(dat$x[dat$id.var==id[i]]) } min min [1] 0.6738606 0.2468355 0.2458727 0.5483756 Thank you in advance, Mitch __ 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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ 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] pdf (probability distribution function) and cdf
I like the function Ecdf in the Hmisc package. For the pdf, you can also use plot(density(x)), which is in the stats package. ??Ecdf -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Tuesday, May 17, 2011 10:09 AM To: R-help@r-project.org Subject: [R] pdf (probability distribution function) and cdf Dear all, I would like for a given vector to calculate the pdf and the cdf and then plot these two graphs. Is there in R any toolkit that can help me do that fast? Regards Alex __ 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-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] pdf (probability distribution function) and cdf
?dnorm -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: Tuesday, May 17, 2011 12:50 PM To: Jonathan Daily Cc: R-help@r-project.org Subject: Re: [R] pdf (probability distribution function) and cdf I am assuming a Gaussian distribution with specific mean and standard deviation --- On Tue, 5/17/11, Jonathan Daily biomathjda...@gmail.com wrote: From: Jonathan Daily biomathjda...@gmail.com Subject: Re: [R] pdf (probability distribution function) and cdf To: Alaios ala...@yahoo.com Cc: R-help@r-project.org Date: Tuesday, May 17, 2011, 3:18 PM Do you have a reproducible example? As posed I have no idea what this vector contains. Are you assuming a specific distribution type and using these vectors to parameterize it? On Tue, May 17, 2011 at 10:08 AM, Alaios ala...@yahoo.com wrote: Dear all, I would like for a given vector to calculate the pdf and the cdf and then plot these two graphs. Is there in R any toolkit that can help me do that fast? Regards Alex __ 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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ 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-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] how to get row name using the which function
Perhaps not the most elegant. rownames(example)[which.max(example)] If you wanted to type less, you could always write a function. names.max - function(x){ return(rownames(example)[which.max(example)]) } -Mitch -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Schumacher, G. Sent: Monday, May 02, 2011 7:54 AM To: 'r-help@r-project.org' Subject: [R] how to get row name using the which function Dear All, Probably a very basic question, but can't seem to work my way around it. I want to which row has the maximum value. But what if the row names do not correspond with the row numbers. In the example below, you'll see that the max of example is row 4, but the name of row 4 is 9. How do I get R to return 9 as value, instead of 4. example - matrix(c(0,0,0,1), 4, 1, dimnames=list(c(1, 3, 5, 9), c(1))) which.max(example) [1] 4 Hope someone can help out. Gijs Schumacher, MSc PhD candidate -- Department of Political Science VU University Amsterdam Contact: Tel: +31(0)20 5986798 Fax: +31(0)20 5986820 Web: http://home.fsw.vu.nl/g.schumacher Email: g.schumac...@vu.nlmailto:g.schumac...@fsw.vu.nl Visiting address: Metropolitan Buitenveldertselaan 2 Room Z - 333 Mail: De Boelelaan 1081 1081 HV Amsterdam The Netherlands [[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-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] Finding elements in a character vector
Hello, I have two character vectors: list.a and list.b. Every element of list.a appears somewhere in list.b. Not all elements of list.b are in list.a, and some elements of list.b appear multiple times in list.a. I want to create a new vector (index) of the same length as list.a where the nth element of index is the location in list.b of the nth element of list.a. This code will work, but I have heard over and over again that using loops is inefficient in R and that there are (almost always) better ways to do things. for(i in 1:length(list.a)){ index[i] - seq(1,length(list.b))[list.b==list.a[i]] } Thank you, Mitch __ 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] Finding elements in a character vector
Perfect. Thank you. -Mitch -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Friday, April 08, 2011 8:03 PM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Finding elements in a character vector match(list.a,list.b) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 8 Apr 2011, Downey, Patrick wrote: Hello, I have two character vectors: list.a and list.b. Every element of list.a appears somewhere in list.b. Not all elements of list.b are in list.a, and some elements of list.b appear multiple times in list.a. I want to create a new vector (index) of the same length as list.a where the nth element of index is the location in list.b of the nth element of list.a. This code will work, but I have heard over and over again that using loops is inefficient in R and that there are (almost always) better ways to do things. for(i in 1:length(list.a)){ index[i] - seq(1,length(list.b))[list.b==list.a[i]] } Thank you, Mitch __ 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-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] Hierarchical Power Analysis
Hello, A colleague is trying to do a fairly complicated power analysis for a project. The project would be evaluating random assignment to one of three conditions within each of 8 sites. The dependent variable would be binary (we do not care at this point whether it would be analyzed with logit or probit). We can simulate the data in a bunch of iterations and do analyses in each iteration, but it seems like there might be an easier way. Are there any packages in R with the capability to do such power analyses? Thanks, Mitch __ 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 contents
Hello, I'm running a number of arima models using the arima function. Often, when lag length gets too high, these model don't converge and an error message appears as this: reg - arima(y,order=c(7,0,7),xreg=isr) Warning message: In arima(y, order = c(7, 0, 7), xreg = isr) : possible convergence problem: optim gave code=1 In this case, when you print the results from the arima model, the error message appears again: reg Call: arima(x = y, order = c(7, 0, 7), xreg = isr) Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ma1 ma2 -0.3356 0.0282 -0.0124 0.0604 0.1608 0.7949 0.2286 0.4461 0.0099 s.e. NaN 0.2140 0.1711 0.2545 0.1547 0.0725 NaN NaN 0.1842 ma3 ma4 ma5 ma6 ma7 intercept isr 0.0841 0.0773 -0.054 -0.7227 -0.1322 6.1433 -0.0818 s.e. 0.1911 0.2689 NaN 0.1774 NaN 5.0604 0.2110 sigma^2 estimated as 4.542: log likelihood = -651.68, aic = 1337.36 Warning message: In sqrt(diag(x$var.coef)) : NaNs produced I'm writing a loop to run several of these models and I would like to include an if statement with instructions in case there is a possible convergence problem. Is there any way to automatically detect a warning like this without visually inspecting each result? I tried warnings(arima(y,order=c(7,0,7),isr), but I don't think that will get me what I want. The contents of an arima object are below. I was hoping one of them would include error messages, but I haven't been able to find it. summary(reg) Length Class Mode coef 16-none- numeric sigma2 1-none- numeric var.coef 256-none- numeric mask 16-none- logical loglik 1-none- numeric aic 1-none- numeric arma7-none- numeric residuals 299ts numeric call4-none- call series 1-none- character code1-none- numeric n.cond 1-none- numeric model 10-none- list Thanks in advance for any help. -Mitch __ 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] Extracting a formula from Arima for structural break analysis
Hello, I fit an ARMA model to a series using the arima function. Now I wish to use the breakpoints function from the {strucchange} package to test for structural breaks. The breakpoints function requires a formula as input. The examples show how to write an AR model as a formula, but I have MA terms as well, making it somewhat more complicated. I would like to know one of the following two things: 1) Is it possible to extract a formula from an object of class Arima (produced by the arima function), and if so how? 2) How would one write a symbolic fomula to represent an ARMA model? If I'm approaching this totally wrong, please make suggestions. Thanks, Mitch __ 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] Y Axis Labels
Hello, I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is there a way to label the values on the y-axis with the translation from the scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like Never, Once per month, A few times per month, A few times per week, Everyday. Thanks, Mitch __ 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] Y Axis Labels
Thank you both. Using axis I have gotten exactly what I needed. Thanks, Mitch -Original Message- From: Thomas Levine [mailto:thomas.lev...@gmail.com] Sent: Wednesday, October 27, 2010 2:34 PM To: Sarah Goslee Cc: Downey, Patrick; r-help@r-project.org Subject: Re: [R] Y Axis Labels Oops. That was backwards plot(scale~time,axes=F) axis(2,at=0:4,labels=c(Never, Once per month, A few times per month, A few times per week,Everyday)) axis(1) Tom 2010/10/27 Thomas Levine thomas.lev...@gmail.com: More specifically time=rnorm(20)+10 scale=rep(0:4,4) plot(time~scale,axes=F) axis(1,at=0:4,labels=c(Never, Once per month, A few times per month, A few times per week,Everyday)) axis(2) Tom 2010/10/27 Sarah Goslee sarah.gos...@gmail.com: You can use axis() to draw custom axes of many sorts. The examples under ?axis demonstrate how to not draw the default axes and how to make custom ones. Sarah On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick pdow...@urban.org wrote: Hello, I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is there a way to label the values on the y-axis with the translation from the scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like Never, Once per month, A few times per month, A few times per week, Everyday. Thanks, Mitch -- Sarah Goslee http://www.functionaldiversity.org __ 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-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] Equality of Vectors
Hello, Is there a way to get a single TRUE or FALSE statement from comparing two vectors? For example, c(1,2,3) == c(1,2,3) produces TRUE TRUE TRUE where I would like it to produce only TRUE for use in an if statement. Likewise, when two vectors are not exactly identical (in all elements) I would like a single FALSE result, as opposed to c(1,2,3) == c(1,2,5) TRUE TRUE FALSE Any ideas? Thanks, Mitch __ 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] Displaying Iteration Count
Hello, I'm running a very long for loop that usually takes hours. For my own piece of mind, it would be nice if I could check periodically and see which iteration the loop is on. A line of code that told R to print the iteration number every 100 or 200 iterations would be perfect. Does anyone know something like this? I've never known how to print anything within a for loop before the loop ends. Thanks, Mitch __ 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] ecdf
Hello, I'd like to plot an empirical cumulative distribution function, except instead of the fraction of values x, I'd like the fraction of values x. I think this can be done using the ecdf function in {Hmisc}. I installed the package and loaded it. However, when following the example given in the documentation, I get an error: x - rnorm(100) ecdf(x,what='1-F') Error in ecdf(x, what = 1-F) : unused argument(s) (what = 1-F) I believe that this is because R is attempting to access the ecdf function in base R, which does not have the what option. Am I correct, and if so, how can I change that? Note: I also tried to do it myself without the {Hmisc} ecdf function, and couldn't figure out a way. x2 - 1-ecdf(x) doesn't work, and neither does x2 - rep(0,times=100) for(i in 1:100){ x2[i] - 1-ecdf(x)[i] } Both result in errors. Thanks in advance for any suggestions you can offer. -Mitch __ 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] ecdf
Hi Thierry, That worked perfectly. Thanks for the suggestion. For reference, in the documentation, it never lists {Hmisc}'s function as starting with E instead of e. I don't know who's in charge of documentation, but that should probably be corrected. Thanks again. -Mitch -Original Message- From: ONKELINX, Thierry [mailto:thierry.onkel...@inbo.be] Sent: Monday, April 19, 2010 9:08 AM To: Downey, Patrick; R help Subject: RE: [R] ecdf R is case sensitive. ecdf() is in the stats package, Ecdf() is in Hmisc. So you want Ecdf(x,what='1-F') Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Downey, Patrick Verzonden: maandag 19 april 2010 15:04 Aan: R help Onderwerp: [R] ecdf Hello, I'd like to plot an empirical cumulative distribution function, except instead of the fraction of values x, I'd like the fraction of values x. I think this can be done using the ecdf function in {Hmisc}. I installed the package and loaded it. However, when following the example given in the documentation, I get an error: x - rnorm(100) ecdf(x,what='1-F') Error in ecdf(x, what = 1-F) : unused argument(s) (what = 1-F) I believe that this is because R is attempting to access the ecdf function in base R, which does not have the what option. Am I correct, and if so, how can I change that? Note: I also tried to do it myself without the {Hmisc} ecdf function, and couldn't figure out a way. x2 - 1-ecdf(x) doesn't work, and neither does x2 - rep(0,times=100) for(i in 1:100){ x2[i] - 1-ecdf(x)[i] } Both result in errors. Thanks in advance for any suggestions you can offer. -Mitch __ 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. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] Strange results from Multivariate Normal Density
Hello, I'm using dmnorm from the package {mnormt} and getting strange results. First, according to the documentation, dmnorm should return a vector of densities, and I'm only getting one value returned (which is what I would expect). I've been interpreting this as the joint density of all values in the x vector (which is what I want). Should a vector of densities be returned, and if so, to what do they correspond? Second, and far more concerning, when I enter the following: varcov1 - array(0,dim=c(2,2)) varcov1[1,1] - 0.4891125 varcov1[2,2] - 0.4891125 varcov1[1,2] - 0.5 varcov1[2,1] - 0.5 varcov1 dmnorm(c(0.930315,-0.8706811),mean=c(1.109568,6.648583),varcov1) The result is an infinite density, which seems unlikely. For instance, the second value is more than 7 standard deviations from the mean. Thanks in advance for any comments and suggestions. -Mitch __ 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] Lag Function
Can anyone tell me what's going on here? x - matrix(data=c(1,2,3,4,5),ncol=1) x1 - lag(x,k=1) x x1 x - x1 That's with x specified as a column vector, but the same thing happens when it's a row vector. x - c(1,2,3,4,5) x1 - lag(x,k=1) x x1 x - x1 When the documentation says Vector or matrix arguments x are coerced to time series. What does that mean? Thank you, Mitch __ 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] VAR with contemporaneous effects
Hi, I would like to estimate a VAR of the form: Ay_t = By_t-1 + Cy_t-2 + ... + Dx_t + e_t Where A is a non-diagonal matrix of coefficients, B and C are matricies of coefficients and D is a matrix of coefficients for the exogenous variables. I don't think the package {vars} can do this because I want to include contemporaneous cross-variable impacts. So I want y1_t to affect y2_t and I think in {vars} I can only have y1_t-1 affect y2_t. {vars} will only allow VARs of the form: y_t = By_t-1 + Cy_t-2 + ... + Dx_t + e_t Solutions? Maybe another package? Or maybe I'm thinking about this wrong? (And I know that I have to put constraints on A to get identification - I'm willing to do that). Thanks, Mitch Downey __ 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] Constraining coefficients to be equal in svar
Hello, I'm working on an structural VAR using the var command to estimate and the svar command on the resultant object (package: vars). I want to constrain coefficients to equal one another, but that value to be estimated. So for the A matrix, I want A[2,1]=A[1,2] to be my constraints. Can this be done with this package? If so, how? If not, is there another package that it might be done with (I want only to estimate a VAR and get Impulse Response Functions, so I don't need any fancy cointegration or error correction techniques or any of that). Thanks. P. Mitchell Downey | Research Associate II Justice Policy Center | Urban Institute 2100 M. Street N.W. | Washington, DC 20037 T: (202) 261-5329 | F: (202) 659-8985 pdow...@urban.org | www.urban.org __ 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.