# Simulating variables with predefined correlation and autocorrelation

 Classic List Threaded
7 messages
Reply | Threaded
Open this post in threaded view
|

## Simulating variables with predefined correlation and autocorrelation

 Hello everyone, I'm trying to simulate a set of variables by specifying correlations. For the simulated data, I also want to specify autocorrelations. Basically I am trying to simulate data assuming spatial durbin model (a model which accounts for autocorrelation in both Y and X). I came across the post on ‘*Simulating spatially autocorrelated data*’ in R-sig-geo ( https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) where similar query was discussed, however the focus there was on generating autocorrelated dependent variable. Can anyone assist me on this? Thanks in advance.         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 Dear Amitha, I'm not sure I understand well your question (but then, I don't know this Durbin model). From what I quickly looked up it follows this formulation: y = \rho W y + \alpha 1_n + X \beta + W X \theta + \varepsilon where y are the observations (thus, what you are trying to simulate if I understood correctly), W, X and 1_n are fixed and known matrices, and the greek letters are the unknown parameters. For simulating y from this model, you should assign values to the greek letters and compute: y = (I_n - \rho W)^{-1} [\alpha 1_n + X \beta + W X \theta + \varepsilon] Does this help? ƒacu.- On 8/21/19 8:52 AM, Amitha Puranik wrote: > Hello everyone, > > I'm trying to simulate a set of variables by specifying correlations. For > the simulated data, I also want to specify autocorrelations. Basically I am > trying to simulate data assuming spatial durbin model (a model which > accounts for autocorrelation in both Y and X). I came across the post > on ‘*Simulating > spatially autocorrelated data*’ in R-sig-geo ( > https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) where > similar query was discussed, however the focus there was on generating > autocorrelated dependent variable. > > Can anyone assist me on this? Thanks in advance. > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo        [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 In reply to this post by AMITHA PURANIK Dear Prof Facundo Muñoz, Thank you for a quick response. I am sorry for not phrasing my query clearly. I am interested to simulate 2 variables Y and X in such a way that the resultant variables should possess the correlation coefficient of 0.6 between Y and X and autocorrelation of 0.7 in Y and 0.4 in X. The query posted in the link ( https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) focussed on only the autocorrelation of Y (spatial lag model) whereas I would like to introduce some autocorrelation in X too (spatial durbin model). Is there a way to do this? Should a covariance structure defining both correlation and autocorrelation be specified while simulating variables? If so, how to define such covariance structure? I will be grateful for your assistance. Thanks in advance. Amitha Puranik         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 Administrator Could you please explain why you want to do this and whether you want to use the same weights for y and x? Maybe refer to https://doi.org/10.1111/j.1538-4632.1991.tb00235.x and work referred to there; I'll try to find other references later. Roger Bivand Norwegian School of Economics Bergen, Norway Fra: Amitha Puranik Sendt: torsdag 22. august, 12.41 Emne: Re: [R-sig-Geo]  Simulating variables with predefined correlation and autocorrelation Til: [hidden email] Kopi: [hidden email] Dear Prof Facundo Muñoz, Thank you for a quick response. I am sorry for not phrasing my query clearly. I am interested to simulate 2 variables Y and X in such a way that the resultant variables should possess the correlation coefficient of 0.6 between Y and X and autocorrelation of 0.7 in Y and 0.4 in X. The query posted in the link ( https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) focussed on only the autocorrelation of Y (spatial lag model) whereas I would like to introduce some autocorrelation in X too (spatial durbin model). Is there a way to do this? Should a covariance structure defining both correlation and autocorrelation be specified while simulating variables? If so, how to define such covariance structure? I will be grateful for your assistance. Thanks in advance. Amitha Puranik [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo        [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo Roger Bivand Department of Economics Norwegian School of Economics Helleveien 30 N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 Dear Prof. Bivand, Thanks a lot for responding and providing the material to read. I will definitely go through your paper and the references cited in it. I am working on simulating various scenarios where autocorrelation exists in Y or X or both and also in the residuals and compare the model performances on these data. At present I have planned to assign same weights (distance based) for both X and Y. I have found solution to simulate autocorrelated Y based on your response in the link ( https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html). But I have not found a way to induce autocorrelation in even the independent variables(s). Hence I posted this query. Thanks in advance. Regards, Amitha Puranik. On Thu, Aug 22, 2019 at 7:06 PM Roger Bivand <[hidden email]> wrote: > Could you please explain why you want to do this and whether you want to > use the same weights for y and x? Maybe refer to > https://doi.org/10.1111/j.1538-4632.1991.tb00235.x and work referred to > there; I'll try to find other references later. > > Roger Bivand > Norwegian School of Economics > Bergen, Norway > > > > Fra: Amitha Puranik > Sendt: torsdag 22. august, 12.41 > Emne: Re: [R-sig-Geo]  Simulating variables with predefined correlation > and autocorrelation > Til: [hidden email] > Kopi: [hidden email] > > > Dear Prof Facundo Muñoz, Thank you for a quick response. I am sorry for > not phrasing my query clearly. I am interested to simulate 2 variables Y > and X in such a way that the resultant variables should possess the > correlation coefficient of 0.6 between Y and X and autocorrelation of 0.7 > in Y and 0.4 in X. The query posted in the link ( > https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) > focussed on only the autocorrelation of Y (spatial lag model) whereas I > would like to introduce some autocorrelation in X too (spatial durbin > model). Is there a way to do this? Should a covariance structure defining > both correlation and autocorrelation be specified while simulating > variables? If so, how to define such covariance structure? I will be > grateful for your assistance. Thanks in advance. Amitha Puranik > [[alternative HTML version deleted]] > _______________________________________________ R-sig-Geo mailing list > [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo> >         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 Dear Amitha, If understand your query correctly, you could also have a look at my preprint on Monte Carlo simulations of different spatial regression models: https://kluedo.ub.uni-kl.de/frontdoor/index/index/docId/5630. The replication materials are online available (https://github.com/ruettenauer/Reproduction-Material-Spatial-Monte-Carlo-Experiments). The '01_Monte Carlo Simulation Spatial_Program.R' scipt provides a function to set up data with different constellations of autocorrelation. Maybe the code is useful for your purposes as well. Best, Tobias -----Original Message----- From: R-sig-Geo <[hidden email]> On Behalf Of Amitha Puranik Sent: 22 August 2019 17:19 To: [hidden email] Cc: [hidden email] Subject: Re: [R-sig-Geo] Simulating variables with predefined correlation and autocorrelation Dear Prof. Bivand, Thanks a lot for responding and providing the material to read. I will definitely go through your paper and the references cited in it. I am working on simulating various scenarios where autocorrelation exists in Y or X or both and also in the residuals and compare the model performances on these data. At present I have planned to assign same weights (distance based) for both X and Y. I have found solution to simulate autocorrelated Y based on your response in the link ( https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html). But I have not found a way to induce autocorrelation in even the independent variables(s). Hence I posted this query. Thanks in advance. Regards, Amitha Puranik. On Thu, Aug 22, 2019 at 7:06 PM Roger Bivand <[hidden email]> wrote: > Could you please explain why you want to do this and whether you want > to use the same weights for y and x? Maybe refer to > https://doi.org/10.1111/j.1538-4632.1991.tb00235.x and work referred > to there; I'll try to find other references later. > > Roger Bivand > Norwegian School of Economics > Bergen, Norway > > > > Fra: Amitha Puranik > Sendt: torsdag 22. august, 12.41 > Emne: Re: [R-sig-Geo]  Simulating variables with predefined > correlation and autocorrelation > Til: [hidden email] > Kopi: [hidden email] > > > Dear Prof Facundo Muñoz, Thank you for a quick response. I am sorry > for not phrasing my query clearly. I am interested to simulate 2 > variables Y and X in such a way that the resultant variables should > possess the correlation coefficient of 0.6 between Y and X and > autocorrelation of 0.7 in Y and 0.4 in X. The query posted in the link > ( > https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) > focussed on only the autocorrelation of Y (spatial lag model) whereas > I would like to introduce some autocorrelation in X too (spatial > durbin model). Is there a way to do this? Should a covariance > structure defining both correlation and autocorrelation be specified > while simulating variables? If so, how to define such covariance > structure? I will be grateful for your assistance. Thanks in advance. > Amitha Puranik [[alternative HTML version deleted]] > _______________________________________________ R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo> >         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo_______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

## Re: Simulating variables with predefined correlation and autocorrelation

 Dear Dr Tobias, Thanks a lot for sharing the materials. This means a lot! On Tue, Sep 3, 2019 at 1:05 PM Tobias Rüttenauer <[hidden email]> wrote: > Dear Amitha, > > If understand your query correctly, you could also have a look at my > preprint on Monte Carlo simulations of different spatial regression models: > https://kluedo.ub.uni-kl.de/frontdoor/index/index/docId/5630. > > The replication materials are online available ( > https://github.com/ruettenauer/Reproduction-Material-Spatial-Monte-Carlo-Experiments). > The '01_Monte Carlo Simulation Spatial_Program.R' scipt provides a function > to set up data with different constellations of autocorrelation. Maybe the > code is useful for your purposes as well. > > Best, > Tobias > > > -----Original Message----- > From: R-sig-Geo <[hidden email]> On Behalf Of Amitha > Puranik > Sent: 22 August 2019 17:19 > To: [hidden email] > Cc: [hidden email] > Subject: Re: [R-sig-Geo] Simulating variables with predefined correlation > and autocorrelation > > Dear Prof. Bivand, > > > > Thanks a lot for responding and providing the material to read. I will > definitely go through your paper and the references cited in it. > > I am working on simulating various scenarios where autocorrelation exists > in Y or X or both and also in the residuals and compare the model > performances on these data. At present I have planned to assign same > weights (distance based) for both X and Y. I have found solution to > simulate autocorrelated Y based on your response in the link ( > https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html). But > I have not found a way to induce autocorrelation in even the independent > variables(s). Hence I posted this query. Thanks in advance. > > Regards, > > Amitha Puranik. > > > > > > > > > > > > > > > > On Thu, Aug 22, 2019 at 7:06 PM Roger Bivand <[hidden email]> wrote: > > > Could you please explain why you want to do this and whether you want > > to use the same weights for y and x? Maybe refer to > > https://doi.org/10.1111/j.1538-4632.1991.tb00235.x and work referred > > to there; I'll try to find other references later. > > > > Roger Bivand > > Norwegian School of Economics > > Bergen, Norway > > > > > > > > Fra: Amitha Puranik > > Sendt: torsdag 22. august, 12.41 > > Emne: Re: [R-sig-Geo]  Simulating variables with predefined > > correlation and autocorrelation > > Til: [hidden email] > > Kopi: [hidden email] > > > > > > Dear Prof Facundo Muñoz, Thank you for a quick response. I am sorry > > for not phrasing my query clearly. I am interested to simulate 2 > > variables Y and X in such a way that the resultant variables should > > possess the correlation coefficient of 0.6 between Y and X and > > autocorrelation of 0.7 in Y and 0.4 in X. The query posted in the link > > ( > > https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012728.html) > > focussed on only the autocorrelation of Y (spatial lag model) whereas > > I would like to introduce some autocorrelation in X too (spatial > > durbin model). Is there a way to do this? Should a covariance > > structure defining both correlation and autocorrelation be specified > > while simulating variables? If so, how to define such covariance > > structure? I will be grateful for your assistance. Thanks in advance. > > Amitha Puranik [[alternative HTML version deleted]] > > _______________________________________________ R-sig-Geo mailing list > > [hidden email] > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo> > > > > >         [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo> >         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo