Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Last active December 18, 2020 17:11
Show Gist options
  • Save audhiaprilliant/47a02032135469be83857a17898bf22e to your computer and use it in GitHub Desktop.
Save audhiaprilliant/47a02032135469be83857a17898bf22e to your computer and use it in GitHub Desktop.
Simulation of Autocorrelation in Linear Regression Model
# Install package
install.packages('tidyr')
# Load the package
library(tidyr)
# Data melting
long = df %>%
gather(Coefficient, Value, -c(Rho))
# Create a new column indicating whether it is intercept or slope
long$Status = ifelse(substring(long$Coefficient, 1, 9) == 'intercept', 'Intercept', 'Slope')
# View the result
View(long)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment