This file contains 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 pystan | |
!pip install -q pystan | |
# Install Facebook Prophet | |
!pip install -q fbprophet | |
# Download Google Trends data | |
!git clone https://gist.github.com/jcheong0428/838a1b1daf67473373da50627bc1bbda | |
!cp 838a1b1daf67473373da50627bc1bbda/*.csv . | |
import pandas as pd | |
import seaborn as sns |
This file contains 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
Month | back pain | lower back pain | chiropractor near me | |
---|---|---|---|---|
2013-01 | 67 | 69 | 0 | |
2013-02 | 64 | 66 | 0 | |
2013-03 | 66 | 67 | 0 | |
2013-04 | 69 | 71 | 0 | |
2013-05 | 69 | 70 | 1 | |
2013-06 | 67 | 68 | 1 | |
2013-07 | 74 | 77 | 1 | |
2013-08 | 71 | 75 | 1 | |
2013-09 | 69 | 70 | 2 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4 in line 1.
This file contains 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
Category: All categories | |
Month,back pain: (United States),lower back pain: (United States),neck pain: (United States) | |
2004-01,29,8,7 | |
2004-02,31,7,9 | |
2004-03,33,9,7 | |
2004-04,30,7,7 | |
2004-05,35,8,9 | |
2004-06,37,10,7 | |
2004-07,33,9,9 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 pymer4 | |
!pip install -q pymer4 | |
# load pymer4 | |
from pymer4.models import Lmer | |
model = Lmer('Weight ~ Time + Evit + (1 + Time|Pig)', data=data) | |
display(model.fit()) | |
# ANOVA results from fitted model | |
display(model.anova()) | |
# Plot estimated model coefficients | |
model.plot_summary() |
This file contains 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
%%R -i data | |
# Specify Evit as a factor and set a polynomial contrast. | |
data$Evit <- as.factor(data$Evit) | |
contrasts(data$Evit) <- contr.poly | |
m<-lmer('Weight ~ Time * Evit + (1|Pig)', data=data) | |
print(summary(m)) | |
# Relevel categorical data so base level is Evit100 | |
m<-lmer('Weight ~ Time * relevel(Evit, ref="Evit100") + (1|Pig)', data=data) | |
print(summary(m)) |
This file contains 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
%%R -i data -o betas | |
m<-lmer('Weight ~ Time + (1+Time|Pig)', data=data) | |
print(summary(m)) | |
betas <- fixef(m) |
This file contains 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
# make sure rpy2 was loaded using %load_ext rpy2.ipython | |
%%R | |
library(lme4) | |
library(lmerTest) | |
data(dietox, package='geepack') | |
m<-lmer('Weight ~ Time + (1+Time|Pig)', data=dietox) | |
print(summary(m)) |
This file contains 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
!apt-get install r-base | |
!pip install -q rpy2 | |
packnames = ('lme4', 'lmerTest', 'emmeans', "geepack") | |
from rpy2.robjects.packages import importr | |
from rpy2.robjects.vectors import StrVector | |
utils = importr("utils") | |
utils.chooseCRANmirror(ind=1) | |
utils.install_packages(StrVector(packnames)) |