Last active
December 18, 2020 17:10
-
-
Save audhiaprilliant/7dcd7d65292fd87367f48aa6f22b99ac to your computer and use it in GitHub Desktop.
Simulation of Autocorrelation in Linear Regression Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install package | |
| install.packages('dplyr') | |
| # Load the package | |
| library(dplyr) | |
| # Create a data aggregation | |
| statDf = df %>% | |
| group_by(Rho) %>% | |
| summarize( | |
| # Without autocorrelation | |
| mean_InterceptNonAutocorrelation = mean(interceptNonAutocorrelation), | |
| mean_InterceptNonAutocorrelation = sd(interceptNonAutocorrelation), | |
| mean_SlopeNonAutocorrelation = mean(slopeNonAutocorrelation), | |
| sd_SlopeNonAutocorrelation = sd(slopeNonAutocorrelation), | |
| # With autocorrelation | |
| mean_InterceptAutocorrelation = mean(interceptAutocorrelation), | |
| mean_InterceptAutocorrelation = sd(interceptAutocorrelation), | |
| mean_SlopeAutocorrelation = mean(slopeAutocorrelation), | |
| sd_SlopeAutocorrelation = sd(slopeAutocorrelation) | |
| ) %>% | |
| arrange(desc(Rho)) | |
| # View the result | |
| View(statDf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment